Ejemplo n.º 1
0
 /**
  * Return the opening markup for the given navigation item
  *
  * @param   NavigationItem  $item
  *
  * @return  string
  */
 public function beginItemMarkup(NavigationItem $item)
 {
     $cssClass = array(static::CSS_CLASS_ITEM);
     if ($item->hasChildren() && $item->getChildren()->getLayout() === Navigation::LAYOUT_DROPDOWN) {
         $cssClass[] = static::CSS_CLASS_DROPDOWN;
         $item->setAttribute('class', static::CSS_CLASS_DROPDOWN_TOGGLE)->setIcon(static::DROPDOWN_TOGGLE_ICON)->setUrl('#');
     }
     if ($item->getActive()) {
         $cssClass[] = static::CSS_CLASS_ACTIVE;
     }
     $content = sprintf('<li id="%s" class="%s">', $this->view()->escape($item->getUniqueName()), join(' ', $cssClass));
     return $content;
 }
Ejemplo n.º 2
0
 /**
  * Add a child to this item
  *
  * If the child is active this item gets activated as well.
  *
  * @param   NavigationItem  $child
  *
  * @return  $this
  */
 public function addChild(NavigationItem $child)
 {
     $this->getChildren()->addItem($child->setParent($this));
     if ($child->getActive()) {
         $this->setActive();
     }
     return $this;
 }
Ejemplo n.º 3
0
 /**
  * Return the opening markup for the given navigation item
  *
  * @param   NavigationItem  $item
  *
  * @return  string
  */
 public function beginItemMarkup(NavigationItem $item)
 {
     $cssClasses = array(static::CSS_CLASS_ITEM);
     if ($item->hasChildren() && $item->getChildren()->getLayout() === Navigation::LAYOUT_DROPDOWN) {
         $cssClasses[] = static::CSS_CLASS_DROPDOWN;
         $item->setAttribute('class', static::CSS_CLASS_DROPDOWN_TOGGLE)->setIcon(static::DROPDOWN_TOGGLE_ICON)->setUrl('#');
     }
     if ($item->getActive()) {
         $cssClasses[] = static::CSS_CLASS_ACTIVE;
     }
     if ($item->getIcon() === null) {
         // @TODO(el): Add constant
         $cssClasses[] = 'no-icon';
     }
     if ($cssClass = $item->getCssClass()) {
         $cssClasses[] = $cssClass;
     }
     $content = sprintf('<li class="%s">', join(' ', $cssClasses));
     return $content;
 }