Example #1
0
 /**
  * Widget's initialization method
  */
 public function init()
 {
     $this->attachBehavior('TbWidget', new TbWidget());
     $this->copyId();
     TbArray::defaultValue('placement', $this->placement, $this->htmlOptions);
     $this->initEvents();
 }
Example #2
0
 /**
  * Renders the input file field
  */
 public function renderField()
 {
     list($name, $id) = $this->resolveNameID();
     TbArray::defaultValue('id', $id, $this->htmlOptions);
     TbArray::defaultValue('name', $name, $this->htmlOptions);
     TbHtml::addCssClass('bfh-selectbox', $this->wrapperOptions);
     echo CHtml::openTag('div', $this->wrapperOptions);
     if ($this->hasModel()) {
         echo CHtml::activeHiddenField($this->model, $this->attribute, $this->htmlOptions);
         $value = $this->model->{$this->attribute};
         $valueText = $value && isset($this->data[$value]) ? $this->data[$value] : ' ';
     } else {
         echo CHtml::hiddenField($name, $this->value, $this->htmlOptions);
         $value = $this->value;
         $valueText = $value && isset($this->data[$value]) ? $this->data[$value] : ' ';
     }
     echo CHtml::openTag('a', array('class' => 'bfh-selectbox-toggle', 'role' => 'button', 'data-toggle' => 'bfh-selectbox', 'href' => '#'));
     echo CHtml::tag('span', array('class' => 'bfh-selectbox-option ' . $this->size, 'data-option' => $value), $valueText);
     echo CHtml::tag('b', array('class' => 'caret'), ' ');
     echo CHtml::closeTag('a');
     echo CHtml::openTag('div', array('class' => 'bfh-selectbox-options'));
     if ($this->displayFilter) {
         echo '<input type="text" class="bfh-selectbox-filter">';
     }
     $items = array();
     foreach ($this->data as $key => $item) {
         $items[] = CHtml::tag('a', array('tabindex' => '-1', 'href' => '#', 'data-option' => $key), $item);
     }
     echo CHtml::tag('ul', array('role' => 'options'), '<li>' . implode('</li><li>', $items) . '</li>');
     echo CHtml::closeTag('div');
     echo CHtml::closeTag('div');
 }
Example #3
0
    /**
     * Renders the input file field
     */
    public function renderField()
    {
        list($name, $id) = $this->resolveNameID();
        TbArray::defaultValue('id', $id, $this->htmlOptions);
        TbArray::defaultValue('name', $name, $this->htmlOptions);
        echo CHtml::openTag('div', $this->htmlOptions);
        echo CHtml::openTag('div', array('class' => 'input-prepend bfh-timepicker-toggle', 'data-toggle' => 'bfh-timepicker'));
        echo CHtml::tag('span', array('class' => 'add-on'), TbHtml::icon(TbHtml::ICON_TIME));
        if ($this->hasModel()) {
            echo CHtml::activeTextField($this->model, $this->attribute, $this->inputOptions);
        } else {
            echo CHtml::textField($name, $this->value, $this->inputOptions);
        }
        echo CHtml::closeTag('div');
        echo '<div class="bfh-timepicker-popover">
				<table class="table">
				<tbody>
					<tr>
						<td class="hour">
						<a class="next" href="#"><i class="icon-chevron-up"></i></a><br>
						<input type="text" class="input-mini" readonly><br>
						<a class="previous" href="#"><i class="icon-chevron-down"></i></a>
						</td>
						<td class="separator">:</td>
						<td class="minute">
						<a class="next" href="#"><i class="icon-chevron-up"></i></a><br>
						<input type="text" class="input-mini" readonly><br>
						<a class="previous" href="#"><i class="icon-chevron-down"></i></a>
						</td>
					</tr>
				</tbody>
				</table>
			</div>';
        echo CHtml::closeTag('div');
    }
Example #4
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     $this->attachBehavior('TbWidget', new TbWidget());
     $this->copyId();
     if (isset($this->size)) {
         TbArray::defaultValue('size', $this->size, $this->htmlOptions);
     }
 }
