Inheritance: extends CHtml
 /**
  * Renders the data cell content.
  *
  * @param integer $row the row number (zero-based)
  * @param YdActiveRecord $data the data associated with the row
  */
 protected function renderDataCellContent($row, $data)
 {
     ob_start();
     parent::renderDataCellContent($row, $data);
     $parentContents = ob_get_clean();
     if ($data instanceof CActiveRecord) {
         $links = is_callable(array($data, 'getMenuLinks')) ? call_user_func(array($data, 'getMenuLinks')) : array();
         if ($links) {
             if (is_callable(array($data, 'getUrl'))) {
                 $this->buttonOptions['type'] = TbHtml::BUTTON_TYPE_LINK;
                 $this->buttonOptions['url'] = call_user_func(array($data, 'getUrl'));
             }
             echo '<div class="filter-container">';
             $this->buttonOptions['split'] = true;
             echo TbHtml::buttonDropdown($parentContents, $links, $this->buttonOptions);
             echo '</div>';
         } else {
             $url = is_callable(array($data, 'getUrl')) ? call_user_func(array($data, 'getUrl')) : false;
             if ($url) {
                 $this->buttonOptions['class'] = isset($this->buttonOptions['class']) ? $this->buttonOptions['class'] . ' btn' : 'btn';
                 echo TbHtml::link($parentContents, $url, $this->buttonOptions);
             } else {
                 echo TbHtml::button($parentContents, $this->buttonOptions);
             }
         }
     } else {
         echo TbHtml::button($parentContents, $this->buttonOptions);
     }
 }
 /**
  * Runs the widget.
  */
 public function run()
 {
     list($name, $id) = $this->resolveNameID();
     $id = $this->resolveId($id);
     if ($this->hasModel()) {
         echo TbHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
     } else {
         echo TbHtml::textField($name, $this->value, $this->htmlOptions);
     }
     if ($this->assetPath !== false) {
         $this->publishAssets($this->assetPath);
         $this->registerCssFile('/css/bootstrap-datetimepicker.css');
         if ($this->registerJs) {
             $this->registerScriptFile('/js/' . $this->resolveScriptVersion('bootstrap-datetimepicker.js'), CClientScript::POS_END);
             if (isset($this->locale)) {
                 $this->locale = str_replace('_', '-', $this->locale);
                 $this->registerScriptFile("/js/locales/bootstrap-datetimepicker.{$this->locale}.js", CClientScript::POS_END);
             }
         }
     }
     if ($this->bindPlugin) {
         $options = !empty($this->pluginOptions) ? CJavaScript::encode($this->pluginOptions) : '';
         $this->getClientScript()->registerScript(__CLASS__ . '#' . $id, "jQuery('#{$id}').datetimepicker({$options});");
     }
 }
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);
     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] : '&nbsp;';
     } else {
         echo CHtml::hiddenField($name, $this->value, $this->htmlOptions);
         $value = $this->value;
         $valueText = $value && isset($this->data[$value]) ? $this->data[$value] : '&nbsp;';
     }
     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'), '&nbsp;');
     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 #4
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');
    }
 /**
  * Renders the widget. If there are no items, nothing will be rendered.
  * TODO: Reuse TbCollapse somehow
  */
 public function run()
 {
     $itemCount = count($this->items);
     if ($itemCount === 0) {
         return;
     }
     echo CHtml::openTag('div', $this->htmlOptions);
     foreach ($this->items as $k => $item) {
         $id = __CLASS__ . '_' . $this->id . '_' . $k;
         $contentId = $id . '_content';
         $linkOptions = array('class' => 'accordion-toggle episode-toggle', 'data-content-id' => $contentId, 'data-toggle' => 'collapse', 'data-parent' => $this->id);
         // Add content-url data attributes to the link when available
         if (isset($item['contentUrl'])) {
             $linkOptions['data-content-url'] = $item['contentUrl'];
         }
         // Render the contents of the heading
         $heading = $this->render('_seasonAccordionHeading', array('linkUrl' => '#' . $id, 'linkOptions' => $linkOptions, 'season' => $item['season']), true);
         $bodyOptions = array('class' => 'accordion-body collapse', 'id' => $id);
         if ($itemCount === 1) {
             TbHtml::addCssClass('in', $bodyOptions);
         }
         echo CHtml::openTag('div', array('class' => 'accordion-group'));
         echo CHtml::tag('div', array('class' => 'accordion-heading'), $heading);
         echo CHtml::openTag('div', $bodyOptions);
         echo CHtml::tag('div', array('id' => $contentId, 'class' => 'accordion-inner'), $item['content']);
         echo CHtml::closeTag('div');
         echo CHtml::closeTag('div');
     }
     echo CHtml::closeTag('div');
 }
 /**
  * @param null $label
  * @param array $options
  * @return string
  */
 public function getSubmitButtonRow($label = null, $options = array())
 {
     if (!isset($options['color'])) {
         $options['color'] = TbHtml::BUTTON_COLOR_PRIMARY;
     }
     return CHtml::tag('div', array('class' => 'form-actions'), TbHtml::submitButton($label, $options));
 }
