示例#1
1
 /**
  * Renders a link button.
  * @param string $id the ID of the button
  * @param array $button the button configuration which may contain 'label', 'url', 'imageUrl' and 'options' elements.
  * @param integer $row the row number (zero-based)
  * @param mixed $data the data object associated with the row
  */
 protected function renderButton($id, $button, $row, $data)
 {
     if (isset($button['visible']) && !$this->evaluateExpression($button['visible'], array('row' => $row, 'data' => $data))) {
         return;
     }
     $url = \bootstrap\helpers\BSArray::popValue('url', $button, '#');
     if (strcmp($url, '#') !== 0) {
         $url = $this->evaluateExpression($url, array('data' => $data, 'row' => $row));
     }
     $imageUrl = \bootstrap\helpers\BSArray::popValue('imageUrl', $button, false);
     $label = \bootstrap\helpers\BSArray::popValue('label', $button, $id);
     $options = \bootstrap\helpers\BSArray::popValue('options', $button, array());
     \bootstrap\helpers\BSArray::defaultValue('data-title', $label, $options);
     \bootstrap\helpers\BSArray::defaultValue('title', $label, $options);
     \bootstrap\helpers\BSArray::defaultValue('data-toggle', 'tooltip', $options);
     if ($icon = \bootstrap\helpers\BSArray::popValue('icon', $button, false)) {
         echo CHtml::link(BSHtml::icon($icon), $url, $options);
     } else {
         if ($imageUrl && is_string($imageUrl)) {
             echo CHtml::link(CHtml::image($imageUrl, $label), $url, $options);
         } else {
             echo CHtml::link($label, $url, $options);
         }
     }
 }
示例#2
0
文件: BsNav.php 项目: bafio89/qea-u
 /**
  * Initializes the widget.
  */
 public function init()
 {
     $this->attachBehavior('BsWidget', new BsWidget());
     $this->copyId();
     $route = $this->controller->getRoute();
     if ($this->stacked) {
         BSHtml::addCssClass('nav-stacked', $this->htmlOptions);
     }
     $pull = \bootstrap\helpers\BSArray::popValue('pull', $this->htmlOptions);
     if (!empty($pull)) {
         if ($pull === BSHtml::PULL_RIGHT || $pull === BSHtml::PULL_LEFT) {
             BSHtml::addCssClass('pull-' . $pull, $this->htmlOptions);
         }
     }
     //        if (isset($this->scrollspy)) {
     //            if (is_string($this->scrollspy)) {
     //                $this->scrollspy = array('target' => $this->scrollspy);
     //            }
     //            $this->widget('bootstrap.widgets.TbScrollspy', $this->scrollspy);
     //        }
     $this->items = $this->normalizeItems($this->items, $route, $hasActiveChild);
 }
示例#3
0
 /**
  * Runs the widget.
  */
 public function run()
 {
     $brand = $this->brandLabel !== false ? BSHtml::navbarBrandLink($this->brandLabel, $this->brandUrl, $this->brandOptions) : '';
     ob_start();
     foreach ($this->items as $item) {
         if (is_string($item)) {
             echo $item;
         } else {
             $widgetClassName = \bootstrap\helpers\BSArray::popValue('class', $item);
             if ($widgetClassName !== null) {
                 $this->controller->widget($widgetClassName, $item);
             }
         }
     }
     $items = ob_get_clean();
     ob_start();
     if ($this->collapse !== false) {
         BSHtml::addCssClass('collapse navbar-collapse', $this->collapseOptions);
         ob_start();
         /* @var BsCollapse $collapseWidget */
         $collapseWidget = $this->controller->widget('bootstrap.widgets.BsCollapse', array('toggle' => false, 'content' => $items, 'htmlOptions' => $this->collapseOptions));
         $collapseContent = ob_get_clean();
         $collapseLink = BSHtml::navbarCollapseLink('#' . $collapseWidget->getId());
         echo BSHtml::tag('div', array('class' => 'navbar-header'), $collapseLink . $brand) . $collapseContent;
     } else {
         echo BSHtml::tag('div', array('class' => 'navbar-header'), $brand) . $items;
     }
     $containerContent = ob_get_clean();
     $containerOptions = \bootstrap\helpers\BSArray::popValue('containerOptions', $this->htmlOptions, array());
     BSHtml::addCssClass('container', $containerOptions);
     $content = BSHtml::tag('div', $containerOptions, $containerContent);
     echo BSHtml::navbar($content, $this->htmlOptions);
 }
