/**
  * Renders the widget.
  */
 public function run()
 {
     $this->registerClientScript();
     $button = Html::button(FontAwesome::icon('picture-o') . ' ' . $this->buttonLabel, $this->buttonOptions);
     if ($this->iframe) {
         $button .= Modal::widget(['id' => $this->getIFrameModalId(), 'header' => Html::tag('h4', $this->modalTitle, ['class' => 'modal-title']), 'size' => Modal::SIZE_LARGE, 'options' => ['class' => 'kcfinder-modal']]);
     }
     $thumbs = '';
     if ($this->hasModel() && is_array($this->model->{$this->attribute})) {
         $images = $this->model->{$this->attribute};
         foreach ($images as $path) {
             $thumbs .= strtr($this->thumbTemplate, ['{thumbSrc}' => $this->getThumbSrc($path), '{inputName}' => $this->getInputName(), '{inputValue}' => $path]);
         }
     }
     $thumbs = Html::tag('ul', $thumbs, ['id' => $this->getThumbsId(), 'class' => 'kcf-thumbs']);
     echo Html::tag('div', strtr($this->template, ['{button}' => $button, '{thumbs}' => $thumbs]), ['class' => 'kcf-input-group']);
 }
 /**
  * Renders the widget.
  */
 public function run()
 {
     $this->registerClientScript();
     $button = Html::button(FontAwesome::icon('picture-o') . ' ' . $this->buttonLabel, $this->buttonOptions);
     $thumbs = '<ul class="kcf-thumbs" id="' . $this->getThumbsId() . '"></ul>';
     echo Html::tag('div', strtr($this->template, ['{button}' => $button, '{thumbs}' => $thumbs]), ['class' => 'kcf-input-group']);
 }
Example #3
0
 /**
  * Renders the widget.
  */
 public function run()
 {
     // icon support
     foreach ($this->items as &$item) {
         if (isset($item['icon'])) {
             $icon = FA::icon($item['icon']);
             $item['label'] = trim($icon . ' ' . ArrayHelper::getValue($item, 'label', ''));
             $item['encode'] = false;
             unset($item['icon']);
         }
     }
     return parent::run();
 }
Example #4
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     foreach ($this->items as &$item) {
         // icon ?
         if (isset($item['icon'])) {
             $icon = FA::icon($item['icon'] . ' fw');
             $item['label'] = trim($icon . ' ' . ArrayHelper::getValue($item, 'label', ''));
             $item['encode'] = false;
             unset($item['icon']);
         }
         // active ?
         if (isset($item['active'])) {
             $active = $item['active'];
             if ($active instanceof \Closure) {
                 $active = call_user_func($active, $this->getView()->getContext());
             }
             if ($active) {
                 Html::addCssClass($item['options'], 'active');
             }
             unset($item['active']);
         }
     }
     return parent::run();
 }
Example #5
0
 /**
  * Renders the widget.
  */
 public function run()
 {
     if (!$this->visible) {
         return '';
     }
     if ($this->url !== null) {
         $this->options['href'] = Url::to($this->url);
         $this->tagName = 'a';
     }
     if ($this->disabled) {
         $this->options['disabled'] = 'disabled';
         $this->tagName = 'button';
         $this->items = null;
         unset($this->options['href'], $this->options['target']);
     }
     if (!empty($this->type)) {
         if ($this->type == 'submit') {
             $this->options['type'] = $this->type;
             Html::addCssClass($this->options, 'btn-primary');
         } else {
             if ($this->type == 'button') {
                 $this->options['type'] = $this->type;
                 Html::addCssClass($this->options, 'btn-default');
             } else {
                 Html::addCssClass($this->options, 'btn-' . $this->type);
             }
         }
     }
     if (!empty($this->size)) {
         Html::addCssClass($this->options, 'btn-' . $this->size);
     }
     if (!empty($this->tooltip)) {
         $this->options['title'] = $this->tooltip;
         $this->options['data']['toggle'] = 'tooltip';
         $this->options['data']['container'] = 'body';
     }
     if (!empty($this->icon)) {
         $this->label = FA::icon($this->icon) . ' ' . $this->label;
         $this->encodeLabel = false;
     }
     if (is_array($this->items)) {
         return $this->renderDropdown();
     }
     return parent::run();
 }