Example #7
0
 /**
  * Renders the data items for the view.
  * Each item is corresponding to a single data model instance.
  */
 public function renderItems()
 {
     $thumbnails = array();
     $data = $this->dataProvider->getData();
     if (!empty($data)) {
         $owner = $this->getOwner();
         $render = $owner instanceof CController ? 'renderPartial' : 'render';
         foreach ($data as $i => $row) {
             $thumbnail = array();
             $d = $this->viewData;
             $d['index'] = $i;
             $d['data'] = $row;
             $d['widget'] = $this;
             $thumbnail['content'] = $owner->{$render}($this->itemView, $d, true);
             if (isset($this->url)) {
                 $thumbnail['url'] = $this->evaluateExpression($this->url, array('data' => $row));
             }
             if (isset($this->span)) {
                 $thumbnail['span'] = $this->span;
             }
             $thumbnails[] = $thumbnail;
         }
         echo TbHtml::thumbnails($thumbnails, $this->htmlOptions);
     } else {
         $this->renderEmptyText();
     }
 }
Example #8
0
 /**
  * Runs the widget.
  */
 public function run()
 {
     $links = $this->createPageLinks();
     if (!empty($links)) {
         echo TbHtml::pagination($links, $this->htmlOptions);
     }
 }
Example #9
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     $this->attachBehavior('ywplugin', array('class' => 'yiiwheels.behaviors.WhPlugin'));
     TbArray::defaultValue('autocomplete', 'off', $this->htmlOptions);
     TbHtml::addCssClass('grd-white', $this->htmlOptions);
     $this->initOptions();
 }
Example #10
0
 public function init()
 {
     parent::init();
     TbHtml::addCssClass('bfh-phone', $this->htmlOptions);
     $this->htmlOptions['data-format'] = $this->format;
     unset($this->htmlOptions['data-name'], $this->htmlOptions['data-value']);
 }
Example #11
0
 /**
  * Renders the filter cell content. Here we can provide HTML options for actual filter input
  */
 protected function renderFilterCellContent()
 {
     if (is_string($this->filter)) {
         echo $this->filter;
     } else {
         if ($this->filter !== false && $this->grid->filter !== null && $this->name !== null && strpos($this->name, '.') === false) {
             if ($this->filterInputOptions) {
                 $filterInputOptions = $this->filterInputOptions;
                 if (empty($filterInputOptions['id'])) {
                     $filterInputOptions['id'] = false;
                 }
             } else {
                 $filterInputOptions = array();
             }
             if (is_array($this->filter)) {
                 $filterInputOptions['prompt'] = '';
                 echo TbHtml::activeDropDownList($this->grid->filter, $this->name, $this->filter, $filterInputOptions);
             } else {
                 if ($this->filter === null) {
                     echo TbHtml::activeTextField($this->grid->filter, $this->name, $filterInputOptions);
                 }
             }
         } else {
             parent::renderFilterCellContent();
         }
     }
 }
 /**
  * Renders the form buttons
  */
 protected function renderButtons()
 {
     echo TbHtml::submitButton(Yii::t('FilterForm', 'Apply filter'), array('color' => TbHtml::BUTTON_COLOR_PRIMARY));
     $controller = Yii::app()->controller;
     // Disable when no filter is defined
     echo TbHtml::linkButton(Yii::t('FilterForm', 'Clear filter'), array('color' => TbHtml::BUTTON_COLOR_INFO, 'disabled' => $this->model->isEmpty(), 'url' => $controller->createUrl($controller->route)));
 }
 /**
  * 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 = TbHtml::popOption('url', $button, '#');
     if (strcmp($url, '#') !== 0) {
         $url = $this->evaluateExpression($url, array('data' => $data, 'row' => $row));
     }
     $imageUrl = TbHtml::popOption('imageUrl', $button, false);
     $label = TbHtml::popOption('label', $button, $id);
     $options = TbHtml::popOption('options', $button, array());
     $options = TbHtml::defaultOption('title', $label, $options);
     $options = TbHtml::defaultOption('rel', 'tooltip', $options);
     if ($icon = TbHtml::popOption('icon', $button, false)) {
         /* todo: not sure if we require this anymore */
         if (strpos($icon, 'icon') === false) {
             $icon = 'icon-' . implode(' icon-', explode(' ', $icon));
         }
         echo CHtml::link('<i class="' . $icon . '"></i>', $url, $options);
     } else {
         if ($imageUrl && is_string($imageUrl)) {
             echo CHtml::link(CHtml::image($imageUrl, $label), $url, $options);
         } else {
             echo CHtml::link($label, $url, $options);
         }
     }
 }
