Exemplo n.º 1
0
 public function init()
 {
     if ($this->canClose) {
         BHtml::registerBootstrapJs();
     }
     $class = array();
     $class[] = 'alert';
     if ($this->isBlock) {
         $class[] = 'alert-block';
     }
     if (in_array($this->type, array('warning', 'error', 'success', 'danger', 'info'))) {
         $class[] = 'alert-' . $this->type;
     } else {
         $class[] = 'info';
     }
     if ($this->canClose && $this->fadeWhenClose) {
         $class[] = 'fade in';
     }
     $htmlOptions = $this->htmlOptions;
     if (!isset($htmlOptions['class'])) {
         $htmlOptions['class'] = implode(' ', $class);
     } else {
         $htmlOptions['class'] = implode(' ', array_merge(explode(' ', $htmlOptions['class']), $class));
     }
     $htmlOptions['data-alert'] = 'alert';
     $html = '';
     Yii::trace(CVarDumper::dumpAsString($this->canClose));
     if ($this->canClose) {
         $html .= CHtml::link('×', '#', array('class' => 'close', 'data-dismiss' => 'alert'));
     }
     echo CHtml::openTag('div', $htmlOptions) . $html;
 }
Exemplo n.º 2
0
 public function run()
 {
     $nav = $content = '';
     $first = true;
     $type = rtrim($this->type, 's');
     foreach ($this->items as $id => $item) {
         if (is_array($item['content'])) {
             $id = "{$this->id}-{$id}";
             $opts = $first ? array('class' => 'active') : array();
             $opts['class'] = isset($opts['class']) ? $opts['class'] . ' dropdown' : 'dropdown';
             $dropdown = array();
             foreach ($item['content'] as $subId => $subTab) {
                 Yii::trace(CVarDumper::dumpAsString($subTab));
                 $subOpts = array();
                 $subOpts['id'] = "{$id}-{$subId}";
                 $subOpts['class'] = 'tab-pane';
                 $content .= CHtml::tag('div', $subOpts, $subTab['content']);
                 $dropdown[$subTab['title']] = '#' . $subOpts['id'];
             }
             Yii::trace(CVarDumper::dumpAsString($dropdown));
             $nav .= CHtml::tag('li', $opts, BHtml::dropdownToggle($item['title']) . BHtml::dropdownMenu($dropdown, array('linkOptions' => array('data-toggle' => 'tab'))));
         } else {
             $id = "{$this->id}-{$id}";
             $opts = $first ? array('class' => 'active') : array();
             $nav .= CHtml::tag('li', $opts, CHtml::link($item['title'], "#{$id}", array('data-toggle' => $type)));
             $opts['id'] = $id;
             $opts['class'] = isset($opts['class']) ? $opts['class'] . ' tab-pane' : 'tab-pane';
             $content .= CHtml::tag('div', $opts, $item['content']);
         }
         $first = false;
     }
     echo CHtml::tag('div', $this->htmlOptions, CHtml::tag('ul', $this->navOptions, $nav) . CHtml::tag('div', array('class' => 'tab-content'), $content));
     BHtml::registerBootstrapJs();
 }
Exemplo n.º 3
0
 public function run()
 {
     echo BHtml::closeTag('div');
     // body
     if (!empty($this->actions)) {
         $actions = array();
         foreach ($this->actions as $action) {
             $tagType = 'link';
             if (!is_array($action)) {
                 $action = array('text' => $action);
             }
             if (!isset($action['text'])) {
                 $action['text'] = 'Action';
             }
             if (!isset($action['url'])) {
                 $tagType = 'button';
             }
             if (!isset($action['htmlOptions'])) {
                 $action['htmlOptions'] = array('class' => 'btn small');
             } else {
                 $action['htmlOptions']['class'] = (isset($action['htmlOptions']['class']) ? $action['htmlOptions']['class'] . ' ' : '') . 'btn small';
             }
             if (isset($action['primary']) && $action['primary']) {
                 $action['htmlOptions']['class'] .= ' primary';
             }
             if (isset($action['onclick'])) {
                 $action['htmlOptions']['onclick'] = (isset($action['htmlOptions']['onclick']) ? $action['htmlOptions']['onclick'] : '') . $action['onclick'];
             }
             if (isset($action['close']) && $action['close']) {
                 $action['htmlOptions']['onclick'] = (isset($action['onclick']) ? $action['onclick'] : '') . ';$("#' . $this->id . '").modal("hide");';
             }
             $actions[] = $tagType == 'link' ? CHtml::link($action['text'], $action['url'], $action['htmlOptions']) : BHtml::button($action['text'], $action['htmlOptions']);
         }
         echo BHtml::tag('div', array('class' => 'modal-footer'), implode("\n", $actions));
     }
     echo BHtml::closeTag('div');
     // container
     BHtml::registerBootstrapJs();
 }