Пример #1
0
    public function renderItem(Item $item, $html = '')
    {
        $subItems = $item->getSubItems();
        $class = $item->isActive() ? 'active' : '';
        if (sizeof($subItems) > 0) {
            // Если первый уровень
            if (empty($html)) {
                $html .= '
					<li class="mm-dropdown mm-dropdown-root ' . $class . ' ">';
                $html .= '<a href="#">' . $this->renderIcon($item) . '<span class="mm-text">' . $item->getLabel() . '</span></a>';
                $html .= '<ul class="mmc-dropdown-delay animated fadeInLeft">';
            } else {
                $html .= '
					<li class="mm-dropdown"' . $class . '>';
                $html .= '<a tabindex="-1" href="#">' . $this->renderIcon($item) . ' <span class="mm-text">' . $item->getLabel() . '</span></a>';
                $html .= '<ul>';
            }
            foreach ($subItems as $key => $subItem) {
                $html .= $this->renderItem($subItem, ' ');
            }
            $html .= '</ul>
				</li>';
        } else {
            $html .= '<li class=' . $class . '>
						<a href="' . $item->getUrl() . '">' . $this->renderIcon($item) . ' <span class="mm-text">' . $item->getLabel() . '</span></a>
					</li>';
        }
        return $html;
    }
Пример #2
0
 /**
  * Рендерим иконку
  * @param  Item   $item 
  * @return string
  */
 public function renderIcon(Item $item)
 {
     $icon = $item->getOptionByKey('icon');
     if (!empty($icon)) {
         return '<i class="menu-icon fa fa-' . $icon . '"></i>';
     }
     return '';
 }
Пример #3
0
 /**
  * Рендерит один пункт меню
  * @param  Item   $item 
  * @param  array $options дополнительные опции
  * @return  string
  */
 public function renderItem(Item $item, $options = array())
 {
     $class = isset($options['class']) ? $options['class'] : '';
     $url = $item->getUrl();
     if (!empty($url)) {
         return '<li class="' . $class . '"><a href="' . $url . '">' . $item->getLabel() . '</a></li>';
     } else {
         return '<li class="' . $class . '">' . $item->getLabel() . '</li>';
     }
 }
Пример #4
0
    /**
     * Рендерит один пункт меню
     * @param  Item   $item [description]
     * @return [type]       [description]
     */
    public function renderItem(Item $item)
    {
        $subItems = $item->getSubItems();
        if (sizeof($subItems) > 0) {
            $html = '<li class="dropdown">
						<a href="#" class="dropdown-toggle" data-toggle="dropdown">' . $this->renderIcon($item) . ' ' . $item->getLabel() . '</a>
							<ul class="dropdown-menu">';
            foreach ($subItems as $subItem) {
                $html .= '<li><a href="' . $subItem->getUrl() . '">' . $this->renderIcon($item) . '<span class="mm-text">' . $subItem->getLabel() . '</span></a></li>';
            }
            $html .= '</ul>
					</li>';
        } else {
            $html = '<li>
						<a href="' . $item->getUrl() . '">' . $this->renderIcon($item) . ' <span class="mm-text">' . $item->getLabel() . '</span></a>
					</li>';
        }
        return $html;
    }
Пример #5
0
 /**
  * @ToDo
  * Добавляет вложенный элемент
  */
 public function addItem($id, $url, $options = array())
 {
     $item = new Item($id, $url, $options);
     // Если такой пункт уже есть
     if ($this->getSection()->find($item->getId())) {
         throw new NavigationException('Id ' . $item->getId() . ' already exists');
     }
     if ($item !== null && $item !== false) {
         $item->setSectionName($this->getSectionName());
         $this->_subItems[$id] = $item;
     }
     return $this->_subItems;
 }