Example #5
0
 public function testDefaultValue()
 {
     $array = array();
     TbArray::defaultValue('key', 'default', $array);
     $this->assertEquals('default', TbArray::getValue('key', $array));
     TbArray::defaultValue('key', 'value', $array);
     $this->assertEquals('default', TbArray::getValue('key', $array));
 }
 /**
  * Renders the select2 field
  */
 public function renderField()
 {
     list($name, $id) = $this->resolveNameID();
     TbArray::defaultValue('id', $id, $this->htmlOptions);
     TbArray::defaultValue('name', $name, $this->htmlOptions);
     if ($this->hasModel()) {
         echo $this->asDropDownList ? TbHtml::activeDropDownList($this->model, $this->attribute, $this->data, $this->htmlOptions) : TbHtml::activeHiddenField($this->model, $this->attribute);
     } else {
         echo $this->asDropDownList ? TbHtml::dropDownList($this->name, $this->value, $this->data, $this->htmlOptions) : TbHtml::hiddenField($this->name, $this->value);
     }
 }
Example #7
0
 /**
  * Renders field
  */
 public function renderField()
 {
     list($name, $id) = $this->resolveNameID();
     TbArray::defaultValue('id', $id, $this->htmlOptions);
     TbArray::defaultValue('name', $name, $this->htmlOptions);
     if ($this->hasModel()) {
         echo CHtml::activeTextArea($this->model, $this->attribute, $this->htmlOptions);
     } else {
         echo CHtml::textArea($name, $this->value, $this->htmlOptions);
     }
 }
 /**
  * Renders the input file field
  */
 public function renderField()
 {
     list($name, $id) = $this->resolveNameID();
     TbArray::defaultValue('id', $id, $this->htmlOptions);
     TbArray::defaultValue('name', $name, $this->htmlOptions);
     $this->htmlOptions['data-url'] = $this->uploadAction;
     $this->pluginOptions['url'] = $this->uploadAction;
     if ($this->hasModel()) {
         echo CHtml::activeFileField($this->model, $this->attribute, $this->htmlOptions);
     } else {
         echo CHtml::fileField($name, $this->value, $this->htmlOptions);
     }
 }
 /**
  * Initializes the widget.
  */
 public function init()
 {
     TbArray::defaultValue('successClass', 'success', $this->pluginOptions);
     TbArray::defaultValue('errorClass', 'error', $this->pluginOptions);
     if (!isset($this->assetPath)) {
         $this->assetPath = Yii::getPathOfAlias('vendor.guillaumepotier.parsleyjs.dist');
     }
     if (!$this->bindPlugin) {
         $this->htmlOptions['data-plugin'] = 'parsley';
         $this->htmlOptions['data-plugin-options'] = CJSON::encode($this->pluginOptions);
     }
     parent::init();
 }
Example #10
0
 /**
  * Renders the field
  */
 public function renderField()
 {
     list($name, $id) = $this->resolveNameID();
     TbArray::defaultValue('id', $id, $this->htmlOptions);
     TbArray::defaultValue('name', $name, $this->htmlOptions);
     echo '<span class="bootstrap-timepicker">';
     if ($this->hasModel()) {
         echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
     } else {
         echo CHtml::textField($name, $this->value, $this->htmlOptions, array('style' => 'width:100%'));
     }
     echo '</span>';
 }
Example #11
0
 /**
  * Renders the multiselect field
  */
 public function renderField()
 {
     list($name, $id) = $this->resolveNameID();
     TbArray::defaultValue('id', $id, $this->htmlOptions);
     TbArray::defaultValue('name', $name, $this->htmlOptions);
     // fixes #32: 'multiple' will be forced later in jQuery plugin
     $this->htmlOptions['multiple'] = 'multiple';
     if ($this->hasModel()) {
         echo CHtml::activeDropDownList($this->model, $this->attribute, $this->data, $this->htmlOptions);
     } else {
         echo CHtml::dropDownList($this->name, $this->value, $this->data, $this->htmlOptions);
     }
 }
