本文整理汇总了PHP中Html::addCssClass方法的典型用法代码示例。如果您正苦于以下问题:PHP Html::addCssClass方法的具体用法?PHP Html::addCssClass怎么用?PHP Html::addCssClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Html
的用法示例。
在下文中一共展示了Html::addCssClass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
Html::addCssClass($this->options, ['widget' => 'info-box']);
$iconOptions = ['class' => 'info-box-icon'];
if ($this->type === self::COLORED_ICON) {
Html::addCssClass($iconOptions, 'bg-' . $this->color);
} else {
Html::addCssClass($this->options, 'bg-' . $this->color);
}
echo Html::beginTag('div', $this->options);
echo Html::tag('span', FA::icon($this->icon), $iconOptions);
echo '<div class="info-box-content">';
if (!empty($this->contents)) {
foreach ($this->contents as $content) {
if (is_array($content)) {
$type = ArrayHelper::getValue($content, 'type', 'text');
$text = ArrayHelper::getValue($content, 'text', '');
if (in_array($type, ['text', 'number'])) {
echo Html::tag('span', $text, ['class' => 'info-box-' . $type]);
} elseif ($type == 'progress') {
$value = ArrayHelper::getValue($content, 'value', $text);
echo '<div class="progress">';
echo Html::tag('div', '', ['class' => 'progress-bar', 'style' => ['width' => $value . '%']]);
echo '</div>';
} else {
echo Html::tag('span', $text, ['class' => $type]);
}
} else {
echo $content;
}
}
}
}
示例2: fLabel
/**
* Generates a label.
*
* @param string $content the label content
* @param string $type the label type - default is empty
* - is one of [[self::TYPE_SECONDARY]], [[self::TYPE_SUCCESS]], [[self::TYPE_WARNING]], [[self::TYPE_ALERT]]
* @param string $border the border type - defaults is empty
* - is one of [[self::BORDER_RADIUS]], [[self::BORDER_ROUND]]
* @param array $options html options for the label container
* @param string $tag the label container tag - defaults to 'span'
*
* Example(s):
* ~~~
* echo Html::fLabel('Regular');
* echo Html::fLabel('Primary', Html::TYPE_PRIMARY);
* echo Html::fLabel('Success round', Html::TYPE_SUCCESS, Html::BORDER_ROUND);
* ~~~
*
* @see http://getbootstrap.com/components/#labels
*/
public static function fLabel($content, $type = '', $border = '', $options = [], $tag = 'span')
{
Html::addCssClass($options, 'label');
Html::addCssClass($options, $type);
Html::addCssClass($options, $border);
return static::tag($tag, $content, $options);
}
示例3: run
public function run()
{
AdminlteAsset::register($this->getView());
Html::addCssClass($this->options, ['widget' => 'progress']);
if ($this->vertical) {
Html::addCssClass($this->options, 'vertical');
}
if (!empty($this->size)) {
Html::addCssClass($this->options, $this->size);
}
$barOptions = ['class' => 'progress-bar'];
if (!empty($this->type)) {
Html::addCssClass($barOptions, 'progress-bar-' . $this->type);
}
if ($this->striped) {
Html::addCssClass($barOptions, 'progress-bar-striped');
}
$barOptions['style']['width'] = $this->value . '%';
if (empty($this->text)) {
$text = '';
} else {
$text = Html::tag('span', $text, ['class' => 'sr-only']);
}
return Html::tag('div', Html::tag('div', $text, $barOptions), $this->options);
}
示例4: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
Html::addCssClass($this->options, ['widget' => 'box']);
if ($this->solid) {
Html::addCssClass($this->options, 'box-solid');
if ($this->variant === null) {
Html::addCssClass($this->options, 'box-default');
}
}
if ($this->variant !== null) {
Html::addCssClass($this->options, 'box-' . $this->variant);
}
echo Html::beginTag('div', $this->options);
// header
if ($this->header || !empty($this->boxTools)) {
echo '<div class="box-header with-border">';
echo Html::tag('h3', $this->header, ['class' => 'box-title']);
}
// box-tools
if (!empty($this->boxTools)) {
echo Html::beginTag('div', ['class' => 'box-tools pull-right']);
foreach ($this->boxTools as $toolbox) {
if (is_array($toolbox)) {
$tag = 'span';
if (($widget = ArrayHelper::getValue($toolbox, 'button')) !== null) {
$tag = 'button';
$toolbox['options']['data-widget'] = $widget;
Html::addCssClass($toolbox['options'], 'btn btn-box-tool');
} elseif (($label = ArrayHelper::getValue($toolbox, 'label')) !== null) {
Html::addCssClass($toolbox['options'], 'label label-' . $label);
} elseif (($badge = ArrayHelper::getValue($toolbox, 'badge')) !== null) {
Html::addCssClass($toolbox['options'], 'badge bg-' . $badge);
}
$tag = ArrayHelper::getValue($toolbox, 'tag', $tag);
$options = ArrayHelper::getValue($toolbox, 'options', []);
$text = ArrayHelper::getValue($toolbox, 'text', '');
$icon = ArrayHelper::getValue($toolbox, 'icon');
if ($icon !== null) {
$text .= ' ' . FA::icon($icon);
}
if (($tooltip = ArrayHelper::getValue($toolbox, 'tooltip')) !== null) {
$options['data-toggle'] = 'tooltip';
$options['title'] = $tooltip;
}
echo Html::tag($tag, $text, $options);
} else {
echo $toolbox;
}
}
echo '</div>';
}
if ($this->header || !empty($this->boxTools)) {
echo '</div>';
}
// body
echo '<div class="box-body">';
echo $this->body;
}
示例5: init
/**
* Initializes the widget.
* If you override this method, make sure you call the parent implementation first.
*/
public function init()
{
parent::init();
$this->clientOptions = false;
if ($this->defaultClass) {
Html::addCssClass($this->options, $this->defaultClass);
}
}
示例6: icon
/**
* Fetch the icon for a icon identifier
*
* @param string $id suffix the icon suffix name
* @param array $options the icon HTML attributes
* @param string $prefix the icon css prefix name
*
* @return string the parsed icon
*/
public function icon($id, $options = ['style' => 'margin-right:5px'], $prefix = null)
{
if ($prefix === null) {
$prefix = $this->prefix;
}
Html::addCssClass($options, explode(' ', $prefix . $id));
return Html::tag('i', '', $options);
}
示例7: init
public function init()
{
parent::init();
Html::addCssClass($this->options, ['weui_grid']);
if (!isset($this->options['href'])) {
$this->options['href'] = "javascript:;";
}
}
示例8: init
/**
* @inheritdoc
*/
public function init()
{
if (!in_array($this->layout, ['default', 'horizontal', 'inline'])) {
throw new InvalidConfigException('Invalid layout type: ' . $this->layout);
}
if ($this->layout !== 'default') {
Html::addCssClass($this->options, 'form-' . $this->layout);
}
parent::init();
}
示例9: inlineList
/**
* Renders and inline list
* @param array $items the items to render
* @param array $htmlOptions the HTML attributes
* @return string the generated list
*/
public static function inlineList($items, $htmlOptions = array())
{
$listItems = array();
Html::addCssClass($htmlOptions, 'inline-list');
foreach ($items as $item) {
$listItems[] = \CHtml::tag('li', $htmlOptions, $item);
}
if (!empty($listItems)) {
return \CHtml::tag('ul', $htmlOptions, implode("\n", $listItems));
}
}
示例10: checkbox
/**
* @inheritdoc
*/
public static function checkbox($name, $checked = false, $options = [])
{
$options['checked'] = (bool) $checked;
$value = array_key_exists('value', $options) ? $options['value'] : '1';
if (isset($options['uncheck'])) {
// add a hidden field so that if the checkbox is not selected, it still submits a value
$hidden = static::hiddenInput($name, $options['uncheck']);
unset($options['uncheck']);
} else {
$hidden = '';
}
if (isset($options['label'])) {
$label = $options['label'];
$labelOptions = isset($options['labelOptions']) ? $options['labelOptions'] : [];
$divOptions = isset($options['divOptions']) ? $options['divOptions'] : [];
Html::addCssClass($divOptions, 'checkbox');
unset($options['label'], $options['labelOptions'], $options['divOptions']);
$options['id'] = str_replace(['[]', '][', '[', ']', ' '], ['', '-', '-', '', '-'], $name) . '-' . $value;
$content = Html::tag('div', static::input('checkbox', $name, $value, $options) . static::label($label, $options['id'], $labelOptions), $divOptions);
return $hidden . $content;
} else {
return $hidden . static::input('checkbox', $name, $value, $options);
}
}
示例11: 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);
}
}
示例12: label
/**
* @inheritdoc
*/
public function label($label = null, $options = [])
{
if (is_bool($label)) {
$this->enableLabel = $label;
if ($label === false && $this->form->layout === 'horizontal') {
Html::addCssClass($this->wrapperOptions, $this->horizontalCssClasses['offset']);
}
} else {
$this->enableLabel = true;
$this->renderLabelParts($label, $options);
parent::label($label, $options);
}
return $this;
}
示例13: 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;
}
示例14: renderAlert
/**
* Render single alert.
* @param string $tag Alert html tag.
* @param string $type Alert type.
* @param string $alert Alert text.
* @param array $options Alert type specific options.
*/
protected function renderAlert($tag, $type, $alert, array $options)
{
$classes = ['alert', 'in', 'alert-' . $type];
if ($options['block']) {
$classes[] = 'alert-block';
}
if ($options['fade']) {
$classes[] = 'fade';
}
Html::addCssClass($options['htmlOptions'], implode(' ', $classes));
echo Html::openTag($tag, $options['htmlOptions']);
if ($options['closeText'] !== false) {
echo '<a href="#" class="close" data-dismiss="alert">' . $options['closeText'] . '</a>';
}
echo $alert;
echo Html::closeTag($tag);
}
示例15: init
/**
* Initializes the widget.
*/
public function init()
{
parent::init();
$this->clientOptions = false;
if (empty($this->options['class'])) {
Html::addCssClass($this->options, ['navbar', 'navbar-default']);
} else {
Html::addCssClass($this->options, ['widget' => 'navbar']);
}
if (empty($this->options['role'])) {
$this->options['role'] = 'navigation';
}
$options = $this->options;
$tag = ArrayHelper::remove($options, 'tag', 'nav');
echo Html::beginTag($tag, $options);
if ($this->renderInnerContainer) {
if (!isset($this->innerContainerOptions['class'])) {
Html::addCssClass($this->innerContainerOptions, 'container');
}
echo Html::beginTag('div', $this->innerContainerOptions);
}
echo Html::beginTag('div', ['class' => 'navbar-header']);
if (!isset($this->containerOptions['id'])) {
$this->containerOptions['id'] = "{$this->options['id']}-collapse";
}
echo $this->renderToggleButton();
if ($this->brandLabel !== false) {
Html::addCssClass($this->brandOptions, ['widget' => 'navbar-brand']);
echo Html::a($this->brandLabel, $this->brandUrl === false ? Yii::$app->homeUrl : $this->brandUrl, $this->brandOptions);
}
echo Html::endTag('div');
Html::addCssClass($this->containerOptions, ['collapse' => 'collapse', 'widget' => 'navbar-collapse']);
$options = $this->containerOptions;
$tag = ArrayHelper::remove($options, 'tag', 'div');
echo Html::beginTag($tag, $options);
}