예제 #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
파일: MNav.php 프로젝트: bafio89/qea-u
 private function prepareItems()
 {
     $option = array();
     foreach ($this->items as $item) {
         $label = '';
         if (isset($item['icon'])) {
             $label .= BSHtml::icon($item['icon'] . ' glyphicon iconb');
         }
         //            CVarDumper::dump($htmlOptions,10,true);
         if ($this->type === MNav::MIDDLE_NAV_A || $this->type === MNav::MIDDLE_NAV_FREE && isset($item['label'])) {
             $label .= "<span>{$item['label']} </span>";
         }
         $htmlOptions = array();
         $cssclass = 'tipN ';
         //            if(isset($item['icon']))
         //                $label .= BSHtml::icon()$item['icon'].' iconb';
         if (isset($item['color'])) {
             $cssclass .= $item['color'];
         }
         $htmlOptions['class'] = $cssclass;
         if (isset($item['tooltip'])) {
             $htmlOptions['data-toggle'] = 'tooltip';
         }
         if (isset($item['tooltip']['label'])) {
             $htmlOptions['data-original-title'] = $item['tooltip']['label'];
         }
         if (isset($item['tooltip']['placement'])) {
             $htmlOptions['data-placement'] = $item['tooltip']['placement'];
         }
         if (isset($item['badge'])) {
             $htmlOptions['badge'] = $item['badge'];
         }
         if (isset($item['label'])) {
             $htmlOptions['title'] = $item['label'];
         }
         $option[] = array($label, $item['url'], $htmlOptions);
     }
     return $option;
 }