/**
  * 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);
 }
Esempio n. 2
0
 /**
  * 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 = TbHtml::popOption('class', $item);
             if ($widgetClassName !== null) {
                 $this->controller->widget($widgetClassName, $item);
             }
         }
     }
     $items = ob_get_clean();
     ob_start();
     if ($this->collapse !== false) {
         $this->collapseOptions = TbHtml::addClassName('nav-collapse', $this->collapseOptions);
         // todo: fix collapse, currently it cannot be clicked when within a navbar
         ob_start();
         /* @var TbCollapse $collapseWidget */
         $collapseWidget = $this->controller->widget('bootstrap.widgets.TbCollapse', array('toggle' => false, 'content' => $items, 'htmlOptions' => $this->collapseOptions));
         $collapseContent = ob_get_clean();
         echo TbHtml::collapseIcon('#' . $collapseWidget->getId());
         echo $brand . $collapseContent;
     } else {
         echo $brand . $items;
     }
     $containerContent = ob_get_clean();
     $containerOptions = TbHtml::popOption('containerOptions', $this->htmlOptions, array());
     $containerOptions = TbHtml::addClassName($this->fluid ? 'container-fluid' : 'container', $containerOptions);
     ob_start();
     echo TbHtml::openTag('div', $containerOptions);
     echo $containerContent;
     echo '</div>';
     $content = ob_get_clean();
     echo TbHtml::navbar($content, $this->htmlOptions);
 }
Esempio n. 3
0
 public function testNavbarBrandLink()
 {
     $I = $this->codeGuy;
     $html = TbHtml::navbarBrandLink('Brand text', '#', array('class' => 'link'));
     $a = $I->createNode($html, 'a.brand');
     $I->seeNodeCssClass($a, 'link');
     $I->seeNodeAttribute($a, 'href', '#');
     $I->seeNodeText($a, 'Brand text');
 }
Esempio n. 4
0
 /**
  * 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 = TbHtml::popOption('class', $item);
             if ($widgetClassName !== null) {
                 $this->controller->widget($widgetClassName, $item);
             }
         }
     }
     $items = ob_get_clean();
     ob_start();
     echo CHtml::openTag('div', array('class' => $this->fluid ? 'container-fluid' : 'container'));
     if ($this->collapse !== false) {
         $collapseId = TbHtml::getNextId();
         $this->collapseOptions = TbHtml::addClassName('nav-collapse', $this->collapseOptions);
         echo TbHtml::collapseIcon('#' . $collapseId) . PHP_EOL;
         echo $brand . PHP_EOL;
         $this->controller->beginWidget('bootstrap.widgets.TbCollapse', array('id' => $collapseId, 'toggle' => false, 'htmlOptions' => $this->collapseOptions));
         echo $items;
         $this->controller->endWidget();
     } else {
         echo $brand . PHP_EOL;
         echo $items . PHP_EOL;
     }
     echo '</div>';
     $content = ob_get_clean();
     echo TbHtml::navbar($content, $this->htmlOptions);
 }
Esempio n. 5
0
 /**
  * Runs the widget.
  */
 public function run()
 {
     $brand = $this->brandLabel !== false ? TbHtml::navbarBrandLink($this->brandLabel, $this->brandUrl, $this->brandOptions) : '';
     ob_start();
     if (!Yii::app()->user->isGuest) {
         $menus = $this->Menudata();
     } else {
         $menus[0] = array();
     }
     $menus[1] = array('class' => 'bootstrap.widgets.TbNav', 'htmlOptions' => array('class' => 'pull-right'), 'items' => array(array('label' => '网站前台', 'url' => Yii::app()->request->hostInfo . Yii::app()->baseUrl), array('label' => '站点配置', 'url' => array('/settings/index'), 'visible' => !Yii::app()->user->isGuest), array('label' => '登录', 'url' => array('/site/login'), 'visible' => Yii::app()->user->isGuest), array('label' => Yii::app()->user->name, 'url' => '#', 'items' => array(array('label' => '个人资料', 'icon' => 'user', 'url' => '#'), array('label' => '退出', 'icon' => 'off', 'url' => array('/site/logout'))), 'visible' => !Yii::app()->user->isGuest)));
     $this->items = $menus;
     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('nav-collapse', $this->collapseOptions);
         ob_start();
         /* @var TbCollapse $collapseWidget */
         $collapseWidget = $this->controller->widget('bootstrap.widgets.TbCollapse', array('toggle' => false, 'content' => $items, 'htmlOptions' => $this->collapseOptions));
         $collapseContent = ob_get_clean();
         echo TbHtml::navbarCollapseLink('#' . $collapseWidget->getId());
         echo $brand . $collapseContent;
     } else {
         echo $brand . $items;
     }
     $containerContent = ob_get_clean();
     $containerOptions = TbArray::popValue('containerOptions', $this->htmlOptions, array());
     TbHtml::addCssClass($this->fluid ? 'container-fluid' : 'container', $containerOptions);
     ob_start();
     echo TbHtml::openTag('div', $containerOptions);
     echo $containerContent;
     echo '</div>';
     $content = ob_get_clean();
     echo TbHtml::navbar($content, $this->htmlOptions);
 }