예제 #1
0
 /**
  * @param int   $level
  * @param array $item
  *
  * @return string
  */
 public function renderItem($level, $item)
 {
     if ($item['acl']) {
         if (false == app()->aclService()->authorize($item['acl'])) {
             return '';
         }
     }
     $href = null;
     if ($item['type'] == 'separator') {
         return '<li class="divider"></li>';
     } else {
         if ($item['type'] == 'route') {
             $href = app()->routing()->getUrl($item['route'], $item['params']);
         } else {
             if ($item['type'] == 'plugin') {
                 $item = app()->navigation()->signal($item['event'], $item);
             }
         }
     }
     $label = app()->i18n()->getTranslator()->text($item['label']);
     // process plugin but return false.
     if (!$item) {
         return '';
     }
     $extra = '';
     $cls = 'ni-' . $item['name'];
     if (!empty($item['class'])) {
         $cls = $item['class'];
     }
     if ($item['active']) {
         $cls .= ' active';
     }
     if (!empty($item['extra'])) {
         $extra = _htmlattrs($item['extra']);
     }
     if (!empty($item['children'])) {
         $childrenHtml = $this->renderChildren($item['children']['level'], $item['children']['items']);
         return '<li class="dropdown">' . '<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">' . $label . '<span class="caret"></span></a>' . $childrenHtml . '</li>';
     } else {
         return '<li role="presentation" class="' . $cls . '"><a ' . $extra . ' href="' . $href . '">' . $label . '</a></li>';
     }
 }
 /**
  * @param int   $level
  * @param array $item
  *
  * @return string
  */
 public function renderItem($level, $item)
 {
     if (is_string($item)) {
         return $item;
     }
     $href = null;
     if ($item['type'] == 'separator') {
         return '<li class="divider"></li>';
     } else {
         if ($item['type'] == 'route') {
             $item['href'] = app()->routing()->getUrl($item['route'], $item['params']);
         }
     }
     if (is_string($item)) {
         return $item;
     }
     if (empty($item['href'])) {
         if (!empty($item['route'])) {
             $href = app()->routing()->getUrl($item['route'], $item['params']);
         }
     } else {
         $href = $item['href'];
     }
     $label = app()->trans()->text($item['label']);
     // process plugin but return false.
     if (!$item) {
         return '';
     }
     $extra = '';
     $cls = 'ni-' . $item['name'];
     if (!empty($item['class'])) {
         $cls = $item['class'];
     }
     if ($item['active']) {
         $cls .= ' active';
     }
     if (!empty($item['extra'])) {
         $extra = _htmlattrs($item['extra']);
     }
     if (!empty($item['children']) && $level < $this->level) {
         $childrenHtml = $this->renderChildren($item['children']['level'], $item['children']['items']);
         return '<li class="dropdown ' . $cls . '">' . '<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">' . $label . $this->params['dropdownIcon'] . '</a>' . $childrenHtml . '</li>';
     } else {
         return '<li class="' . $cls . '"><a ' . $extra . ' href="' . $href . '">' . $label . '</a></li>';
     }
 }