label =$label; $this->labelpos=$labelpos; $this->link =$link; $this->id =$id; $this->flyout =$flyout; $this->submenus=array(); } 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 addFlyout($flyout='down') { $this->flyout = $flyout; } function addClass($class, $submenuclass='', $iconclass='icon_general') { $this->class = $class; $this->submenuclass = $submenuclass; $this->iconclass = $iconclass; } function addTarget($target) { $this->target = $target; } function addSubMenu($obj) { $this->submenus[] = $obj; } // public function __toString() { return $this->getMenuAsList(); } // Get the menu as a simple list - for accessible interfaces, search engines and CSS menus function getMenuAsList() { $link = ''; if ($this->link) { if ($this->target !== null) { $link .= ' target="'.$this->target.'"'; } if ($this->link=='#') { if ($this->onclick !== null) { $link .= ' onclick="'.$this->onclick.'"'; } $html=''.$this->label.''; } else { $html=''.$this->label.''; } } else { $html=$this->label; } if ($this->submenus) { $html.=''; } if ($this->id) { return '
  • '.$html.'
  • '; } else { return '
  • '.$html.'
  • '; } } function getMenu() { global $menucount, $TEXT_DIRECTION, $WT_IMAGES; if (!isset($menucount)) { $menucount = 0; } else { $menucount++; } $id = $menucount.rand(); $c = count($this->submenus); $output = "
    class}\">"; $link = "link}\" onmouseover=\""; if ($c >= 0) { $link .= "show_submenu('menu{$id}_subs', 'menu{$id}', '{$this->flyout}');"; } $link .= '" onmouseout="'; if ($c >= 0) { $link .= "timeout_submenu('menu{$id}_subs');"; } if ($this->onclick !== null) { $link .= "\" onclick=\"{$this->onclick}"; } if ($this->target !== null) { $link .= '" target="'.$this->target; } $link .= "\">"; $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');\">"; foreach ($this->submenus as $submenu) { $submenu->parentmenu = $submenuid; $output .= $submenu->getMenu(); } $output .= "
    "; } $output .= "
    "; return $output; } /** * returns the number of submenu's in this menu * @return int */ function subCount() { return count($this->submenus); } }