Example #12
0
 /**
  * Renders the field
  */
 public function renderField()
 {
     list($name, $id) = $this->resolveNameID();
     TbArray::defaultValue('id', $id, $this->htmlOptions);
     TbArray::defaultValue('name', $name, $this->htmlOptions);
     echo '<div class="input-group">';
     echo '<div class="input-group-addon"><span class="glyphicon glyphicon-time"></span></div>';
     if ($this->hasModel()) {
         echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
     } else {
         echo CHtml::textField($name, $this->value, $this->htmlOptions, array('style' => 'width:100%'));
     }
     echo '</div>';
 }
Example #13
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     if ($this->brandLabel !== false) {
         if (!isset($this->brandLabel)) {
             $this->brandLabel = CHtml::encode(Yii::app()->name);
         }
         if (!isset($this->brandUrl)) {
             $this->brandUrl = Yii::app()->homeUrl;
         }
     }
     if (isset($this->color)) {
         TbArray::defaultValue('color', $this->color, $this->htmlOptions);
     }
     if (isset($this->display) && $this->display !== TbHtml::NAVBAR_DISPLAY_NONE) {
         TbArray::defaultValue('display', $this->display, $this->htmlOptions);
     }
 }
Example #14
0
 /**
  * Renders field
  */
 public function renderField()
 {
     list($name, $id) = $this->resolveNameID();
     TbArray::defaultValue('id', $id, $this->htmlOptions);
     TbArray::defaultValue('name', $name, $this->htmlOptions);
     $tagOptions = $this->htmlOptions;
     $tagOptions['id'] = 'aceEditor_' . $tagOptions['id'];
     echo CHtml::openTag('div', $tagOptions);
     echo CHtml::closeTag('div');
     $this->htmlOptions['style'] = 'display:none';
     if ($this->hasModel()) {
         echo CHtml::activeTextArea($this->model, $this->attribute, $this->htmlOptions);
     } else {
         echo CHtml::textArea($name, $this->value, $this->htmlOptions);
     }
     $this->htmlOptions = $tagOptions;
 }
Example #15
0
 /**
  * Renders the input file field
  */
 public function renderField()
 {
     list($name, $id) = $this->resolveNameID();
     TbArray::defaultValue('id', $id, $this->htmlOptions);
     TbArray::defaultValue('name', $name, $this->htmlOptions);
     if ($this->useHelperSelectBox) {
         $select = Yii::createComponent(CMap::mergeArray($this->helperOptions, array('class' => 'yiiwheels.widgets.formhelpers.WhSelectBox', 'htmlOptions' => $this->htmlOptions, 'model' => $this->model, 'attribute' => $this->attribute, 'name' => $this->name, 'value' => $this->value, 'wrapperOptions' => array('class' => 'bfh-fonts', 'data-family' => $this->hasModel() ? $this->model->{$this->attribute} : $this->value))));
         $select->init();
         $select->run();
     } else {
         $this->htmlOptions['data-family'] = $this->hasModel() ? $this->model->{$this->attribute} : $this->value;
         if ($this->hasModel()) {
             echo CHtml::activeDropDownList($this->model, $this->attribute, array(), $this->htmlOptions);
         } else {
             echo CHtml::dropDownList($name, $this->value, array(), $this->htmlOptions);
         }
     }
 }
Example #16
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     $this->attachBehavior('TbWidget', new TbWidget());
     $this->copyId();
     TbHtml::addCssClass('collapse', $this->htmlOptions);
     if (isset($this->parent)) {
         TbArray::defaultValue('data-parent', $this->parent, $this->htmlOptions);
     }
     if (isset($this->toggle) && $this->toggle) {
         TbHtml::addCssClass('in', $this->htmlOptions);
     }
     if (isset($this->view)) {
         $controller = $this->getController();
         if (isset($controller) && $controller->getViewFile($this->view) !== false) {
             $this->content = $this->controller->renderPartial($this->view, $this->viewData, true);
         }
     }
     echo TbHtml::openTag($this->tagName, $this->htmlOptions);
     echo $this->content;
 }
