/** * 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); } }
/** * Init the widget */ public function init() { parent::init(); EBootstrap::mergeClass($this->htmlOptions, array('progress', 'progress-' . $this->type)); if ($this->striped) { EBootstrap::mergeClass($this->htmlOptions, array('progress-striped')); } if ($this->active) { EBootstrap::mergeClass($this->htmlOptions, array('active')); } }
/** * 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); }
/** * 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); }
/** * 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 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 widget */ public function run() { parent::run(); if (empty($this->content)) { $content = ob_get_contents(); $content = str_replace('>', '>', $content); $content = str_replace('<', '<', $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'); }
/** * 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')); }
/** * 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; } }
/** * 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 ''; } }
/** * Init the widget */ public function init() { echo EBootstrap::openTag('div', array('class' => 'well sidebar-nav')); EBootstrap::mergeClass($this->htmlOptions, array('nav', 'nav-pills', 'nav-stacked')); parent::init(); }
/** * 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); }
/** * 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"; } }
/** * Render header */ public function init() { parent::init(); EBootstrap::mergeClass($this->htmlOptions, array('tab-content')); echo EBootstrap::openTag('div', $this->htmlOptions); }
/** * Init the widget */ public function init() { parent::init(); EBootstrap::mergeClass($this->htmlOptions, array('hero-unit')); }
/** * Init the widget */ public function init() { parent::init(); EBootstrap::mergeClass($this->htmlOptions, array('bootstrap-list-view-item')); }
/** * 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 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('breadcrumb')); }