/** * Initializes menu items */ public function initItems() { if (!empty($this->items)) { $links = array(); if ($this->homeLabel !== false) { $label = $this->homeLabel !== null ? $this->homeLabel : Icon::icon(Enum::ICON_HOME); $links[$label] = array('href' => $this->homeUrl !== null ? $this->homeUrl : \Yii::app()->homeUrl); } foreach ($this->items as $label => $options) { if (is_string($label)) { if ($this->encodeLabel) { $label = \CHtml::encode($label); } if (is_string($options)) { $links[$label] = array('href' => \CHtml::normalizeUrl($options)); } else { $url = ArrayHelper::removeValue($options, 'url', ''); $options['href'] = \CHtml::normalizeUrl($url); $links[$label] = $options; } } else { $links[$options] = array('href' => '#'); } } $this->items = $links; } }
/** * Generates a button. * @param string $tag the HTML tag. * @param string $label the button label text. * @param array $htmlOptions additional HTML attributes. * @return string the generated button. */ public static function btn($tag, $label, $htmlOptions = array()) { ArrayHelper::addValue('class', 'button', $htmlOptions); $icon = ArrayHelper::removeValue($htmlOptions, 'icon'); if (isset($icon)) { $label = Icon::icon($icon) . ' ' . $label; } return \CHtml::tag($tag, $htmlOptions, $label); }