submenus = array();
$this->addLink($link);
$this->addLabel($label, $pos);
$this->addFlyout($flyout);
}
function isSeparator()
{
$this->separator = true;
}
function addLabel($label=' ', $pos='right')
{
if ($label) $this->label = $label;
$this->labelpos = $pos;
}
function addLink($link='#')
{
$this->link = $link;
}
function addOnclick($onclick)
{
$this->onclick = $onclick;
}
function addIcon($icon, $hovericon=null)
{
if (file_exists($icon)) $this->icon = $icon;
else $this->icon = null;
if (file_exists($hovericon)) $this->hovericon = $hovericon;
else $this->hovericon = null;
}
function addFlyout($flyout='down')
{
$this->flyout = $flyout;
}
function addClass($class, $hoverclass='', $submenuclass='', $iconclass='icon_general')
{
$this->class = $class;
$this->hoverclass = $hoverclass;
$this->submenuclass = $submenuclass;
$this->iconclass = $iconclass;
}
function addTarget($target)
{
$this->target = $target;
}
function addSubMenu($obj)
{
$this->submenus[] = $obj;
}
function addSeparator() {
$submenu = new Menu();
$submenu->isSeparator();
$this->submenus[] = $submenu;
}
// Get the menu as a simple list - for accessible interfaces, search engines and CSS menus
function getMenuAsList() {
$link = '';
if ($this->separator) {
return "\t".'
'."\n";
}
if ($this->link) {
if ($this->target !== null) {
$link .= ' target="'.$this->target.'"';
}
if ($this->link=='#') {
$this->link = "javascript:;";
if ($this->onclick !== null) {
$link .= ' onclick="'.$this->onclick.'"';
}
$html=''.$this->label.'';
} else {
$html=''.$this->label.'';
}
} else {
return '';
}
if ($this->submenus) {
$html.="\n\t".'
'."\n";
foreach ($this->submenus as $submenu) {
$html.="\t".$submenu->getMenuAsList();
}
$html.="\t".'
';
return '
'.$html.'
'."\n";
}
return '
'.$html.'
'."\n";
}
// Get the menu as a dropdown form element
function getMenuAsDropdown() {
if ($this->separator || !$this->link && !$this->submenus) {
return '';
}
if ($this->submenus) {
$options='';
foreach ($this->submenus as $submenu) {
$options.=$submenu->getMenuAsDropdown();
}
return '';
} else {
return '';
}
}
// Get the menu as a list of icons
function getMenuAsIcons() {
if ($this->separator || !$this->link && !$this->submenus) {
return '';
}
$icons=array();
if ($this->icon) {
$icons[]='';
}
if ($this->submenus) {
foreach ($this->submenus as $submenu) {
$icons[]=$submenu->getMenuAsIcons();
}
}
return join(' ', $icons);
}
function getMenu()
{
global
$menucount,
$TEXT_DIRECTION,
$WT_IMAGE_DIR,
$WT_IMAGES
;
if (!isset($menucount))
{
$menucount = 0;
}
else
{
$menucount++;
}
$id = $menucount.rand();
if ($this->separator)
{
$output = "