Example #17
0
 /**
  * Renders the input file field
  */
 public function renderField()
 {
     list($name, $id) = $this->resolveNameID();
     TbArray::defaultValue('id', $id, $this->htmlOptions);
     TbArray::defaultValue('name', $name, $this->htmlOptions);
     if ($this->useHelperSelectBox) {
         $select = Yii::createComponent(CMap::mergeArray($this->helperOptions, array('class' => 'yiiwheels.widgets.formhelpers.WhSelectBox', 'htmlOptions' => $this->htmlOptions, 'model' => $this->model, 'attribute' => $this->attribute, 'name' => $this->name, 'value' => $this->value, 'wrapperOptions' => array('class' => 'bfh-languages', 'data-language' => $this->hasModel() ? $this->model->{$this->attribute} : $this->value, 'data-flags' => isset($this->pluginOptions['flags']) && $this->pluginOptions['flags'] ? 'true' : 'false', 'data-available' => isset($this->pluginOptions['available']) ? $this->pluginOptions['available'] : null))));
         $select->init();
         $select->run();
     } else {
         $this->htmlOptions['data-language'] = $this->hasModel() ? $this->model->{$this->attribute} : $this->value;
         if (!$this->readOnly) {
             if ($this->hasModel()) {
                 echo CHtml::activeDropDownList($this->model, $this->attribute, array(), $this->htmlOptions);
             } else {
                 echo CHtml::dropDownList($name, $this->value, array(), $this->htmlOptions);
             }
         } else {
             echo CHtml::tag('span', $this->htmlOptions);
         }
     }
 }
    /**
     * Renders the input file field
     */
    public function renderField()
    {
        list($name, $id) = $this->resolveNameID();
        TbArray::defaultValue('id', $id, $this->htmlOptions);
        TbArray::defaultValue('name', $name, $this->htmlOptions);
        echo CHtml::openTag('div', $this->htmlOptions);
        echo CHtml::openTag('div', array('class' => 'input-prepend bfh-datepicker-toggle', 'data-toggle' => 'bfh-datepicker'));
        echo CHtml::tag('span', array('class' => 'add-on'), TbHtml::icon(TbHtml::ICON_CALENDAR));
        if ($this->hasModel()) {
            echo CHtml::activeTextField($this->model, $this->attribute, $this->inputOptions);
        } else {
            echo CHtml::textField($name, $this->value, $this->inputOptions);
        }
        echo CHtml::closeTag('div');
        echo '<div class="bfh-datepicker-calendar">
				<table class="calendar table table-bordered">
					<thead>
						<tr class="months-header">
							<th class="month" colspan="4">
							<a class="previous" href="#"><i class="icon-chevron-left"></i></a>
							<span></span>
							<a class="next" href="#"><i class="icon-chevron-right"></i></a>
						</th>
						<th class="year" colspan="3">
							<a class="previous" href="#"><i class="icon-chevron-left"></i></a>
							<span></span>
							<a class="next" href="#"><i class="icon-chevron-right"></i></a>
						</th>
						</tr>
						<tr class="days-header">
						</tr>
					</thead>
					<tbody>
					</tbody>
				</table>
			</div>';
        echo CHtml::closeTag('div');
    }
Example #19
0
 /**
  * Runs the widget.
  */
 public function run()
 {
     /* @var $user CWebUser */
     $user = Yii::app()->getUser();
     if (count($user->getFlashes(false)) == 0) {
         return;
     }
     echo TbHtml::openTag('div', $this->htmlOptions);
     foreach ($this->alerts as $color => $alert) {
         if (isset($alert['visible']) && !$alert['visible']) {
             continue;
         }
         if ($user->hasFlash($color)) {
             $htmlOptions = TbArray::popValue('htmlOptions', $alert, array());
             TbArray::defaultValue('closeText', $this->closeText, $htmlOptions);
             TbArray::defaultValue('block', $this->block, $htmlOptions);
             TbArray::defaultValue('fade', $this->fade, $htmlOptions);
             echo TbHtml::alert($color, $user->getFlash($color), $htmlOptions);
         }
     }
     echo '</div>';
     $this->registerEvents("#{$this->htmlOptions['id']} > .alert", $this->events);
 }
