/** * Widget's init function */ public function init() { parent::init(); $this->options['style'] = ArrayHelper::getValue($this->options, 'style', ''); $width = ArrayHelper::getValue($this->options, 'width', '100%'); $height = ArrayHelper::remove($this->options, 'height', '450px'); $this->options['style'] = "width:{$width};height:{$height};" . $this->options['style']; }
/** * Builds meta-tag options based on the options and attributes */ public function buildOptions() { $options = $this->options; ArrayHelper::remove($this->options, 'disabled'); $this->addCssClass($options, 'switch'); $options['data-animated'] = $this->animated ? 'true' : 'false'; $options['data-on-label'] = $this->onLabel; $options['data-off-label'] = $this->offLabel; $options['data-on'] = $this->onStyle ? $this->offStyle : 'primary'; $options['data-off'] = $this->offStyle ? $this->offStyle : 'default'; }
/** * Renders the close button. * @return string the rendering result */ protected function renderCloseButton() { if ($this->closeButton !== null) { $tag = ArrayHelper::remove($this->closeButton, 'tag', 'button'); $label = ArrayHelper::remove($this->closeButton, 'label', '×'); if ($tag === 'button' && !isset($this->closeButton['type'])) { $this->closeButton['type'] = 'button'; } return \CHtml::tag($tag, $this->closeButton, $label); } else { return null; } }
/** * Renders the data cell content. * This method renders the view, update and toggle buttons in the data cell. * @param integer $row the row number (zero-based) * @param mixed $data the data associated with the row */ protected function renderDataCellContent($row, $data) { $checked = \CHtml::value($data, $this->name); $toggleOptions = $this->toggleOptions; $toggleOptions['icon'] = $checked === null ? $this->emptyIcon : ($checked ? $this->checkedIcon : $this->uncheckedIcon); $toggleOptions['url'] = isset($toggleOptions['url']) ? $this->evaluateExpression($toggleOptions['url'], array('data' => $data, 'row' => $row)) : '#'; if (!$this->displayText) { $htmlOptions = ArrayHelper::remove($this->toggleOptions, 'htmlOptions', array()); $htmlOptions['title'] = $this->getButtonLabel($checked); $htmlOptions['rel'] = 'tooltip'; echo \CHtml::link($toggleOptions['icon'], $toggleOptions['url'], $htmlOptions); } else { echo \CHtml::button($this->getButtonLabel($checked), $toggleOptions); } }
/** * Builds the [[clientOptions]] of the plugin. */ protected function buildOptions() { $onChange = ArrayHelper::remove($this->clientEvents, 'onChange', 'js:$.noop'); $config = array('onChange' => $onChange, 'width' => $this->width, 'height' => $this->height, 'animated' => $this->animated, 'transitionSpeed' => $this->transitionSpeed, 'label' => array('enabled' => $this->onLabel, 'disabled' => $this->offLabel), 'style' => array()); if (!empty($this->enabledStyle)) { $config['style']['enabled'] = $this->enabledStyle; } if (!empty($this->disabledStyle)) { $config['style']['disabled'] = $this->disabledStyle; } if (!empty($this->customEnabledStyle)) { $config['style']['custom'] = array('enabled' => $this->customEnabledStyle); } if (!empty($this->customDisabledStyle)) { if (isset($config['style']['custom'])) { $config['style']['custom']['disabled'] = $this->customDisabledStyle; } else { $config['style']['custom'] = array('disabled' => $this->customDisabledStyle); } } foreach ($config as $key => $element) { if (empty($element)) { unset($config[$key]); } } $this->clientOptions = ArrayHelper::merge($this->clientOptions, $config); }
/** * Normalizes dropdown item options by removing tab specific keys `content` and `contentOptions`, and also * configure `panes` accordingly. * @param array $items the dropdown items configuration. * @param array $panes the panes reference array. * @return boolean whether any of the dropdown items is `active` or not. * @throws \CException */ protected function renderDropdown(&$items, &$panes) { $itemActive = false; foreach ($items as $n => &$item) { if (is_string($item)) { continue; } if (!isset($item['content'])) { throw new \CException("The 'content' option is required."); } $content = ArrayHelper::remove($item, 'content'); $options = ArrayHelper::remove($item, 'contentOptions', array()); $this->addCssClass($options, 'tab-pane'); if (ArrayHelper::remove($item, 'active')) { $this->addCssClass($options, 'active'); $this->addCssClass($item['options'], 'active'); $itemActive = true; } $options['id'] = ArrayHelper::getValue($options, 'id', $this->options['id'] . '-dd-tab' . $n); $item['url'] = '#' . $options['id']; $item['linkOptions']['data-toggle'] = 'tab'; $panes[] = \CHtml::tag('div', $options, $content); unset($item); } return $itemActive; }
/** * Renders fileupload views */ public function renderViews() { $htmlOptions = array(); $htmlOptions['multiple'] = ArrayHelper::remove($this->options, 'multiple', ''); $htmlOptions['name'] = ArrayHelper::remove($this->options, 'name'); $this->render($this->uploadView); $this->render($this->downloadView); $this->render($this->formView, compact('htmlOptions')); if ($this->previewImages || $this->imageProcessing) { $this->render($this->galleryView); } }