Example #14
0
 /**
  * Runs the widget.
  */
 public function run()
 {
     if (!empty($this->items)) {
         //echo TbHtml::nav($this->type, $this->items, $this->htmlOptions);
         echo TbHtml::nav($this->type, $this->items, $this->htmlOptions, $this->submenuHtmlOptions);
         //add submenuHtmlOptions parameter
     }
 }
Example #15
0
 /**
  * Renders the buttons in this form.
  * @return string the rendering result.
  */
 public function renderButtons()
 {
     $buttons = array();
     foreach ($this->getButtons() as $button) {
         $buttons[] = $this->renderElement($button);
     }
     return !empty($buttons) ? TbHtml::tag('div', array('class' => 'form-actions'), implode("\n", $buttons)) : '';
 }
Example #16
0
 /**
  * Widget's initialization method
  * @throws CException
  */
 public function init()
 {
     if (!isset($this->pluginOptions['country'])) {
         throw new CException(Yii::t('zii', '$pluginOptions["country"] cannot be blank.'));
     }
     $this->attachBehavior('ywplugin', array('class' => 'yiiwheels.behaviors.WhPlugin'));
     TbHtml::addCssClass('bfh-states', $this->htmlOptions);
 }
Example #17
0
 public function init()
 {
     parent::init();
     TbHtml::addCssClass('bfh-fonts', $this->htmlOptions);
     if (!isset($this->htmlOptions['data-font'])) {
         $this->htmlOptions['data-font'] = TbArray::popValue('data-value', $this->htmlOptions);
     }
     unset($this->htmlOptions['data-name'], $this->htmlOptions['data-value']);
 }
Example #18
0
 /**
  * Renders the data cell content.
  * @param integer $row the row number (zero-based).
  * @param mixed $data the data associated with the row.
  */
 protected function renderDataCellContent($row, $data)
 {
     /* @var $am CAuthManager|AuthBehavior */
     $am = Yii::app()->getAuthManager();
     $labelType = $this->active || $am->hasParent($this->itemName, $data['name']) || $am->hasChild($this->itemName, $data['name']) ? 'info' : '';
     /* @var $controller AuthItemController */
     $controller = $this->grid->getController();
     echo TbHtml::labelTb($controller->getItemTypeText($data['item']->type), array('color' => $labelType));
 }
 /**
  * Renders a text field with typeahead functionality based on the specified 
  * data.
  * @param CModel $model the model
  * @param string $attribute the attribute name
  * @param string $data JavaScript-encoded array containing the data for the 
  * typeahead
  * @param array $htmlOptions options to pass to the control group
  * @return string the HTML for the input
  */
 public function typeaheadFieldControlGroup($model, $attribute, $data, $htmlOptions = array())
 {
     // Generate a unique ID for this element
     CHtml::resolveNameID($model, $attribute, $htmlOptions);
     TbHtml::addCssClass('twitter-typeahead-input', $htmlOptions);
     $id = $htmlOptions['id'];
     Yii::app()->clientScript->registerScript($id, "\n\t\t\t\$('#{$id}').typeahead({name: '{$id}',local: {$data},limit: 10});\n\t\t", CClientScript::POS_READY);
     return $this->textFieldControlGroup($model, $attribute, $htmlOptions);
 }