Example #20
0
 /**
  * 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 = TbArray::popValue('url', $button);
     if ($url !== '#') {
         $url = $this->evaluateExpression($url, array('data' => $data, 'row' => $row));
     }
     $imageUrl = TbArray::popValue('imageUrl', $button, false);
     $label = TbArray::popValue('label', $button, $id);
     $options = TbArray::popValue('options', $button, array());
     TbArray::defaultValue('title', $label, $options);
     TbArray::defaultValue('rel', 'tooltip', $options);
     if ($icon = TbArray::popValue('icon', $button, false)) {
         echo CHtml::link(TbHtml::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);
         }
     }
 }
    /**
     * Runs the widget.
     */
    public function run()
    {
        list($name, $id) = $this->resolveNameID();
        $this->resolveId($id);
        if ($this->hasModel()) {
            $input = TbHtml::activeFileField($this->model, $this->attribute, $this->htmlOptions);
        } else {
            $input = TbHtml::fileField($name, $this->value, $this->htmlOptions);
        }
        echo TbHtml::tag('span', $this->buttonOptions, $this->label . ' ' . $input);
        if ($this->assetPath !== false) {
            $this->publishAssets($this->assetPath);
            $this->registerCssFile('css/jquery.fileupload-ui.css');
            if ($this->registerJs) {
                $this->getClientScript()->registerCoreScript('jquery');
                $this->registerScriptFile('js/vendor/jquery.ui.widget.js', CClientScript::POS_END);
                $this->registerScriptFile('js/jquery.iframe-transport.js', CClientScript::POS_END);
                $this->registerScriptFile('js/jquery.fileupload.js', CClientScript::POS_END);
            }
        }
        if ($this->bindPlugin) {
            TbArray::defaultValue('dataType', 'json', $this->pluginOptions);
            $options = !empty($this->pluginOptions) ? CJavaScript::encode($this->pluginOptions) : '';
            $script = <<<EOD
jQuery('#{$id}')
    .fileupload({$options})
    .prop('disabled', !jQuery.support.fileInput)
    .parent().addClass(jQuery.support.fileInput ? undefined : 'disabled');
EOD;
            $this->getClientScript()->registerScript(__CLASS__ . '#' . $id, $script);
        }
    }
Example #22
0
 /**
  * Registers the Bootstrap Tooltip plugin.
  * @param string $selector the CSS selector.
  * @param array $options the JavaScript options for the plugin.
  * @see http://twitter.github.com/bootstrap/javascript.html#tooltip
  */
 public function registerTooltip($selector = 'body', $options = array())
 {
     TbArray::defaultValue('selector', 'a[rel=tooltip]', $options);
     $this->registerPlugin(self::PLUGIN_TOOLTIP, $selector, $options);
 }
