Ejemplo n.º 1
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     if (!isset($this->body['content'])) {
         echo Html::endTag('div');
     }
     if (isset($this->footer['content'])) {
         echo Html::tag('div', $this->footer['content'], $this->footer['options']);
     }
     echo Html::endTag('div');
 }
Ejemplo n.º 2
0
 /**
  * @inheritdoc
  */
 public function renderItem($item)
 {
     if (is_string($item)) {
         return $item;
     }
     if (!isset($item['label'])) {
         throw new InvalidConfigException("The 'label' option is required.");
     }
     $encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabels;
     $label = $encodeLabel ? Html::encode($item['label']) : $item['label'];
     $options = ArrayHelper::getValue($item, 'options', []);
     $items = ArrayHelper::getValue($item, 'items');
     $url = ArrayHelper::getValue($item, 'url', '#');
     $name = ArrayHelper::getValue($item, 'name');
     $description = ArrayHelper::getValue($item, 'description');
     $linkOptions = ArrayHelper::getValue($item, 'linkOptions', []);
     $options['id'] = $name;
     $options['title'] = $description;
     if (isset($item['active'])) {
         $active = ArrayHelper::remove($item, 'active', false);
     } else {
         $active = $this->isItemActive($item);
     }
     if ($items !== null) {
         $linkOptions['data-toggle'] = $this->toggle;
         Html::addCssClass($options, ['widget' => $this->toggle]);
         Html::addCssClass($linkOptions, ['widget' => $this->toggle . '-toggle']);
         if ($this->dropDownCaret !== '') {
             $label .= ' ' . $this->dropDownCaret;
         }
         if (is_array($items)) {
             if ($this->activateItems) {
                 $items = $this->isChildActive($items, $active);
             }
             if ($this->toggle == static::TOGGLE_COLLAPSE) {
                 $linkOptions['data-target'] = '#' . $this->collapseIdPrefix . $name;
                 $items = $this->renderCollapse($items, $item);
             } else {
                 $items = $this->renderDropdown($items, $item);
             }
         }
     }
     if ($this->activateItems && $active) {
         Html::addCssClass($options, 'active');
     }
     return Html::tag('li', Html::a($label, $url, $linkOptions) . $items, $options);
 }