/**
* Runs the widget.
*/
public function run()
{
$brand = $this->brandLabel !== false ? TbHtml::navbarBrandLink($this->brandLabel, $this->brandUrl, $this->brandOptions) : '';
ob_start();
foreach ($this->items as $item) {
if (is_string($item)) {
echo $item;
} else {
$widgetClassName = TbArray::popValue('class', $item);
if ($widgetClassName !== null) {
$this->controller->widget($widgetClassName, $item);
}
}
}
$items = ob_get_clean();
ob_start();
if ($this->collapse !== false) {
TbHtml::addCssClass('navbar-collapse', $this->collapseOptions);
ob_start();
/* @var TbCollapse $collapseWidget */
$collapseWidget = $this->controller->widget('\\TbCollapse', array('toggle' => false, 'content' => $items, 'htmlOptions' => $this->collapseOptions));
$collapseContent = ob_get_clean();
echo TbHtml::tag('div', array('class' => 'navbar-header'), TbHtml::navbarCollapseLink('#' . $collapseWidget->getId()) . $brand);
echo $collapseContent;
} else {
echo TbHtml::tag('div', array('class' => 'navbar-header'), $brand);
echo $items;
}
$containerContent = ob_get_clean();
$containerOptions = TbArray::popValue('containerOptions', $this->htmlOptions, array());
TbHtml::addCssClass('navbar-container', $containerOptions);
// Change css [container] to [navbar-container]
ob_start();
echo TbHtml::openTag('div', $containerOptions);
echo $containerContent;
echo '</div>';
$content = ob_get_clean();
echo TbHtml::navbar($content, $this->htmlOptions);
}