/**
  * Render progress bar
  */
 public function run()
 {
     parent::run();
     echo EBootstrap::openTag('div', $this->htmlOptions);
     echo EBootstrap::openTag('div', array('class' => 'bar', 'style' => 'width: ' . $this->width . '%;'));
     echo EBootstrap::closeTag('div');
     echo EBootstrap::closeTag('div');
 }
 /**
  * Recursively renders the menu items.
  *
  * @param array $items the menu items to be rendered recursively
  * @param bool $header Helper variable to identify the header elements
  */
 protected function renderMenuRecursive($items, $header = true)
 {
     $count = 0;
     $n = count($items);
     foreach ($items as $item) {
         if (isset($item['access']) and !empty($item['access'])) {
             $prove = true;
         } else {
             $prove = false;
         }
         if ($prove and Yii::app()->user->checkAccess($item['access']) or !$prove) {
             $count++;
             $options = isset($item['itemOptions']) ? $item['itemOptions'] : array();
             $class = array();
             if ($item['active'] && $this->activeCssClass != '') {
                 $class[] = $this->activeCssClass;
             }
             if ($count === 1 && $this->firstItemCssClass !== null) {
                 $class[] = $this->firstItemCssClass;
             }
             if ($count === $n && $this->lastItemCssClass !== null) {
                 $class[] = $this->lastItemCssClass;
             }
             if ($this->itemCssClass !== null) {
                 $class[] = $this->itemCssClass;
             }
             if ($header and isset($item['items']) or isset($item['header']) and $item['header'] == true) {
                 $class[] = 'nav-header';
             }
             if ($class !== array()) {
                 if (empty($options['class'])) {
                     $options['class'] = implode(' ', $class);
                 } else {
                     $options['class'] .= ' ' . implode(' ', $class);
                 }
             }
             echo EBootstrap::openTag('li', $options);
             $menu = $this->renderMenuItem($item);
             if (isset($this->itemTemplate) || isset($item['template'])) {
                 $template = isset($item['template']) ? $item['template'] : $this->itemTemplate;
                 echo strtr($template, array('{menu}' => $menu));
             } else {
                 echo $menu;
             }
             echo EBootstrap::closeTag('li');
             if (isset($item['items']) && count($item['items'])) {
                 $this->renderMenuRecursive($item['items'], false);
             }
             echo "\n";
         }
     }
 }
 /**
  * Init the widget
  *
  * Render header
  */
 public function init()
 {
     parent::init();
     EBootstrap::mergeClass($this->htmlOptions, array('tab-pane'));
     if ($this->active) {
         EBootstrap::mergeClass($this->htmlOptions, array('active'));
     }
     if (is_null($this->id)) {
         $this->id = $this->getId();
     }
     $this->htmlOptions['id'] = $this->id;
     echo EBootstrap::openTag('div', $this->htmlOptions);
 }
 /**
  * Render the hero element
  */
 public function run()
 {
     parent::run();
     echo EBootstrap::openTag('div', $this->htmlOptions) . "\n";
     echo EBootstrap::tag('h1', array(), $this->headline) . "\n";
     echo EBootstrap::tag('div', array(), $this->body) . "\n";
     if (!empty($this->actions)) {
         echo EBootstrap::openTag('p');
         foreach ($this->actions as $button) {
             echo $button . " \n";
         }
         echo "\n";
         echo EBootstrap::closeTag('p') . "\n";
     }
     echo EBootstrap::closeTag('div') . "\n";
 }
 /**
  * Init widget
  */
 public function init()
 {
     parent::init();
     if (!empty($this->position)) {
         switch ($this->position) {
             case 'bottom':
                 echo EBootstrap::openTag('div', array('class' => 'tabbable tabs-below'));
                 break;
             case 'left':
                 echo EBootstrap::openTag('div', array('class' => 'tabbable tabs-left'));
                 break;
             case 'right':
                 echo EBootstrap::openTag('div', array('class' => 'tabbable tabs-right'));
                 break;
         }
     }
 }
 /**
  * Render the flash messages
  */
 public function run()
 {
     parent::run();
     $flashMessages = Yii::app()->user->getFlashes();
     if (is_array($flashMessages) and count($flashMessages)) {
         echo EBootstrap::openTag('div', $this->htmlOptions);
         foreach ($flashMessages as $key => $message) {
             if (substr($key, 0, 5) == 'block') {
                 $block = true;
                 $key = substr($key, 6);
             } else {
                 $block = false;
             }
             $this->widget('EBootstrapAlert', array('type' => $key, 'message' => $message, 'block' => $block));
         }
         echo EBootstrap::closeTag('div');
     }
 }
 /**
  * Render alert
  */
 public function run()
 {
     parent::run();
     if ($this->type == 'error') {
         $this->type = 'danger';
     }
     EBootstrap::mergeClass($this->htmlOptions, array('alert', 'alert-dismissable', 'fade', 'in'));
     EBootstrap::mergeClass($this->htmlOptions, array('alert-' . $this->type));
     echo EBootstrap::openTag('div', $this->htmlOptions);
     if ($this->canClose) {
         echo EBootstrap::tag('button', array('type' => 'button', 'class' => 'close', 'data-dismiss' => 'alert', 'aria-hidden' => 'true'), "×");
     }
     if ($this->block) {
         echo $this->message;
     } else {
         echo EBootstrap::tag('span', array(), $this->message);
     }
     echo EBootstrap::closeTag('div');
 }
 /**
  * Render the breadcrumbs
  */
 public function run()
 {
     if (empty($this->links)) {
         return;
     }
     echo EBootstrap::openTag('ul', $this->htmlOptions) . "\n";
     $links = array();
     if ($this->homeLink === null) {
         $links[] = EBootstrap::openTag('li') . EBootstrap::link(Yii::t('zii', 'Home'), Yii::app()->homeUrl);
     } else {
         if ($this->homeLink !== false) {
             $links[] = EBootstrap::openTag('li') . $this->homeLink;
         }
     }
     $count = count($this->links);
     if ($count > 0) {
         $links[] = $this->separator . EBootstrap::closeTag('li') . "\n";
         $i = 0;
         foreach ($this->links as $label => $url) {
             $i++;
             if (is_string($label) || is_array($url)) {
                 $links[] = EBootstrap::openTag('li') . EBootstrap::link($this->encodeLabel ? EBootstrap::encode($label) : $label, $url);
             } else {
                 $links[] = EBootstrap::openTag('li') . '<span>' . ($this->encodeLabel ? EBootstrap::encode($url) : $url) . '</span>';
             }
             if ($i < $count) {
                 $links[] = $this->separator;
             }
             $links[] = EBootstrap::closeTag('li') . "\n";
         }
     } else {
         $links[] = EBootstrap::closeTag('li') . "\n";
     }
     echo implode($links);
     echo EBootstrap::closeTag('ul');
 }
 /**
  * Render footer
  */
 public function run()
 {
     parent::run();
     echo EBootstrap::closeTag('div');
     echo EBootstrap::openTag('div', array('class' => 'modal-footer'));
     foreach ($this->footer as $action) {
         echo $action . " \n";
     }
     echo EBootstrap::closeTag('div');
     echo EBootstrap::closeTag('div');
 }
 /**
  * Returns a inline help.
  *
  * Help inline is displayed right next to the input field (where the error should be displayed).
  *
  * @param string $help Help message
  *
  * @since 0.4.4
  * @access public
  * @return string
  */
 public function helpInline($help)
 {
     $html = EBootstrap::openTag('span', array('class' => 'help-inline'));
     $html .= $help;
     $html .= EBootstrap::closeTag('span');
     return $html;
 }
 /**
  * Render header
  */
 public function init()
 {
     parent::init();
     EBootstrap::mergeClass($this->htmlOptions, array('tab-content'));
     echo EBootstrap::openTag('div', $this->htmlOptions);
 }
 /**
  * Render the carousel
  */
 public function run()
 {
     parent::run();
     if (is_array($this->items) and count($this->items)) {
         EBootstrap::mergeClass($this->htmlOptions, array('carousel'));
         echo EBootstrap::openTag('div', $this->htmlOptions) . "\n";
         echo EBootstrap::openTag('div', array('class' => 'carousel-inner')) . "\n";
         foreach ($this->items as $item) {
             $itemOptions = isset($item['htmlOptions']) ? $item['htmlOptions'] : array();
             EBootstrap::mergeClass($itemOptions, array('item'));
             if (isset($item['active']) and $item['active'] == true) {
                 EBootstrap::mergeClass($itemOptions, array('active'));
             }
             echo EBootstrap::openTag('div', $itemOptions) . "\n";
             if (!isset($item['alt'])) {
                 $item['alt'] = isset($item['caption']) ? $item['caption'] : '';
             }
             if (isset($item['href'])) {
                 echo EBootstrap::openTag('a', array('href' => $item['href']));
             }
             echo EBootstrap::image($item['src'], $item['alt'], array()) . "\n";
             if (isset($item['caption']) and !empty($item['caption']) or isset($item['body']) and !empty($item['body'])) {
                 echo EBootstrap::openTag('div', array('class' => 'carousel-caption'));
                 if (isset($item['caption']) and !empty($item['caption'])) {
                     echo EBootstrap::tag('h4', array(), $item['caption']) . "\n";
                 }
                 if (isset($item['body']) and !empty($item['body'])) {
                     echo EBootstrap::tag('p', array(), $item['body']) . "\n";
                 }
                 echo EBootstrap::closeTag('div');
             }
             if (isset($item['href'])) {
                 echo EBootstrap::closeTag('a');
             }
             echo EBootstrap::closeTag('div') . "\n";
         }
         echo EBootstrap::closeTag('div') . "\n";
         echo EBootstrap::link($this->controlPrev, '#' . $this->htmlOptions['id'], array('data-slide' => 'prev', 'class' => 'left carousel-control')) . "\n";
         echo EBootstrap::link($this->controlNext, '#' . $this->htmlOptions['id'], array('data-slide' => 'next', 'class' => 'right carousel-control')) . "\n";
         echo EBootstrap::closeTag('div') . "\n";
     }
 }
 /**
  * Render navigation menu items
  *
  * @param array $items
  * @param bool $sub If a submenu should be rendered
  */
 protected function renderMenuRecursive($items, $sub = false)
 {
     $count = 0;
     $first = true;
     $n = count($items);
     foreach ($items as $item) {
         $count++;
         $options = isset($item['itemOptions']) ? $item['itemOptions'] : array();
         $class = array();
         if ($item['active'] && $this->activeCssClass != '') {
             $class[] = $this->activeCssClass;
         }
         if ($count === 1 && $this->firstItemCssClass !== null) {
             $class[] = $this->firstItemCssClass;
         }
         if ($count === $n && $this->lastItemCssClass !== null) {
             $class[] = $this->lastItemCssClass;
         }
         if ($this->itemCssClass !== null) {
             $class[] = $this->itemCssClass;
         }
         if ($class !== array()) {
             if (empty($options['class'])) {
                 $options['class'] = implode(' ', $class);
             } else {
                 $options['class'] .= ' ' . implode(' ', $class);
             }
         }
         if (isset($this->itemTemplate) || isset($item['template'])) {
             $template = isset($item['template']) ? $item['template'] : $this->itemTemplate;
         } else {
             $template = '';
         }
         if (isset($item['items']) && count($item['items'])) {
             EBootstrap::mergeClass($options, array('dropdown'));
             $item['linkOptions'] = isset($item['linkOptions']) ? $item['linkOptions'] : array();
             EBootstrap::mergeClass($item['linkOptions'], array('dropdown-toggle'));
             $item['linkOptions']['data-toggle'] = 'dropdown';
             $item['label'] .= '<b class="caret"></b>';
         } else {
             if ($this->pills) {
                 $item['linkOptions']['data-toggle'] = 'pill';
             } else {
                 $item['linkOptions']['data-toggle'] = 'tab';
             }
         }
         echo EBootstrap::openTag('li', $options);
         $menu = $this->renderMenuItem($item);
         if (!empty($template)) {
             echo strtr($template, array('{menu}' => $menu));
         } else {
             echo $menu;
         }
         if (isset($item['items']) && count($item['items'])) {
             $options = isset($item['submenuOptions']) ? $item['submenuOptions'] : $this->submenuHtmlOptions;
             if (isset($options['class'])) {
                 $options['class'] = implode(' ', explode(' ', $options['class']) + array('dropdown-menu'));
             } else {
                 $options['class'] = 'dropdown-menu';
             }
             echo "\n" . EBootstrap::openTag('ul', $options) . "\n";
             $this->renderMenuRecursive($item['items'], true);
             echo EBootstrap::closeTag('ul') . "\n";
         }
         echo EBootstrap::closeTag('li') . "\n";
     }
 }
 /**
  * Render the menu items
  */
 protected function renderMenuRecursive($items, $sub = false)
 {
     $count = 0;
     $first = true;
     $n = count($items);
     foreach ($items as $item) {
         $count++;
         $options = isset($item['itemOptions']) ? $item['itemOptions'] : array();
         $class = array();
         if ($item['active'] && $this->activeCssClass != '') {
             $class[] = $this->activeCssClass;
         }
         if ($count === 1 && $this->firstItemCssClass !== null) {
             $class[] = $this->firstItemCssClass;
         }
         if ($count === $n && $this->lastItemCssClass !== null) {
             $class[] = $this->lastItemCssClass;
         }
         if ($this->itemCssClass !== null) {
             $class[] = $this->itemCssClass;
         }
         if ($class !== array()) {
             if (empty($options['class'])) {
                 $options['class'] = implode(' ', $class);
             } else {
                 $options['class'] .= ' ' . implode(' ', $class);
             }
         }
         if (isset($this->itemTemplate) || isset($item['template'])) {
             $template = isset($item['template']) ? $item['template'] : $this->itemTemplate;
         } else {
             $template = '';
         }
         switch ($template) {
             case '{brand}':
                 EBootstrap::mergeClass($options, array('brand'));
                 echo EBootstrap::link($item['label'], $item['url'], $options) . "\n";
                 break;
             case '{divider}':
                 echo EBootstrap::openTag('li', array('class' => 'divider-vertical'));
                 echo EBootstrap::closeTag('li') . "\n";
                 break;
             case '{search}':
                 //Input options
                 if (isset($options['input'])) {
                     $itemOptions = $options['input'];
                     unset($options['input']);
                 } else {
                     $itemOptions = array();
                 }
                 if (isset($itemOptions['name'])) {
                     $name = $itemOptions['name'];
                     unset($itemOptions['name']);
                 } else {
                     $name = 'search';
                 }
                 if (isset($itemOptions['value'])) {
                     $value = $itemOptions['value'];
                     unset($itemOptions['value']);
                 } else {
                     $value = '';
                 }
                 $itemHtmlOptions = isset($itemOptions['htmlOptions']) ? $itemOptions['htmlOptions'] : array();
                 EBootstrap::mergeClass($options, array('navbar-search'));
                 echo EBootstrap::openTag('form', $options) . "\n";
                 echo EBootstrap::searchField($name, $value, $itemHtmlOptions) . "\n";
                 echo EBootstrap::closeTag('form') . "\n";
                 break;
             default:
                 $listOptions = array('class' => 'nav navbar-nav');
                 if (isset($item['align']) and $item['align'] == 'right' and isset($item['items'])) {
                     //Allign navigation right
                     EBootstrap::mergeClass($listOptions, array('pull-right'));
                     if ($this->_ul > 0) {
                         $this->_ul--;
                         echo EBootstrap::closeTag('ul');
                     }
                     $this->_ul++;
                     echo EBootstrap::openTag('ul', $listOptions) . "\n";
                     $this->renderMenuRecursive($item['items'], true);
                     $this->_ul--;
                     echo EBootstrap::closeTag('ul');
                     continue;
                 } elseif ($first and !$sub) {
                     $this->_ul++;
                     echo EBootstrap::openTag('ul', $listOptions) . "\n";
                     $first = false;
                 }
                 //Create dropdown
                 if (isset($item['dropdown']) and $item['dropdown'] == true) {
                     if (isset($options['class'])) {
                         $options['class'] = implode(' ', explode(' ', $options['class'])) . ' dropdown';
                     } else {
                         $options['class'] = 'dropdown';
                     }
                     $item['linkOptions']['data-toggle'] = 'dropdown';
                     if (isset($item['linkOptions']['class'])) {
                         $item['linkOptions']['class'] = implode(' ', explode(' ', $item['linkOptions']['class']) + array('dropdown-toggle'));
                     } else {
                         $item['linkOptions']['class'] = 'dropdown-toggle';
                     }
                     $item['label'] .= '<b class="caret"></b>';
                 }
                 echo EBootstrap::openTag('li', $options);
                 if (isset($item['label'])) {
                     $menu = $this->renderMenuItem($item);
                     if (!empty($template)) {
                         echo strtr($template, array('{menu}' => $menu));
                     } else {
                         echo $menu;
                     }
                 }
                 if (isset($item['items']) && count($item['items'])) {
                     $options = isset($item['submenuOptions']) ? $item['submenuOptions'] : $this->submenuHtmlOptions;
                     if (isset($item['dropdown']) and $item['dropdown'] == true) {
                         EBootstrap::mergeClass($options, array('dropdown-menu'));
                     } else {
                         EBootstrap::mergeClass($options, array('nav'));
                     }
                     $this->_ul++;
                     echo "\n" . EBootstrap::openTag('ul', $options) . "\n";
                     $this->renderMenuRecursive($item['items'], true);
                     if (!isset($options['align'])) {
                         $this->_ul--;
                         echo EBootstrap::closeTag('ul') . "\n";
                     } elseif ($options['align'] == 'right') {
                         echo EBootstrap::closeTag('div') . "\n";
                     }
                 }
                 echo EBootstrap::closeTag('li') . "\n";
         }
     }
     if (!$sub and $this->_ul > 0) {
         $this->_ul--;
         echo EBootstrap::closeTag('ul') . "\n";
     }
 }
 /**
  * Returns an image link
  *
  * @param string $url Url
  * @param string $src Image src
  * @param string $alt Alternative text
  * @param array $htmlOptions
  *
  * @method static
  * @access public
  * @return string
  */
 public static function thumbnailLink($url, $src, $alt = '', $htmlOptions = array())
 {
     $html = '';
     $htmlOptions['href'] = $url;
     self::mergeClass($htmlOptions, array('thumbnail'));
     $html .= EBootstrap::openTag('a', $htmlOptions);
     $html .= EBootstrap::tag('img', array('src' => $src, 'alt' => $alt));
     $html .= EBootstrap::closeTag('a');
     return $html;
 }