/**
  * Render trigger
  */
 public function run()
 {
     parent::run();
     if ($this->html === false) {
         echo EBootstrap::tag($this->element, $this->htmlOptions, $this->value);
     } else {
         echo $this->html;
     }
 }
 /**
  * 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";
 }
 /**
  * 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');
 }
    /**
     * Init the widget and render header
     */
    public function init()
    {
        parent::init();
        if (!isset($this->htmlOptions['id'])) {
            $this->htmlOptions['id'] = $this->getId();
        }
        EBootstrap::mergeClass($this->htmlOptions, array('modal'));
        if (!$this->show) {
            EBootstrap::mergeClass($this->htmlOptions, array('hide'));
        }
        if ($this->fade) {
            EBootstrap::mergeClass($this->htmlOptions, array('fade'));
        }
        Yii::app()->clientScript->registerCoreScript('jquery');
        if (is_null($this->jsFile)) {
            $jsFile = dirname(__FILE__) . '/js/bootstrap.min.js';
            $this->jsFile = Yii::app()->getAssetManager()->publish($jsFile);
            Yii::app()->clientScript->registerScriptFile($this->jsFile);
        } elseif ($this->jsFile !== false) {
            Yii::app()->clientScript->registerScriptFile($this->jsFile);
        }
        $backdrop = $this->backdrop ? 'true' : 'false';
        $keyboard = $this->keyboard ? 'true' : 'false';
        $show = $this->show ? 'true' : 'false';
        Yii::app()->clientScript->registerScript('ebootstrap-model-' . $this->htmlOptions['id'], '
		$("#' . $this->htmlOptions['id'] . '").modal({
			backdrop: ' . $backdrop . ',
			keyboard: ' . $keyboard . ',
			show: ' . $show . ',
		});
		', CClientScript::POS_READY);
        echo EBootstrap::openTag('div', $this->htmlOptions);
        echo EBootstrap::openTag('div', array('class' => 'modal-header'));
        echo EBootstrap::tag('a', array('class' => 'close', 'data-dismiss' => 'modal', 'href' => '#'), $this->close);
        echo EBootstrap::tag('h3', array(), $this->header);
        echo EBootstrap::closeTag('div');
        echo EBootstrap::openTag('div', array('class' => 'modal-body'));
    }
 /**
  * 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);
 }
 /**
  * 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";
     }
 }
 /**
  * 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']);
     }
 }
 /**
  * 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 '';
     }
 }
 /**
  * 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;
     }
 }