10 Yii::import(
'booster.widgets.TbMenu');
91 if (!isset($this->htmlOptions[
'id'])) {
92 $this->htmlOptions[
'id'] = $this->getId();
97 $validPlacements = array(
98 self::PLACEMENT_ABOVE,
99 self::PLACEMENT_BELOW,
100 self::PLACEMENT_LEFT,
101 self::PLACEMENT_RIGHT
104 if (isset($this->placement) && in_array($this->placement, $validPlacements)) {
108 if (!empty($classes)) {
109 $classes = implode(
' ', $classes);
110 if (isset($this->htmlOptions[
'class'])) {
111 $this->htmlOptions[
'class'] .=
' ' . $classes;
113 $this->htmlOptions[
'class'] = $classes;
117 if (isset($this->tabContentHtmlOptions[
'class'])) {
118 $this->tabContentHtmlOptions[
'class'] .=
' tab-content';
120 $this->tabContentHtmlOptions[
'class'] =
'tab-content';
129 public function run() {
136 $this->controller->widget(
137 'booster.widgets.TbMenu',
139 'stacked' => $this->stacked,
140 'justified' => $this->justified,
141 'type' => $this->type,
142 'encodeLabel' => $this->encodeLabel,
143 'htmlOptions' => $this->tabMenuHtmlOptions,
147 $tabs = ob_get_clean();
150 echo CHtml::openTag(
'div', $this->tabContentHtmlOptions);
151 echo implode(
'', $content);
152 echo CHtml::closeTag(
'div');
153 $content = ob_get_clean();
155 echo CHtml::openTag(
'div', $this->htmlOptions);
156 echo $this->placement === self::PLACEMENT_BELOW ? $content .
$tabs :
$tabs . $content;
157 echo CHtml::closeTag(
'div');
160 $cs = Yii::app()->getClientScript();
161 $cs->registerScript(__CLASS__ .
'#' . $id,
"jQuery('#{$id}').tab('show');");
163 foreach ($this->events as $name => $handler) {
164 $handler = CJavaScript::encode($handler);
165 $cs->registerScript(__CLASS__ .
'#' . $id .
'_' . $name,
"jQuery('#{$id}').on('{$name}', {$handler});");
182 $id = $this->getId();
185 foreach (
$tabs as $tab) {
188 if (isset($item[
'visible']) && $item[
'visible'] ===
false) {
192 if (!isset($item[
'itemOptions'])) {
193 $item[
'itemOptions'] = array();
196 if (!isset($item[
'url'])) {
197 $item[
'linkOptions'][
'data-toggle'] =
'tab';
200 if (isset($tab[
'items'])) {
203 if (!isset($item[
'id'])) {
204 $item[
'id'] = $id .
'_tab_' . (
$i + 1);
207 if (!isset($item[
'url'])) {
208 $item[
'url'] =
'#' . $item[
'id'];
211 if (!isset($item[
'content'])) {
212 $item[
'content'] =
'';
215 $content = $item[
'content'];
216 unset($item[
'content']);
218 if (!isset($item[
'paneOptions'])) {
219 $item[
'paneOptions'] = array();
222 $paneOptions = $item[
'paneOptions'];
223 unset($item[
'paneOptions']);
225 $paneOptions[
'id'] = $item[
'id'];
227 $classes = array(
'tab-pane fade');
229 if (isset($item[
'active']) && $item[
'active']) {
230 $classes[] =
'active in';
233 $classes = implode(
' ', $classes);
234 if (isset($paneOptions[
'class'])) {
235 $paneOptions[
'class'] .=
' ' . $classes;
237 $paneOptions[
'class'] = $classes;
240 $panes[] = CHtml::tag(
'div', $paneOptions, $content);