Ejemplo n.º 1
0
 /**
  * Render a menu item
  *
  * @param Zym_Menu_Item $item
  * @return string
  */
 protected function _renderMenuItem(Zym_Menu_Item $item, $menuClass)
 {
     $link = null;
     $target = $item->getTarget();
     if (!empty($target)) {
         if (is_array($target)) {
             $link = (string) $this->_view->url($target, null, true);
         } else {
             $link = (string) $target;
         }
     }
     $xhtml .= sprintf('<li id="%s" class="%sitem', $item->getId(), $menuClass);
     if ($item->isSelected()) {
         $xhtml .= ' activeMenuItem';
     }
     $xhtml .= '">';
     if (!empty($link)) {
         $xhtml .= sprintf('<a class="%sitemlabel" href="%s">%s</a>', $menuClass, $link, $item->getLabel());
     } else {
         $xhtml .= $item->getLabel();
     }
     if ($item->hasMenuItems()) {
         $xhtml .= $this->_renderMenu($item, $menuClass);
     }
     $xhtml .= '</li>';
     return $xhtml;
 }
Ejemplo n.º 2
0
 /**
  * Render a menu item
  *
  * @param Zym_Menu_Item $item
  * @return string
  */
 protected function _renderMenuItem(Zym_Menu_Item $item)
 {
     $link = null;
     $target = $item->getTarget();
     if (!empty($target)) {
         if (is_array($target)) {
             $link = $this->_view->url($target, null, true);
         } else {
             $link = (string) $target;
         }
     }
     $js .= sprintf('{text:"%s"', $item->getLabel());
     if ($item->isSelected()) {
         $js .= ',selected:true';
     }
     if (!empty($link)) {
         $js .= sprintf(',url:"%s"', $link);
     }
     if ($item->hasMenuItems()) {
         $js .= sprintf(',submenu:{id:"%s",itemdata:%s}', $item->getId(), $this->_renderMenu($item));
     }
     $js .= '}';
     return $js;
 }