Example #23
0
 /**
  * Generates an image carousel.
  * @param array $items the item configurations.
  * @param array $htmlOptions additional HTML attributes.
  * @return string the generated carousel.
  */
 public static function carousel(array $items, $htmlOptions = array())
 {
     if (!empty($items)) {
         $id = TbArray::getValue('id', $htmlOptions, parent::ID_PREFIX . parent::$count++);
         TbArray::defaultValue('id', $id, $htmlOptions);
         $selector = '#' . $id;
         self::addCssClass('carousel', $htmlOptions);
         if (TbArray::popValue('slide', $htmlOptions, true)) {
             self::addCssClass('slide', $htmlOptions);
         }
         $interval = TbArray::popValue('data-interval', $htmlOptions);
         if ($interval) {
             $htmlOptions['data-interval'] = $interval;
         }
         $pause = TbArray::popValue('data-pause', $htmlOptions);
         if ($pause) {
             $htmlOptions['data-pause'] = $pause;
         }
         $indicatorOptions = TbArray::popValue('indicatorOptions', $htmlOptions, array());
         $innerOptions = TbArray::popValue('innerOptions', $htmlOptions, array());
         self::addCssClass('carousel-inner', $innerOptions);
         $prevOptions = TbArray::popValue('prevOptions', $htmlOptions, array());
         $prevLabel = TbArray::popValue('label', $prevOptions, '&lsaquo;');
         $nextOptions = TbArray::popValue('nextOptions', $htmlOptions, array());
         $nextLabel = TbArray::popValue('label', $nextOptions, '&rsaquo;');
         $hidePrevAndNext = TbArray::popValue('hidePrevAndNext', $htmlOptions, false);
         $output = self::openTag('div', $htmlOptions);
         $output .= self::carouselIndicators($selector, count($items), $indicatorOptions);
         $output .= self::openTag('div', $innerOptions);
         foreach ($items as $i => $itemOptions) {
             if (isset($itemOptions['visible']) && $itemOptions['visible'] === false) {
                 continue;
             }
             if ($i === 0) {
                 // first item should be active
                 self::addCssClass('active', $itemOptions);
             }
             $content = TbArray::popValue('content', $itemOptions, '');
             $image = TbArray::popValue('image', $itemOptions, '');
             $imageOptions = TbArray::popValue('imageOptions', $itemOptions, array());
             $imageAlt = TbArray::popValue('alt', $imageOptions, '');
             if (!empty($image)) {
                 $content = parent::image($image, $imageAlt, $imageOptions);
             }
             $label = TbArray::popValue('label', $itemOptions);
             $caption = TbArray::popValue('caption', $itemOptions);
             $output .= self::carouselItem($content, $label, $caption, $itemOptions);
         }
         $output .= '</div>';
         if (!$hidePrevAndNext) {
             $output .= self::carouselPrevLink($prevLabel, $selector, $prevOptions);
             $output .= self::carouselNextLink($nextLabel, $selector, $nextOptions);
         }
         $output .= '</div>';
         return $output;
     }
     return '';
 }
Example #24
0
 /**
  * Normalizes the menu items.
  * @param array $items the items to be normalized.
  * @param string $route the route of the current request.
  * @param boolean $active whether there is an active child menu item.
  * @return array the normalized menu items.
  */
 protected function normalizeItems($items, $route, &$active)
 {
     foreach ($items as $i => $item) {
         // skip dividers
         if (is_string($item)) {
             continue;
         }
         if (isset($item['visible']) && !$item['visible']) {
             unset($items[$i]);
             continue;
         }
         TbArray::defaultValue('label', '', $item);
         if ($this->encodeLabel) {
             $items[$i]['label'] = CHtml::encode($item['label']);
         }
         $hasActiveChild = false;
         if (isset($item['items']) && !empty($item['items'])) {
             $items[$i]['items'] = $this->normalizeItems($item['items'], $route, $hasActiveChild);
             if (empty($items[$i]['items']) && $this->hideEmptyItems) {
                 unset($items[$i]['items']);
                 if (!isset($item['url'])) {
                     unset($items[$i]);
                     continue;
                 }
             }
         }
         if (!isset($item['active'])) {
             if ($this->activateParents && $hasActiveChild || $this->activateItems && $this->isItemActive($item, $route)) {
                 $active = $items[$i]['active'] = true;
             } else {
                 $items[$i]['active'] = false;
             }
         } else {
             if ($item['active']) {
                 $active = true;
             }
         }
     }
     return array_values($items);
 }
Example #25
0
 /**
  * Renders field
  */
 public function renderField()
 {
     list($name, $id) = $this->resolveNameID();
     TbArray::defaultValue('id', $id, $this->htmlOptions);
     TbArray::defaultValue('name', $name, $this->htmlOptions);
     // by using TbHtml we support all bootstrap options
     if ($this->hasModel()) {
         echo TbHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
     } else {
         echo TbHtml::textField($name, $this->value, $this->htmlOptions);
     }
 }
Example #26
0
 /**
  * Initializes this form.
  */
 public function init()
 {
     TbArray::defaultValue('layout', $this->layout, $this->activeForm);
 }
