本文整理汇总了PHP中yii\helpers\Html::addCssClass方法的典型用法代码示例。如果您正苦于以下问题:PHP Html::addCssClass方法的具体用法?PHP Html::addCssClass怎么用?PHP Html::addCssClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\helpers\Html
的用法示例。
在下文中一共展示了Html::addCssClass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderItems
/**
* Renders menu items.
* @param array $items the menu items to be rendered
* @return string the rendering result.
* @throws InvalidConfigException if the label option is not specified in one of the items.
*/
protected function renderItems($items)
{
$lines = [];
foreach ($items as $i => $item) {
if (isset($item['visible']) && !$item['visible']) {
unset($items[$i]);
continue;
}
if (is_string($item)) {
$lines[] = $item;
continue;
}
if (!isset($item['title'])) {
throw new InvalidConfigException("The 'title' option is required.");
}
$title = $this->encode ? Html::encode($item['title']) : $item['title'];
$titleOptions = ArrayHelper::getValue($item, 'titleOptions', []);
Html::addCssClass($titleOptions, 'list-group-item-heading');
$titleCode = Html::tag('h4', $title, $titleOptions);
$description = $this->encode ? Html::encode($item['description']) : $item['description'];
$descriptionOptions = ArrayHelper::getValue($item, 'descriptionOptions', []);
Html::addCssClass($descriptionOptions, 'list-group-item-text');
$descriptionCode = Html::tag('p', $description, $descriptionOptions);
$linkOptions = ArrayHelper::getValue($item, 'linkOptions', []);
Html::addCssClass($linkOptions, 'list-group-item');
Html::addCssStyle($linkOptions, 'word-wrap: break-word');
if (isset($item['active']) && $item['active']) {
Html::addCssClass($linkOptions, 'active');
}
$linkOptions['tabindex'] = '-1';
$lines[] = Html::a($titleCode . "\n" . $descriptionCode, ArrayHelper::getValue($item, 'url', '#'), $linkOptions);
}
return Html::tag('div', implode("\n", $lines), $this->options);
}
示例2: run
public function run()
{
//$id = $this->getId();
Html::addCssClass($this->options, "form-control");
echo $this->getInput($this->type, $this->list);
$this->registerAssets();
}
示例3: renderReloader
protected function renderReloader()
{
$text = Html::tag('p', 'На изображении плохо видно буквы?');
$link = Html::tag('p', 'Нажмите сюда для обновления.', ['id' => 'verifycode-hint', 'class' => 'captcha-hint-link']);
Html::addCssClass($options, 'captcha-hint');
return Html::tag('div', $text . $link, $options);
}
示例4: run
public function run()
{
if (!$this->visible) {
return false;
}
if (($class = self::sizeToClass($this->size)) !== false) {
Html::addCssClass($this->options, $class);
}
Html::addCssClass($this->options, "btn-{$this->type}");
$label = $this->encodeLabel ? Html::encode($this->label) : $this->label;
if (isset($this->icon)) {
$label = "<i class='glyphicon glyphicon-{$this->icon}'></i> " . $label;
}
if (isset($this->url)) {
$this->tagName = 'a';
$this->options['role'] = 'button';
$this->options['href'] = Url::to($this->url);
if ($this->disabled) {
Html::addCssClass($this->options, 'disabled');
}
} else {
if ($this->disabled) {
$this->options['disabled'] = 'disabled';
}
}
if ($this->block) {
Html::addCssClass($this->options, 'btn-block');
}
$html = Html::tag($this->tagName, $label, $this->options);
echo $html;
$this->registerPlugin('button');
}
示例5: init
public function init()
{
parent::init();
Html::addCssClass($this->options, 'ui message');
if ($this->icon) {
Html::addCssClass($this->options, self::TYPE_ICON);
}
if ($this->hidden) {
Html::addCssClass($this->options, self::TYPE_HIDDEN);
}
if ($this->visible) {
Html::addCssClass($this->options, self::TYPE_VISIBLE);
}
if ($this->floating) {
Html::addCssClass($this->options, self::TYPE_FLOATING);
}
if ($this->compact) {
Html::addCssClass($this->options, self::TYPE_COMPACT);
}
if ($this->attached) {
Html::addCssClass($this->options, self::TYPE_ATTACHED);
}
if ($this->size) {
Html::addCssClass($this->options, $this->size);
}
if ($this->color) {
Html::addCssClass($this->options, $this->color);
}
if ($this->type) {
Html::addCssClass($this->options, $this->type);
}
echo Html::beginTag('div', $this->options);
}
示例6: run
/**
* @inheritdoc
*/
public function run()
{
$this->_msgCat = 'kvcolor';
if (!isset($this->type)) {
$this->type = $this->useNative ? 'color' : 'text';
}
$this->width = '60px';
$this->initI18N(__DIR__);
if (empty($this->html5Container['id'])) {
$this->html5Container['id'] = $this->options['id'] . '-cont';
}
if ($this->type === 'text') {
Html::addCssStyle($this->html5Options, 'display:none');
if ($this->pluginLoading) {
Html::addCssClass($this->html5Container, 'kv-center-loading');
}
}
$this->html5Options['value'] = $this->hasModel() ? Html::getAttributeValue($this->model, $this->attribute) : $this->value;
if (substr($this->language, 0, 2) !== 'en') {
$this->_defaultOptions += ['cancelText' => Yii::t('kvcolor', 'cancel'), 'chooseText' => Yii::t('kvcolor', 'choose'), 'clearText' => Yii::t('kvcolor', 'Clear Color Selection'), 'noColorSelectedText' => Yii::t('kvcolor', 'No Color Selected'), 'togglePaletteMoreText' => Yii::t('kvcolor', 'more'), 'togglePaletteLessText' => Yii::t('kvcolor', 'less')];
}
Html::addCssClass($this->containerOptions, 'spectrum-group');
Html::addCssClass($this->html5Options, 'spectrum-source');
Html::addCssClass($this->options, 'spectrum-input');
if (!$this->useNative) {
Html::addCssClass($this->html5Container, 'input-group-sp');
$this->pluginOptions = array_replace_recursive($this->_defaultOptions, $this->pluginOptions);
}
$this->initInput();
$this->registerColorInput();
}
示例7: renderButton
/**
* Generates the button dropdown.
* @return string the rendering result.
*/
protected function renderButton()
{
Html::addCssClass($this->options, 'btn');
$label = $this->label;
if ($this->encodeLabel) {
$label = Html::encode($label);
}
$options = $this->options;
$splitButton = '';
$caretHtml = $this->caretHtml ? $this->caretHtml : '<span class="caret"></span>';
if ($this->split) {
$options = $this->options;
$this->options['data-toggle'] = 'dropdown';
Html::addCssClass($this->options, 'dropdown-toggle');
$splitButton = Button::widget(['label' => $this->caretHtml ? $this->caretHtml : '<span class="caret"></span>', 'encodeLabel' => false, 'options' => $this->options, 'view' => $this->getView()]);
} else {
$label .= ' ' . $this->caretHtml ? $this->caretHtml : '<span class="caret"></span>';
$options = $this->options;
if (!isset($options['href'])) {
$options['href'] = '#';
}
Html::addCssClass($options, 'dropdown-toggle');
$options['data-toggle'] = 'dropdown';
}
return Button::widget(['tagName' => $this->tagName, 'label' => $label, 'options' => $options, 'encodeLabel' => false, 'view' => $this->getView()]) . "\n" . $splitButton;
}
示例8: renderItem
public function renderItem($header, $item, $index)
{
if (array_key_exists('content', $item)) {
$id = $this->options['id'] . '-collapse' . $index;
$options = ArrayHelper::getValue($item, 'contentOptions', []);
$options['id'] = $id;
$expanded = false;
if (array_key_exists('expanded', $item)) {
$expanded = $item['expanded'];
}
Html::addCssClass($options, 'panel-collapse collapse' . ($expanded ? ' in' : ''));
$encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabels;
if ($encodeLabel) {
$header = Html::encode($header);
}
$headerToggle = Html::a($header, '#' . $id, ['class' => 'collapse-toggle', 'data-toggle' => 'collapse', 'data-parent' => '#' . $this->options['id']]) . "\n";
$header = Html::tag('h4', $headerToggle, ['class' => 'panel-title']);
if (is_string($item['content'])) {
$content = Html::tag('div', $item['content'], ['class' => 'panel-body']) . "\n";
} elseif (is_array($item['content'])) {
$content = Html::ul($item['content'], ['class' => 'list-group', 'itemOptions' => ['class' => 'list-group-item'], 'encode' => false]) . "\n";
if (isset($item['footer'])) {
$content .= Html::tag('div', $item['footer'], ['class' => 'panel-footer']) . "\n";
}
} else {
throw new InvalidConfigException('The "content" option should be a string or array.');
}
} else {
throw new InvalidConfigException('The "content" option is required.');
}
$group = [];
$group[] = Html::tag('div', $header, ['class' => 'panel-heading']);
$group[] = Html::tag('div', $content, $options);
return implode("\n", $group);
}
示例9: init
public function init()
{
parent::init();
$clientValue = self::toClientFormat($this->model->{$this->attribute});
if ($clientValue === false) {
throw new InvalidConfigException();
}
$this->model->{$this->attribute} = $clientValue;
if (!isset($this->select2Config['pluginOptions']['allowClear'])) {
$this->select2Config['pluginOptions']['placeholder'] = '';
$this->select2Config['pluginOptions']['allowClear'] = true;
}
if (!isset($this->select2Config['options'])) {
$this->select2Config['options'] = null;
}
$this->setDataTarget($this->select2Config['options']);
Html::addCssClass($this->select2Config['options'], 'combowidget-select2');
if (!isset($this->select2Config['value'])) {
$this->select2Config['value'] = $this->inputValue(self::STATE_LIST);
}
// ugly workaround (InputWidget must have name or model)
$this->select2Config['name'] = Html::getInputId($this->model, $this->attribute) . '-ignored-combowidget-select2';
$this->setDataTarget($this->switchOptions);
Html::addCssClass($this->switchOptions, 'combowidget-switch');
$this->setDataTarget($this->textInputOptions);
Html::addCssClass($this->textInputOptions, 'combowidget-textinput');
}
示例10: prepareOptions
public function prepareOptions()
{
$defaultItem = $this->getDefaultItem();
$this->options['item'] = ArrayHelper::getValue($this->options, 'item', $defaultItem);
$this->options['itemOptions'] = $this->listOptions;
Html::addCssClass($this->options, 'grouped inline fields');
}
示例11: init
public function init()
{
parent::init();
Html::addCssClass($this->htmlOptions, 'custom-dz');
/** @var Image[] $files */
$files = Image::find()->where(['and', 'object_id = :objectId', 'object_model_id = :modelId'], [':objectId' => $this->objectId, ':modelId' => $this->modelId])->orderBy(['sort_order' => SORT_ASC])->all();
/** Image $file */
foreach ($files as $file) {
$thumbnail_src = $file->getThumbnail('80x80');
$this->storedFiles[] = ['id' => $file->id, 'name' => $file->filename, 'file' => $file->file, 'thumbnail' => $thumbnail_src, 'description' => $file->image_description];
}
$params = ArrayHelper::merge(isset($this->options['params']) ? $this->options['params'] : [], ['objectId' => $this->objectId, 'modelId' => $this->modelId]);
$this->sortable = true;
$this->options = ArrayHelper::merge($this->options, ['acceptedFiles' => 'image/*', 'params' => $params, 'previewTemplate' => '<div class="file-row">
' . Html::input('hidden', 'id[]') . Html::input('hidden', 'file[]') . '
<!-- This is used as the file preview template -->
<div>
<span class="preview"><img style="width: 80px; height: 80px;" data-dz-thumbnail /></span>
</div>
<div>
<p class="name" data-dz-name></p>
<div class="dz-error-message"><span data-dz-errormessage></span></div>
</div>
<div class="description">
' . Html::textarea('description', '', ['style' => 'width: 100%; min-width: 80px; height: 80px;']) . '
</div>
<div>
<p class="size" data-dz-size></p>
<div class="dz-progress progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0">
<div class="progress-bar progress-bar-success" style="width:0%;" data-dz-uploadprogress></div>
</div>
<div class="dz-success-mark"><span>✔</span> OK</div>
<div class="dz-error-mark"><span>✘</span> ERROR</div>
</div>
<div>
<button data-dz-remove class="btn btn-danger delete">
<i class="fa fa-trash-o"></i>
<span>' . Yii::t('app', 'Delete') . '</span>
</button>
</div>
</div>', 'thumbnailWidth' => '80', 'thumbnailHeight' => '80', 'previewsContainer' => "#{$this->id}"]);
$this->eventHandlers = ['removedfile' => 'function(file) {
jQuery.get(
"' . Url::toRoute($this->removeUrl) . '",
{
"id" : jQuery(file.previewElement).find("[name=\\"id[]\\"]").val(),
"filename" : jQuery(file.previewElement).data("filename")
}
).done(function (data) { return data });
}', 'success' => 'function(file, response) {
response = jQuery.parseJSON(response);
jQuery(file.previewElement).find("[data-dz-name]").text(response.filename);
jQuery(file.previewElement).data("filename", response.filename);
jQuery(file.previewElement).find("[name=\\"id[]\\"]").val(response.afterUpload.id);
jQuery(file.previewElement).find("[name=\\"file[]\\"]").val(response.afterUpload.file);
jQuery(file.previewElement).find(".description textarea").attr("name", "description["+response.afterUpload.id+"]");
}', 'complete' => 'function(file) {
jQuery(file.previewElement).removeClass("dz-processing");
}'];
}
示例12: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
$formatter = Yii::$app->getFormatter();
if (is_null($this->dateFormat)) {
$this->dateFormat = $formatter->dateFormat;
if (is_null($this->dateFormat)) {
$this->dateFormat = 'medium';
}
}
if (is_null($this->timeFormat)) {
$this->timeFormat = $formatter->timeFormat;
if (is_null($this->timeFormat)) {
$this->timeFormat = 'medium';
}
}
if (is_null($this->altDateFormat)) {
$this->altDateFormat = 'yyyy-MM-dd';
}
if (is_null($this->altTimeFormat)) {
$this->altTimeFormat = 'HH:mm:ss';
}
Html::addCssClass($this->options, 'form-control');
$this->altOptions['id'] = $this->options['id'] . '-alt';
$this->clientOptions = array_merge(array_diff_assoc(['numberOfMonths' => $this->numberOfMonths, 'showButtonPanel' => $this->showButtonPanel], get_class_vars(__CLASS__)), $this->clientOptions, ['dateFormat' => FormatConverter::convertDatePhpOrIcuToJui($this->dateFormat), 'separator' => static::SEPARATOR, 'timeFormat' => FormatConverter::convertDatePhpOrIcuToJui($this->timeFormat, 'time'), 'altField' => '#' . $this->altOptions['id'], 'altFieldTimeOnly' => false, 'altFormat' => FormatConverter::convertDatePhpOrIcuToJui($this->altDateFormat), 'altSeparator' => static::SEPARATOR, 'altTimeFormat' => FormatConverter::convertDatePhpOrIcuToJui($this->altTimeFormat, 'time')]);
if (array_key_exists('readonly', $this->options) && $this->options['readonly']) {
if (!array_key_exists('beforeShow', $this->clientOptions)) {
$this->clientOptions['beforeShow'] = new JsExpression('function (input, inst) { return false; }');
}
}
}
示例13: init
public function init()
{
parent::init();
$this->options['id'] = $this->id;
Html::addCssClass($this->options, 'sx-tree');
$this->_beginPjax();
}
示例14: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if (!empty($this->size)) {
Html::addCssClass($this->options, 'btn-group-' . $this->size);
}
}
示例15: 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;
Html::addCssClass($this->options, $this->size);
Html::addCssClass($this->options, 'material-icons');
}