本文整理汇总了PHP中yii\bootstrap\Html::addCssClass方法的典型用法代码示例。如果您正苦于以下问题:PHP Html::addCssClass方法的具体用法?PHP Html::addCssClass怎么用?PHP Html::addCssClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\bootstrap\Html
的用法示例。
在下文中一共展示了Html::addCssClass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$this->clientOptions['treeViewId'] = $this->treeViewId;
$this->registerWidget();
\yii\helpers\Html::addCssClass($this->options, 'execut-tree-filter-input');
$inputOptions = $this->inputOptions;
Html::addCssClass($inputOptions, 'form-control');
$inputOptions['autocomplete'] = 'off';
echo $this->_renderContainer(Html::input('text', 'search', null, $inputOptions) . '<span class="close" title="Clear search results">×</span>');
}
示例2: renderButton
/**
* Generates the button dropdown.
* @return string the rendering result.
*/
protected function renderButton()
{
// Html::addCssClass($this->options, ['widget' => 'btn']);
$label = $this->label;
$options = $this->options;
if (!isset($options['href'])) {
$options['href'] = '#';
}
Html::addCssClass($options, ['toggle' => 'dropdown-toggle']);
$options['data-toggle'] = 'dropdown';
return Html::tag($this->tagName, $label, $options) . "\n";
}
示例3: run
/**
* @inheritdoc
*/
public function run()
{
parent::run();
// TODO: Change the autogenerated stub
if (!empty($this->country)) {
$class = 'flag-icon flag-icon-' . $this->country;
Html::addCssClass($this->options, $class);
if ($this->squared) {
Html::addCssClass($this->options, 'flag-icon-squared');
}
$this->register();
echo Html::beginTag('span', $this->options);
echo Html::endTag('span');
}
}
示例4: run
/**
* @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();
}
示例5: run
/**
* @inheritdoc
*/
public function run()
{
//register assets
$this->registerPlugin('button');
AjaxToggleButtonAsset::register($this->getView());
//prepare ajax params
$params = [];
foreach ($this->model->primaryKey() as $pkCol) {
$params[$pkCol] = $this->model->{$pkCol};
}
Html::addCssClass($this->options, 'widget-ajax-button');
$this->options['data']['current-value'] = $this->model->{$this->booleanAttribute};
$this->options['data']['pjax'] = 0;
$this->options['data']['boolean-format'] = $this->booleanFormat;
$this->options['data']['ajax-params'] = $params;
$this->options['data']['ajax-method'] = $this->ajaxMethod;
return Html::a($this->createLabel(), $this->ajaxUrl, $this->options);
}
示例6: isChildActive
/**
* Check to see if a child item is active optionally activating the parent.
* @param array $items @see items
* @param boolean $active should the parent be active too
* @return array @see items
*/
protected function isChildActive($items, &$active)
{
foreach ($items as $i => $child) {
if (ArrayHelper::remove($items[$i], 'active', false) || $this->isItemActive($child)) {
Html::addCssClass($items[$i]['options'], 'active');
if ($this->activateParents) {
$active = true;
}
}
}
return $items;
}
示例7: addClass
public function addClass($class)
{
BaseHtml::addCssClass($this->options, $class);
return $this;
}
示例8: square
/**
* Creates a squared flag icon
* @return self
*/
public function square()
{
Html::addCssClass($this->options, 'flag-icon-squared');
return $this;
}
示例9: getFilterError
protected function getFilterError()
{
$model = $this->grid->filterModel;
if ($model->hasErrors($this->attribute)) {
Html::addCssClass($this->filterOptions, 'has-error');
return ' ' . Html::error($model, $this->attribute, $this->grid->filterErrorOptions);
} else {
return '';
}
}
示例10: renderStatisticContent
/**
* Return statistic content
* @return string
*/
public function renderStatisticContent()
{
$content = '';
if (!empty($this->statisticColumns) && is_array($this->statisticColumns)) {
$numberColumn = count($this->statisticColumns);
foreach ($this->statisticColumns as $column) {
$header = ArrayHelper::getValue($column, 'header', 'Orders');
$time = ArrayHelper::getValue($column, 'time', 'Annual');
$percent = ArrayHelper::getValue($column, 'percent', '85%');
$totalStatistic = ArrayHelper::getValue($column, 'totalStatistic', '40 886,200');
$smallHeader = ArrayHelper::getValue($column, 'smallHeader', 'New orders');
// Options element in statistic
$headerOptions = ArrayHelper::getValue($column, 'headerOptions', []);
$timeOptions = ArrayHelper::getValue($column, 'timeOptions', []);
$percentOptions = ArrayHelper::getValue($column, 'percentOptions', []);
$totalStatisticOptions = ArrayHelper::getValue($column, 'totalStatisticOptions', []);
$smallHeaderOptions = ArrayHelper::getValue($column, 'smallHeaderOptions', []);
// Replace input
if ($header !== false) {
Html::addCssClass($headerOptions, '');
$header = Html::tag('h5', $header, $headerOptions);
}
if ($time !== false) {
if (empty($timeOptions['class'])) {
$timeOptions['class'] = 'label-success';
}
Html::addCssClass($timeOptions, 'label pull-right');
$time = Html::tag('span', $time, $timeOptions);
}
if ($percent !== false) {
Html::addCssClass($percentOptions, 'stat-percent font-bold text-success');
$percent = Html::tag('div', $percent . ' <i class="fa fa-bolt"></i>', $percentOptions);
}
if ($totalStatistic !== false) {
Html::addCssClass($totalStatisticOptions, 'no-margins');
$totalStatistic = Html::tag('h1', $totalStatistic, $totalStatisticOptions);
}
if ($smallHeader !== false) {
Html::addCssClass($smallHeaderOptions, '');
$smallHeader = Html::tag('small', $smallHeader, $smallHeaderOptions);
}
$statistic = strtr($this->statisticTemplate, ['{header}' => $header, '{time}' => $time, '{totalStatistic}' => $totalStatistic, '{percent}' => $percent, '{smallHeader}' => $smallHeader]);
$content .= Html::tag('div', $statistic, ['class' => 'col-lg-' . round(12 / $numberColumn)]);
}
}
return $content;
}
示例11: renderItems
/**
* Renders menu items.
*
* @param array $items the menu items to be rendered
* @param array $options the container HTML attributes
* @return string the rendering result.
* @throws InvalidConfigException if the label option is not specified in one of the items.
*/
protected function renderItems($items, $options = [])
{
$lines = [];
foreach ($items as $i => $item) {
if (isset($item['visible']) && !$item['visible']) {
unset($items[$i]);
continue;
}
if (is_string($item)) {
$lines[] = $item;
continue;
}
if (!array_key_exists('label', $item)) {
throw new InvalidConfigException("The 'label' option is required.");
}
$encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabels;
$label = $encodeLabel ? Html::encode($item['label']) : $item['label'];
$itemOptions = ArrayHelper::getValue($item, 'options', []);
$icon = ArrayHelper::getValue($item, 'icon', '');
$linkOptions = ArrayHelper::getValue($item, 'linkOptions', []);
$linkOptions['tabindex'] = '-1';
$url = array_key_exists('url', $item) ? $item['url'] : null;
if (!empty($icon)) {
$icon = Html::tag('i', '', ['class' => $icon]);
}
if (empty($item['items'])) {
if ($url === null) {
$content = $label;
Html::addCssClass($itemOptions, 'dropdown-header');
} else {
$content = Html::a($icon . $label, $url, $linkOptions);
}
} else {
$submenuOptions = $options;
unset($submenuOptions['id']);
$content = Html::a($label, $url === null ? '#' : $url, $linkOptions) . $this->renderItems($item['items'], $submenuOptions);
Html::addCssClass($itemOptions, 'dropdown-submenu');
}
$lines[] = Html::tag('li', $content, $itemOptions);
}
return Html::tag('ul', implode("\n", $lines), $options);
}
示例12: initOptions
/**
* Initializes the widget options.
* This method sets the default values for various options.
*/
protected function initOptions()
{
Html::addCssClass($this->options, ['alert', 'fade', 'in']);
if ($this->closeButton !== false) {
$this->closeButton = array_merge(['data-dismiss' => 'alert', 'aria-hidden' => 'true', 'class' => 'close'], $this->closeButton);
}
}
示例13: renderItem
/**
* Renders single item.
* @param array $item item configuration.
* @return string rendered HTML
*/
protected function renderItem($item)
{
if (isset($item[0])) {
$url = $item;
$options = [];
} else {
$url = $item['url'];
$options = $item;
unset($options['url']);
}
// label :
if (isset($options['label'])) {
$label = $options['label'];
unset($options['label']);
} else {
$label = $this->detectLabel($url);
}
if (isset($options['encode'])) {
$encodeLabel = $options['encode'];
unset($options['encode']);
} else {
$encodeLabel = $this->encodeLabels;
}
if ($encodeLabel) {
$label = Html::encode($label);
}
// icon :
if (isset($options['icon'])) {
$icon = $options['icon'];
unset($options['icon']);
} else {
$icon = $this->detectIcon($url);
}
if ($icon) {
$label = Html::icon($icon) . ' ' . $label;
}
// CSS class :
if (isset($options['class'])) {
Html::addCssClass($options, ['widget' => 'btn']);
} else {
$options['class'] = ['btn', $this->detectClass($url)];
}
if (!isset($options['data'])) {
$options['data'] = $this->detectData($url);
}
return Html::a($label, $url, $options);
}
示例14: run
/**
* @inheritdoc
*/
public function run()
{
//register assets
$this->registerPlugin('button');
AjaxToggleButtonAsset::register($this->getView());
//prepare ajax params
$params = [];
foreach ($this->model->primaryKey() as $pkCol) {
$params[$pkCol] = $this->model->{$pkCol};
}
Html::addCssClass($this->options, 'widget-ajax-button');
if ($this->model->{$this->booleanAttribute}) {
Html::removeCssClass($this->options, $this->buttonClassOff);
Html::addCssClass($this->options, $this->buttonClassOn);
} else {
Html::removeCssClass($this->options, $this->buttonClassOn);
Html::addCssClass($this->options, $this->buttonClassOff);
}
$this->options['data']['current-value'] = $this->model->{$this->booleanAttribute};
$this->options['data']['pjax'] = 0;
$this->options['data']['boolean-format'] = $this->booleanFormat;
$this->options['data']['ajax-params'] = $params;
$this->options['data']['ajax-method'] = $this->ajaxMethod;
$this->options['data']['event-success'] = $this->jsEventSuccess;
$this->options['data']['event-error'] = $this->jsEventError;
$this->options['data']['class-on'] = $this->buttonClassOn;
$this->options['data']['class-off'] = $this->buttonClassOff;
return Html::a($this->createLabel(), $this->ajaxUrl, $this->options);
}
示例15: icon
/**
* @return self
*/
public function icon()
{
Html::removeCssClass($this->options, self::BTN_BLOCK);
Html::removeCssClass($this->options, self::BTN_SOCIAL);
Html::addCssClass($this->options, self::BTN_SOCIAL_ICON);
$this->caption = $this->serviceIcon;
return $this;
}