/** * Runs the widget. */ public function run() { $brand = $this->brandLabel !== false ? BsHtml::navbarBrandLink($this->brandLabel, $this->brandUrl, $this->brandOptions) : ''; ob_start(); foreach ($this->items as $item) { if (is_string($item)) { echo $item; } else { $widgetClassName = BsArray::popValue('class', $item); if ($widgetClassName !== null) { $this->controller->widget($widgetClassName, $item); } } } $items = ob_get_clean(); ob_start(); if ($this->collapse !== false) { BsHtml::addCssClass('collapse navbar-collapse', $this->collapseOptions); ob_start(); /* @var BsCollapse $collapseWidget */ $collapseWidget = $this->controller->widget('bootstrap.widgets.BsCollapse', array('toggle' => false, 'content' => $items, 'htmlOptions' => $this->collapseOptions)); $collapseContent = ob_get_clean(); $collapseLink = BsHtml::navbarCollapseLink('#' . $collapseWidget->getId()); echo BsHtml::tag('div', array('class' => 'navbar-header'), $collapseLink . $brand) . $collapseContent; } else { echo BsHtml::tag('div', array('class' => 'navbar-header'), $brand) . $items; } $containerContent = ob_get_clean(); if (isset($this->position) && ($this->position === BsHtml::NAVBAR_POSITION_FIXED_TOP || $this->position === BsHtml::NAVBAR_POSITION_STATIC_TOP)) { $fluid = BsArray::popValue('containerOptions', $this->htmlOptions, false); $containerOptions = BsArray::popValue('containerOptions', $this->htmlOptions, array()); $containerClass = 'container'; if ($fluid) { $containerOptions = BsArray::removeValue('fluid', $this->htmlOptions, array()); $containerClass = 'container-fluid'; } BsHtml::addCssClass($containerClass, $containerOptions); $content = BsHtml::tag('div', $containerOptions, $containerContent); echo BsHtml::navbar($content, $this->htmlOptions); return; } echo BsHtml::navbar($containerContent, $this->htmlOptions); }