| @@ 53-79 (lines=27) @@ | ||
| 50 | * |
|
| 51 | * @return string |
|
| 52 | */ |
|
| 53 | protected function renderItem(Item $item) |
|
| 54 | { |
|
| 55 | $renderedItems = ''; |
|
| 56 | $type = $item->get('type', 'error'); |
|
| 57 | switch ($type) { |
|
| 58 | case Item::TYPE_LINK: |
|
| 59 | $anchorStart = ''; |
|
| 60 | $anchorEnd = ''; |
|
| 61 | $liClass = ' class="active"'; |
|
| 62 | if ($item->has('link')) { |
|
| 63 | $anchorStart = '<a href="' . $this->xoops->url($item->get('link')) . '">'; |
|
| 64 | $anchorEnd = '</a>'; |
|
| 65 | $liClass = ''; |
|
| 66 | } |
|
| 67 | $caption = $item->get('caption', ''); |
|
| 68 | $icon = $item->has('icon') ? |
|
| 69 | '<span class="' . $item->get('icon') . '" aria-hidden="true"></span> ' : ''; |
|
| 70 | $renderedItems .= "<li{$liClass}>{$anchorStart}{$icon}{$caption}{$anchorEnd}</li>"; |
|
| 71 | break; |
|
| 72 | case Item::TYPE_LIST: |
|
| 73 | foreach ($item['items'] as $listItem) { |
|
| 74 | $renderedItems .= $this->renderItem($listItem); |
|
| 75 | } |
|
| 76 | break; |
|
| 77 | default: |
|
| 78 | break; |
|
| 79 | } |
|
| 80 | return $renderedItems; |
|
| 81 | } |
|
| 82 | } |
|
| @@ 67-96 (lines=30) @@ | ||
| 64 | * |
|
| 65 | * @return string |
|
| 66 | */ |
|
| 67 | protected function renderItem(Item $item) |
|
| 68 | { |
|
| 69 | $renderedItems = ''; |
|
| 70 | $type = $item->get('type', 'error'); |
|
| 71 | switch ($type) { |
|
| 72 | case Item::TYPE_LINK: |
|
| 73 | $anchorStart = ''; |
|
| 74 | $anchorEnd = ''; |
|
| 75 | $liClass = ' class="active"'; |
|
| 76 | if ($item->has('link')) { |
|
| 77 | $anchorStart = '<a href="' . $this->xoops->url($item->get('link')) . '">'; |
|
| 78 | $anchorEnd = '</a>'; |
|
| 79 | $liClass = ''; |
|
| 80 | } |
|
| 81 | $caption = $item->get('caption', ''); |
|
| 82 | $icon = $item->has('icon') ? |
|
| 83 | '<span class="' . $item->get('icon') . '" aria-hidden="true"></span> ' : ''; |
|
| 84 | $renderedItems .= "<li{$liClass}>{$anchorStart}{$icon}{$caption}{$anchorEnd}</li>"; |
|
| 85 | break; |
|
| 86 | case Item::TYPE_LIST: |
|
| 87 | foreach ($item['items'] as $listItem) { |
|
| 88 | $renderedItems .= $this->renderItem($listItem); |
|
| 89 | } |
|
| 90 | break; |
|
| 91 | case Item::TYPE_DIVIDER: |
|
| 92 | $renderedItems .= '<li role="separator" class="divider"></li>'; |
|
| 93 | break; |
|
| 94 | default: |
|
| 95 | break; |
|
| 96 | } |
|
| 97 | return $renderedItems; |
|
| 98 | } |
|
| 99 | } |
|