/**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     $classes = array('nav');
     $validTypes = array(self::TYPE_TABS, self::TYPE_PILLS, self::TYPE_LIST);
     if (isset($this->type) && in_array($this->type, $validTypes)) {
         $classes[] = 'nav-' . $this->type;
     }
     if ($this->stacked && $this->type !== self::TYPE_LIST) {
         $classes[] = 'nav-stacked';
     }
     if ($this->dropup === true) {
         $classes[] = 'dropup';
     }
     if (isset($this->scrollspy)) {
         $scrollspy = is_string($this->scrollspy) ? array('target' => $this->scrollspy) : $this->scrollspy;
         $this->widget('bootstrap.widgets.BootScrollSpy', $scrollspy);
     }
     if (!empty($classes)) {
         $classes = implode(' ', $classes);
         if (isset($this->htmlOptions['class'])) {
             $this->htmlOptions['class'] .= ' ' . $classes;
         } else {
             $this->htmlOptions['class'] = $classes;
         }
     }
 }
 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     if (isset($this->htmlOptions['class'])) {
         $this->htmlOptions['class'] .= ' dropdown-menu';
     } else {
         $this->htmlOptions['class'] = 'dropdown-menu';
     }
 }
예제 #3
0
 /**
  * Renders a single item in the menu.
  * @param array $item the item configuration
  * @return string the rendered item
  */
 protected function renderItem($item)
 {
     if (!isset($item['linkOptions'])) {
         $item['linkOptions'] = array();
     }
     if (isset($item['items']) && !empty($item['items'])) {
         if (isset($item['linkOptions']['class'])) {
             $item['linkOptions']['class'] .= ' dropdown-toggle';
         } else {
             $item['linkOptions']['class'] = 'dropdown-toggle';
         }
         $item['linkOptions']['data-toggle'] = 'dropdown';
         $item['label'] .= ' <span class="caret"></span>';
     }
     return parent::renderItem($item);
 }