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) { global $WT_IMAGES; if (isset($WT_IMAGES[$icon])) { $this->icon = $WT_IMAGES[$icon]; } else { $this->icon = null; } if (isset($WT_IMAGES[$hovericon])) { $this->hovericon = $WT_IMAGES[$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".''; 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 ''; } } function getMenu() { global $menucount, $TEXT_DIRECTION, $WT_IMAGES; if (!isset($menucount)) { $menucount = 0; } else { $menucount++; } $id = $menucount.rand(); if ($this->separator) { $output = "
    " ."\"\"" ."
    "; return $output; } $c = count($this->submenus); $output = "
    class}\">\n"; if ($this->link=="#") $this->link = "javascript:;"; $link = "link}\" onmouseover=\""; if ($c >= 0) { $link .= "show_submenu('menu{$id}_subs', 'menu{$id}', '{$this->flyout}'); "; } if ($this->hoverclass !== null) { $link .= "change_class('menu{$id}', '{$this->hoverclass}'); "; } if ($this->hovericon !== null) { $link .= "change_icon('menu{$id}_icon', '{$this->hovericon}'); "; } $link .= '" onmouseout="'; if ($c >= 0) { $link .= "timeout_submenu('menu{$id}_subs'); "; } if ($this->hoverclass !== null) { $link .= "change_class('menu{$id}', '{$this->class}'); "; } if ($this->hovericon !== null) { $link .= "change_icon('menu{$id}_icon', '{$this->icon}'); "; } if ($this->onclick !== null) { $link .= "\" onclick=\"{$this->onclick}"; } if ($this->target !== null) { $link .= '" target="'.$this->target; } $link .= "\">"; if ($this->icon !== null) { $tempTitle = str_replace("\"", '', $this->label); $MenuIcon = "icon}\" class=\"icon\" alt=\"{$tempTitle}\" title=\"{$tempTitle}\" />"; switch ($this->labelpos) { case "right": $output .= $link; $output .= $MenuIcon; $output .= $this->label; $output .= ""; break; case "left": $output .= $link; $output .= $this->label; $output .= $MenuIcon; $output .= ""; break; case "down": $output .= $link; $output .= $MenuIcon; $output .= "
    "; $output .= $this->label; $output .= ""; break; case "up": $output .= $link; $output .= $this->label; $output .= "
    "; $output .= $MenuIcon; $output .= ""; break; default: $output .= $link; $output .= $MenuIcon; $output .= ""; } } else { $output .= $link; $output .= $this->label; $output .= ""; } if ($c > 0) { $submenuid = "menu{$id}_subs"; if ($TEXT_DIRECTION == 'ltr') { $output .= '
    '; } else { $output .= '
    '; } $output .= "
    submenuclass}\" style=\"position: absolute; visibility: hidden; z-index: 100;"; if ($this->flyout == 'right') { if ($TEXT_DIRECTION == 'ltr') { $output .= ' left: 80px;'; } else { $output .= ' right: 50px;'; } } $output .= "\" onmouseover=\"show_submenu('{$this->parentmenu}'); show_submenu('{$submenuid}');\" onmouseout=\"timeout_submenu('menu{$id}_subs');\">\n"; foreach ($this->submenus as $submenu) { $submenu->parentmenu = $submenuid; $output .= $submenu->getMenu(); } $output .= "
    \n"; } $output .= "
    \n"; return $output; } /** * returns the number of submenu's in this menu * @return int */ function subCount() { return count($this->submenus); } }