示例#4
0
文件: BSHtml.php 项目: bafio89/qea-u
 /**
  * Generates a carousel item.
  * @param string $content the content.
  * @param string $label the item label text.
  * @param string $caption the item caption text.
  * @param array $htmlOptions additional HTML attributes.
  * @return string the generated item.
  */
 public static function carouselItem($content, $label, $caption, $htmlOptions = array())
 {
     self::addCssClass('item', $htmlOptions);
     $overlayOptions = \bootstrap\helpers\BSArray::popValue('overlayOptions', $htmlOptions, array());
     self::addCssClass('carousel-caption', $overlayOptions);
     $labelOptions = \bootstrap\helpers\BSArray::popValue('labelOptions', $htmlOptions, array());
     $captionOptions = \bootstrap\helpers\BSArray::popValue('captionOptions', $htmlOptions, array());
     $url = \bootstrap\helpers\BSArray::popValue('url', $htmlOptions, false);
     if ($url !== false) {
         $content = self::link($content, $url);
     }
     $output = self::openTag('div', $htmlOptions);
     $output .= $content;
     if (isset($label) || isset($caption)) {
         $output .= self::openTag('div', $overlayOptions);
         if ($label) {
             $output .= self::tag('h4', $labelOptions, $label);
         }
         if ($caption) {
             $output .= self::tag('p', $captionOptions, $caption);
         }
         $output .= '</div>';
     }
     $output .= '</div>';
     return $output;
 }
示例#5
0
 /**
  * set the label CssClass by Layout
  * @param string $layout
  * @param array $labelOptions
  * @return array new label options
  */
 private static function setLabelOptionsByLayout($layout, $labelOptions = array())
 {
     if (empty($layout) || $layout === BSHtml::FORM_LAYOUT_VERTICAL) {
         BSHtml::addCssClass('control-label', $labelOptions);
         return $labelOptions;
     }
     if ($layout === BSHtml::FORM_LAYOUT_INLINE) {
         BSHtml::addCssClass('control-label', $labelOptions);
         BSHtml::addCssClass('sr-only', $labelOptions);
         return $labelOptions;
     }
     $labelClass = \bootstrap\helpers\BSArray::popValue('class', $labelOptions, BSHtml::FORM_LAYOUT_HORIZONTAL_LABEL_CLASS);
     BSHtml::addCssClass('control-label', $labelOptions);
     BSHtml::addCssClass($labelClass, $labelOptions);
     return $labelOptions;
 }
示例#6
0
文件: BsModal.php 项目: bafio89/qea-u
 /**
  * Renders the button
  */
 public function renderButton()
 {
     if (!empty($this->buttonOptions) && is_array($this->buttonOptions)) {
         \bootstrap\helpers\BSArray::defaultValue('data-toggle', 'modal', $this->buttonOptions);
         if ($this->remote !== null) {
             $this->buttonOptions['data-remote'] = CHtml::normalizeUrl($this->remote);
         }
         $selector = '#' . $this->htmlOptions['id'];
         $label = \bootstrap\helpers\BSArray::popValue('label', $this->buttonOptions, 'button');
         $attr = isset($this->buttonOptions['data-remote']) ? 'data-target' : 'href';
         \bootstrap\helpers\BSArray::defaultValue($attr, $selector, $this->buttonOptions);
         echo BSHtml::button($label, $this->buttonOptions);
     }
 }