Example #27
0
 /**
  * Renders the button
  */
 public function renderButton()
 {
     if (!empty($this->buttonOptions) && is_array($this->buttonOptions)) {
         TbArray::defaultValue('data-toggle', 'modal', $this->buttonOptions);
         if ($this->remote !== null) {
             $this->buttonOptions['data-remote'] = CHtml::normalizeUrl($this->remote);
         }
         $selector = '#' . $this->htmlOptions['id'];
         $label = TbArray::popValue('label', $this->buttonOptions, 'button');
         $attr = isset($this->buttonOptions['data-remote']) ? 'data-target' : 'href';
         TbArray::defaultValue($attr, $selector, $this->buttonOptions);
         echo TbHtml::button($label, $this->buttonOptions);
     }
 }
Example #28
0
 /**
  * Displays a summary of validation errors for one or several models.
  * @param mixed $models the models whose input errors are to be displayed.
  * @param string $header a piece of HTML code that appears in front of the errors
  * @param string $footer a piece of HTML code that appears at the end of the errors
  * @param array $htmlOptions additional HTML attributes to be rendered in the container div tag.
  * @return string the error summary. Empty if no errors are found.
  */
 public function errorSummary($models, $header = null, $footer = null, $htmlOptions = array())
 {
     if (!$this->enableAjaxValidation && !$this->enableClientValidation) {
         return TbHtml::errorSummary($models, $header, $footer, $htmlOptions);
     }
     TbArray::defaultValue('id', $this->id . '_es_', $htmlOptions);
     $html = TbHtml::errorSummary($models, $header, $footer, $htmlOptions);
     if ($html === '') {
         if ($header === null) {
             $header = '<p>' . Yii::t('yii', 'Please fix the following input errors:') . '</p>';
         }
         TbHtml::addCssClass(TbHtml::$errorSummaryCss, $htmlOptions);
         TbHtml::addCssStyle('display:none', $htmlOptions);
         $html = CHtml::tag('div', $htmlOptions, $header . '<ul><li>dummy</li></ul>' . $footer);
     }
     $this->summaryID = $htmlOptions['id'];
     return $html;
 }
Example #29
0
 /**
  * Renders the typeahead field
  */
 public function renderField()
 {
     list($name, $id) = $this->resolveNameID();
     TbArray::defaultValue('id', $id, $this->htmlOptions);
     TbArray::defaultValue('name', $name, $this->htmlOptions);
     if ($this->hasModel()) {
         echo $this->inputType == 'radio' ? CHtml::activeRadioButton($this->model, $this->attribute, $this->htmlOptions) : CHtml::activeCheckBox($this->model, $this->attribute, $this->htmlOptions);
     } else {
         echo $this->inputType == 'radio' ? CHtml::radioButton($this->name, $this->value, $this->htmlOptions) : CHtml::checkBox($this->name, $this->value, $this->htmlOptions);
     }
 }
Example #30
0
 /**
  * Sets up default options for the plugin
  * - thanks https://github.com/anggiaj
  */
 protected function initDefaultOptions()
 {
     list($name, $id) = $this->resolveNameID();
     TbArray::defaultValue('id', $id, $this->htmlOptions);
     TbArray::defaultValue('name', $name, $this->htmlOptions);
     $this->defaultOptions = array('request' => array('endpoint' => $this->uploadAction, 'inputName' => $name), 'validation' => $this->getValidator(), 'messages' => array('typeError' => Yii::t('zii', '{file} has an invalid extension. Valid extension(s): {extensions}.'), 'sizeError' => Yii::t('zii', '{file} is too large, maximum file size is {sizeLimit}.'), 'minSizeError' => Yii::t('zii', '{file} is too small, minimum file size is {minSizeLimit}.'), 'emptyError:' => Yii::t('zii', '{file} is empty, please select files again without it.'), 'noFilesError' => Yii::t('zii', 'No files to upload.'), 'onLeave' => Yii::t('zii', 'The files are being uploaded, if you leave now the upload will be cancelled.')));
 }