public function run() { $view = $this->getView(); B3wAsset::register($view); if (empty($this->content)) { return ''; } $_hb = $this->headerButtons !== false ? ButtonGroup::widget($this->headerButtons) : ''; $_fb = $this->footerButtons !== false ? ButtonGroup::widget($this->footerButtons) : ''; $header = $this->title !== false ? Html::tag('div', $this->title . $_hb, ['class' => 'panel-heading']) : ''; $footer = $this->footer !== false ? Html::tag('div', $this->footer . $_fb, ['class' => 'panel-footer']) : ''; $this->content = Html::tag('div', $this->content, ['class' => 'panel-body']); $table = $this->table !== false ? $this->table : ''; return Html::tag('div', $header . $this->content . $table . $footer, ['class' => 'panel panel-' . $this->type, 'id' => $this->id]); }
public function run() { $view = $this->getView(); B3wAsset::register($view); if (!is_array($this->items) || count($this->items) == 0) { return ''; } //----------------------------------------- $this->size = strtolower($this->size); $_sizeClass = in_array($this->size, ['xs', 'sm', 'lg']) ? 'btn-group-' . $this->size : ''; $_sizeBtnClass = in_array($this->size, ['xs', 'sm', 'lg']) ? 'btn-' . $this->size : ''; $this->type = strtolower($this->type); $_typeClass = in_array($this->type, ['default', 'success', 'danger', 'warning', 'info', 'primary']) ? 'btn-' . $this->type : ''; $out = ''; foreach ($this->items as $item) { if (isset($item['items']) && is_array($item['items'])) { $linkOptions = []; $aClasses = ['btn', $_typeClass, 'dropdown-toggle', $_sizeBtnClass]; if (array_key_exists('linkOptions', $item)) { $_ = $item['linkOptions']; if (array_key_exists('class', $_)) { $aClasses = array_merge($aClasses, [$_['class']]); unset($_['class']); } $linkOptions = array_merge($_, ['data-toggle' => 'dropdown']); } $linkOptions['class'] = implode(' ', $aClasses); $groupOptions = array_key_exists('groupOptions', $item) ? $item['groupOptions'] : []; if (array_key_exists('class', $groupOptions)) { $groupOptions['class'] = $groupOptions['class'] . ' btn-group'; } else { $groupOptions['class'] = 'btn-group'; } $groupOptions['role'] = 'group'; $out .= Html::tag('div', Html::a($item['label'] . ' <span class="caret"></span>', '#', $linkOptions) . Dropdown::widget(['items' => $item['items'], 'encodeLabels' => array_key_exists('encodeLabels', $item) ? $item['encodeLabels'] : true]), $groupOptions); } else { $item['linkOptions']['class'] = (isset($item['linkOptions']['class']) ? $item['linkOptions']['class'] : '') . ' btn ' . $_typeClass; $out .= Html::a($item['label'], $item['url'], $item['linkOptions']); } } $this->containerOptions['class'] .= ' btn-group ' . $_sizeClass; $this->containerOptions['role'] = 'group'; return !empty($out) ? Html::tag('div', $out, $this->containerOptions) . ($this->addClearfix ? Html::tag('div', '', ['class' => 'clearfix']) : '') : ''; }