예제 #1
0
 protected function renderItems($items, $options = [])
 {
     $lines = [];
     foreach ($items as $i => $item) {
         if (isset($item['visible']) && !$item['visible']) {
             continue;
         }
         if (is_string($item)) {
             $lines[] = $item;
             continue;
         }
         if (!array_key_exists('label', $item)) {
             throw new InvalidConfigException("The 'label' option is required.");
         }
         $encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabels;
         $label = $encodeLabel ? Html::encode($item['label']) : $item['label'];
         $itemOptions = ArrayHelper::getValue($item, 'options', []);
         $linkOptions = ArrayHelper::getValue($item, 'linkOptions', []);
         $url = array_key_exists('url', $item) ? $item['url'] : null;
         if ($url === null) {
             $content = $label;
         } else {
             $content = Html::a($label, $url, $linkOptions);
         }
         $lines[] = Html::tag('li', $content, $itemOptions);
     }
     return Html::tag('ul', implode("\n", $lines), $options);
 }
예제 #2
0
 protected function renderHeader($items)
 {
     foreach ($items as $i => $item) {
         if (!array_key_exists('label', $item)) {
             throw new InvalidConfigException("The 'label' option is required.");
         }
         $encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabel;
         $label = $encodeLabel ? Html::encode($item['label']) : $item['label'];
         $itemOptions = ArrayHelper::getValue($item, 'itemOptions', []);
         $itemOptions['class'] = isset($itemOptions['class']) ? 'tab ' . $itemOptions['class'] : 'tab col s3';
         $linkOptions = ArrayHelper::getValue($item, 'linkOptions', []);
         $url = array_key_exists('url', $item) ? $item['url'] : null;
         $href = isset($item['options']['id']) ? $item['options']['id'] : $item['id'];
         $content = Html::a($label, '#' . $href);
         $lines[] = Html::tag('li', $content, $itemOptions);
     }
     return $lines;
 }