/**
  * Render footer
  */
 public function run()
 {
     parent::run();
     if (!empty($this->position)) {
         echo EBootstrap::closeTag('div');
     }
 }
 /**
  * Init the widget
  */
 public function init()
 {
     parent::init();
     $classes = array('table');
     if ($this->bordered) {
         $classes[] = 'table-bordered';
     }
     if ($this->striped) {
         $classes[] = 'table-striped';
     }
     if ($this->condensed) {
         $classes[] = 'table-condensed';
     }
     EBootstrap::mergeClassString($this->itemsCssClass, $classes);
     EBootstrap::mergeClass($this->htmlOptions, array('bootstrap-grid-view'));
     switch ($this->pagerAlign) {
         case 'centered':
             EBootstrap::mergeClassString($this->pagerCssClass, array('pagination-centered'));
             break;
         case 'right':
             EBootstrap::mergeClassString($this->pagerCssClass, array('pagination-right'));
             break;
     }
     if ($this->cssFile === false) {
         $cssFile = dirname(__FILE__) . '/css/bootstrap.css';
         $this->cssFile = Yii::app()->getAssetManager()->publish($cssFile);
         Yii::app()->clientScript->registerCssFile($this->cssFile);
     }
 }
 /**
  * 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');
 }
 /**
  * Render trigger
  */
 public function run()
 {
     parent::run();
     if ($this->html === false) {
         echo EBootstrap::tag($this->element, $this->htmlOptions, $this->value);
     } else {
         echo $this->html;
     }
 }
 /**
  * Create a pager button.
  *
  * @param string $label
  * @param string $page
  * @param string $class
  * @param boolean $hidden
  * @param boolean $selected
  *
  * @access protected
  * @return string
  */
 protected function createPageButton($label, $page, $class, $hidden, $selected)
 {
     if ($hidden || $selected) {
         $class .= ' ' . ($hidden ? self::CSS_HIDDEN_PAGE : self::CSS_SELECTED_PAGE);
     }
     if (!$hidden) {
         return '<li class="' . $class . '">' . EBootstrap::link($label, $this->createPageUrl($page)) . '</li>';
     } else {
         return '<li class="' . $class . '">' . EBootstrap::link($label, '') . '</li>';
     }
 }
 /**
  * Init the widget
  */
 public function init()
 {
     parent::init();
     $classes = array('table');
     if ($this->bordered) {
         $classes[] = 'table-bordered';
     }
     if ($this->striped) {
         $classes[] = 'table-striped';
     }
     if ($this->condensed) {
         $classes[] = 'table-condensed';
     }
     EBootstrap::mergeClass($this->htmlOptions, $classes);
 }
 /**
  * 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 the widget
  */
 public function init()
 {
     parent::init();
     if ($this->collapse) {
         EBootstrap::mergeClass($this->htmlOptions, array('collapse'));
         if ($this->collapseShow) {
             EBootstrap::mergeClass($this->htmlOptions, array('in'));
         }
         if (is_null($this->collapseJsFile)) {
             $collapseJsFile = dirname(__FILE__) . '/js/bootstrap.min.js';
             $this->collapseJsFile = Yii::app()->getAssetManager()->publish($collapseJsFile);
             Yii::app()->clientScript->registerScriptFile($this->collapseJsFile);
         } elseif ($this->collapseJsFile !== false) {
             Yii::app()->clientScript->registerScriptFile($this->collapseJsFile);
         }
     }
 }
 /**
  * Init the widget
  */
 public function init()
 {
     parent::init();
     EBootstrap::mergeClass($this->htmlOptions, array('bootstrap-list-view'));
     switch ($this->pagerAlign) {
         case 'centered':
             EBootstrap::mergeClassString($this->pagerCssClass, array('pagination-centered'));
             break;
         case 'right':
             EBootstrap::mergeClassString($this->pagerCssClass, array('pagination-right'));
             break;
     }
     if ($this->cssFile === false) {
         $cssFile = dirname(__FILE__) . '/css/bootstrap.css';
         $this->cssFile = Yii::app()->getAssetManager()->publish($cssFile);
         Yii::app()->clientScript->registerCssFile($this->cssFile);
     }
 }
 /**
  * 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'), "&times;");
     }
     if ($this->block) {
         echo $this->message;
     } else {
         echo EBootstrap::tag('span', array(), $this->message);
     }
     echo EBootstrap::closeTag('div');
 }
 /**
  * Render the widget
  */
 public function run()
 {
     parent::run();
     if (empty($this->content)) {
         $content = ob_get_contents();
         $content = str_replace('&gt;', '>', $content);
         $content = str_replace('&lt;', '<', $content);
         ob_end_clean();
     } else {
         $content = $this->content;
     }
     EBootstrap::mergeClass($this->htmlOptions, array('prettyprint', 'well'));
     if (!empty($this->language)) {
         EBootstrap::mergeClass($this->htmlOptions, array('lang-' . $this->language));
     }
     if ($this->lineNumbers) {
         EBootstrap::mergeClass($this->htmlOptions, array('linenums'));
     }
     echo CHtml::openTag('pre', $this->htmlOptions);
     echo htmlspecialchars($content);
     echo CHtml::closeTag('pre');
 }
 /**
  * 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 a submit buttom.
  *
  * @param string $label Label
  * @param array $htmlOptions
  *
  * @access public
  * @return EBootstrapButton
  */
 public function submitButton($label, $htmlOptions = array())
 {
     EBootstrap::mergeClass($htmlOptions, array('btn', 'btn-primary'));
     return EBootstrap::submitButton($label, null, null, null, null, null, $htmlOptions);
 }
 /**
  * Execute the widget
  */
 public function run()
 {
     $this->htmlOptions['data-toggle'] = 'collapse';
     $this->htmlOptions['data-target'] = $this->target;
     if ($this->parent !== false) {
         $this->htmlOptions['data-parent'] = $this->parent;
     }
     echo EBootstrap::tag($this->sender, $this->htmlOptions, $this->value);
 }
 /**
  * Error summary
  *
  * Apply bootstrap style to the error summary
  *
  * @param CModel $model
  * @param string $header
  * @param string $footer
  * @param array $htmlOptions
  *
  * @method static
  * @access public
  * @return string
  */
 public static function errorSummary($model, $header = null, $footer = null, $htmlOptions = array())
 {
     $content = '';
     if (!is_array($model)) {
         $model = array($model);
     }
     if (isset($htmlOptions['firstError'])) {
         $firstError = $htmlOptions['firstError'];
         unset($htmlOptions['firstError']);
     } else {
         $firstError = false;
     }
     foreach ($model as $m) {
         foreach ($m->getErrors() as $errors) {
             foreach ($errors as $error) {
                 if ($error != '') {
                     $content .= "<li>{$error}</li>\n";
                 }
                 if ($firstError) {
                     break;
                 }
             }
         }
     }
     if ($content !== '') {
         if ($header === null) {
             $header = Yii::t('yii', 'Please fix the following input errors:');
         }
         $header = EBootstrap::tag('h4', array('class' => 'alert-heading'), $header) . "\n";
         if (!isset($htmlOptions['class'])) {
             $htmlOptions['class'] = EBootstrap::$errorSummaryCss;
         }
         EBootstrap::mergeClass($htmlOptions, array('alert', 'alert-error', 'alert-block'));
         return EBootstrap::tag('div', $htmlOptions, $header . "\n<ul>\n{$content}</ul>" . $footer);
     } else {
         return '';
     }
 }
 /**
  * Renders the content of a menu item.
  *
  * You can pass an 'icon' as item option as well as a bolean 'iconWhite'
  */
 protected function renderMenuItem($item)
 {
     if (isset($item['icon']) and !empty($item['icon'])) {
         $icon = '<span class="glyphicon glyphicon-' . $item['icon'];
         if (isset($item['iconWhite']) and $item['iconWhite'] == true) {
             $icon .= ' icon-white';
         }
         $icon .= '"></span> ';
     } else {
         $icon = '';
     }
     if (isset($item['url'])) {
         $label = $this->linkLabelWrapper === null ? $icon . $item['label'] : '<' . $this->linkLabelWrapper . '>' . $icon . $item['label'] . '</' . $this->linkLabelWrapper . '>';
         return EBootstrap::link($label, $item['url'], isset($item['linkOptions']) ? $item['linkOptions'] : array());
     } else {
         return EBootstrap::tag('span', isset($item['linkOptions']) ? $item['linkOptions'] : array(), $icon . $item['label']);
     }
 }
 /**
  * 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";
     }
 }
 /**
  * Init the widget
  */
 public function init()
 {
     parent::init();
     EBootstrap::mergeClass($this->htmlOptions, array('bootstrap-list-view-item'));
 }
 /**
  * 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');
 }
 /**
  * Render footer
  */
 public function run()
 {
     parent::run();
     echo EBootstrap::closeTag('div');
 }
 /**
  * Outputs the button
  */
 public function __tostring()
 {
     $class = array();
     if (!empty($this->size)) {
         $class[] = 'btn-' . $this->size;
     }
     if (!empty($this->type)) {
         $class[] = 'btn-' . $this->type;
     } else {
         $class[] = 'btn-default';
     }
     if ($this->disabled) {
         $class[] = 'disabled';
     }
     if ($this->block) {
         $class[] = 'btn-block';
     }
     if (!empty($this->icon)) {
         $this->text = EBootstrap::icon($this->icon, $this->iconWhite) . ' ' . $this->text;
     }
     EBootstrap::mergeClass($this->htmlOptions, $class);
     switch ($this->element) {
         case 'button':
             return EBootstrap::tag('button', $this->htmlOptions, $this->text) . "\n";
             break;
         default:
             return EBootstrap::link($this->text, $this->url, $this->htmlOptions) . "\n";
             break;
     }
 }
 /**
  * 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";
     }
 }