Example #20
0
 public function init()
 {
     if (empty($this->country) && !isset($this->pluginOptions['country'])) {
         throw new CException('"$country" cannot be empty.');
     }
     $this->pluginOptions['country'] = TbArray::getValue('country', $this->pluginOptions, $this->country);
     parent::init();
     TbHtml::addCssClass('bfh-timezones', $this->htmlOptions);
     unset($this->htmlOptions['data-name']);
 }
 /**
  * Returns this button.
  * @return string the rendering result.
  */
 public function render()
 {
     $attributes = $this->attributes;
     $attributes['name'] = $this->name;
     if (isset(self::$coreTypes[$this->type])) {
         $type = self::$coreTypes[$this->type];
         return TbHtml::btn($type, $this->label, $attributes);
     } else {
         return $this->getParent()->getOwner()->widget($this->type, $attributes, true);
     }
 }
 /**
  * Add the update dialog to current page.
  */
 public function run()
 {
     $this->widget('bootstrap.widgets.TbModal', array('id' => 'myModal', 'header' => 'Modal Heading', 'content' => TbHtml::animatedProgressBar(99)));
     // Publish extension assets
     $assets = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('ext.modaldlg') . '/assets');
     // Register extension assets
     $cs = Yii::app()->getClientScript();
     $cs->registerScriptFile($assets . '/EModalDlg.js', CClientScript::POS_END);
     // Open update dialog the clicking target elements
     $cs->registerScript('eupdatedialog', "\n          jQuery( '{$this->target}' ).on( 'click', updateDialogOpen );", CClientScript::POS_END);
 }
 /**
  * Generates a nicely formatted help block, useful to explain what a form or 
  * a page does. Nothing is rendered if the "showHelpBlocks" setting is set 
  * to false.
  * @param string $content the block content
  * @return string the HTML for the help block
  */
 public static function helpBlock($content)
 {
     if (!Setting::getBoolean('showHelpBlocks')) {
         return;
     }
     $output = CHtml::openTag('p', array('class' => 'form-help'));
     $output .= TbHtml::icon(TbHtml::ICON_EXCLAMATION_SIGN);
     $output .= $content;
     $output .= CHtml::closeTag('p');
     return $output;
 }
 /**
  * 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 #25
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 TbHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
     } else {
         echo TbHtml::textField($name, $this->value, $this->htmlOptions);
     }
 }
Example #26
0
 /**
  * Widget's initialization method
  * @throws CException
  */
 public function init()
 {
     $this->attachBehavior('ywplugin', array('class' => 'yiiwheels.behaviors.WhPlugin'));
     TbHtml::addCssClass('bfh-phone', $this->htmlOptions);
     $this->htmlOptions['data-format'] = $this->format;
     if ($this->readOnly) {
         $this->htmlOptions['data-number'] = $this->hasModel() ? $this->model->{$this->attribute} : $this->value;
     } else {
         $this->pluginOptions['format'] = $this->format;
         $this->pluginOptions['value'] = $this->hasModel() ? $this->model->{$this->attribute} : $this->value;
     }
 }
Example #27
0
 /**
  * Renders the field if no selector has been provided
  */
 public function renderField()
 {
     if (null === $this->selector) {
         list($name, $id) = $this->resolveNameID();
         if ($this->hasModel()) {
             echo TbHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
         } else {
             echo TbHtml::textField($name, $this->value, $this->htmlOptions);
         }
         $this->setLocaleSettings();
     }
 }
Example #28
0
 /**
  * Renders the data cell content.
  * @param integer $row the row number (zero-based).
  * @param mixed $data the data associated with the row.
  */
 protected function renderDataCellContent($row, $data)
 {
     /* @var $am CAuthManager|AuthBehavior */
     $am = Yii::app()->getAuthManager();
     if ($am->hasParent($this->itemName, $data['name'])) {
         echo TbHtml::linkButton(TbHtml::icon(TbHtml::ICON_REMOVE), array('color' => TbHtml::BUTTON_COLOR_LINK, 'size' => TbHtml::BUTTON_SIZE_MINI, 'url' => array('removeParent', 'itemName' => $this->itemName, 'parentName' => $data['name']), 'rel' => 'tooltip', 'title' => Yii::t('AuthModule.main', 'Remove')));
     } else {
         if ($am->hasChild($this->itemName, $data['name'])) {
             echo TbHtml::linkButton(TbHtml::icon(TbHtml::ICON_REMOVE), array('color' => TbHtml::BUTTON_COLOR_LINK, 'size' => TbHtml::BUTTON_SIZE_MINI, 'url' => array('removeChild', 'itemName' => $this->itemName, 'childName' => $data['name']), 'rel' => 'tooltip', 'title' => Yii::t('AuthModule.main', 'Remove')));
         }
     }
 }
Example #29
0
 public function init()
 {
     if (empty($this->country)) {
         throw new CException('"$country" cannot be empty.');
     }
     $this->pluginOptions['country'] = $this->country;
     parent::init();
     TbHtml::addCssClass('bfh-states', $this->htmlOptions);
     if (!isset($this->htmlOptions['data-state'])) {
         $this->htmlOptions['data-state'] = TbArray::popValue('data-value', $this->htmlOptions);
     }
     unset($this->htmlOptions['data-name'], $this->htmlOptions['data-value']);
 }
Example #30
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     Yii::import('bootstrap.behaviors.TbWidget');
     $this->attachBehavior('tbWidget', new TbWidget());
     if (!isset($this->assetPath)) {
         $this->assetPath = Yii::getPathOfAlias('lib.bootstrap-wysihtml5');
     }
     if (!$this->bindPlugin) {
         $this->htmlOptions['data-plugin'] = 'wysihtml5';
         $this->htmlOptions['data-plugin-options'] = CJSON::encode($this->pluginOptions);
     }
     TbHtml::addCssStyle('width: ' . $this->width . 'px; height: ' . $this->height . 'px;', $this->htmlOptions);
 }