public function run() { echo Html::beginTag('div', ['class' => 'info-box ' . ($this->bgFill ? $this->bg : '')]); if (!$this->icon) { $this->icon = Html::fa('question', 'i'); } echo Html::tag('span', $this->icon, ['class' => 'info-box-icon ' . ($this->bgFill ? '' : $this->bg)]); echo Html::beginTag('div', ['class' => 'info-box-content']); echo Html::tag('span', $this->text, ['class' => 'info-box-text']); echo Html::tag('span', $this->number, ['class' => 'info-box-number']); if ($this->progress !== null) { echo Html::tag('div', Html::tag('div', '', ['class' => 'progress-bar', 'style' => 'width: ' . $this->progress . '%;']), ['class' => 'progress']); if (!empty($this->progressText)) { echo Html::tag('div', $this->progressText, ['class' => 'progress-description']); } } echo Html::endTag('div'); echo Html::endTag('div'); }
/** * Renders a widget's item. * @param string|array $item the item to render. * @return string the rendering result. * @throws InvalidConfigException */ 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', '#'); $linkOptions = ArrayHelper::getValue($item, 'linkOptions', []); if (isset($item['active'])) { $active = ArrayHelper::remove($item, 'active', false); } else { $active = $this->isItemActive($item); } if ($items !== null) { $linkOptions['data-toggle'] = 'dropdown'; Html::addCssClass($options, ['widget' => 'dropdown']); Html::addCssClass($linkOptions, ['widget' => 'dropdown-toggle']); if ($this->dropDownCaret !== '') { $label .= ' ' . $this->dropDownCaret; } if (is_array($items)) { if ($this->activateItems) { $items = $this->isChildActive($items, $active); } $items = $this->renderDropdown($items, $item); } } if ($this->activateItems && $active) { Html::addCssClass($options, 'active'); } return Html::tag('li', Html::a($label, $url, $linkOptions) . $items, $options); }