当前位置: 首页>>代码示例>>PHP>>正文


PHP Html::addCssClass方法代码示例

本文整理汇总了PHP中kartik\helpers\Html::addCssClass方法的典型用法代码示例。如果您正苦于以下问题:PHP Html::addCssClass方法的具体用法?PHP Html::addCssClass怎么用?PHP Html::addCssClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kartik\helpers\Html的用法示例。


在下文中一共展示了Html::addCssClass方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: init

 public function init()
 {
     Html::addCssClass($this->options, 'jarviswidget');
     $this->options['id'] = $this->id;
     $this->params['options'] = $this->options;
     parent::init();
 }
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:7,代码来源:BackendWidget.php

示例2: renderAddon

 protected function renderAddon(&$options, $type = 'picker')
 {
     if ($options === false) {
         return '';
     }
     if (is_string($options)) {
         return $options;
     }
     Html::addCssClass($options, 'input-group-addon');
     $icon = $type === 'picker' ? 'date_range' : 'close';
     $icon = '<i class="glyphicon-calendar material-icons">' . $icon . '</i>';
     if (empty($options['title'])) {
         $title = $type === 'picker' ? Yii::t('kvdtime', 'Select date & time') : Yii::t('kvdtime', 'Clear field');
         if ($title != false) {
             $options['title'] = $title;
         }
     }
     return Html::tag('span', $icon, $options);
 }
开发者ID:promo-pr,项目名称:cms,代码行数:19,代码来源:DateTimePicker.php

示例3: getDefaultButton

 /**
  * Gets the default button
  *
  * @param string $type the button type
  * @param string $icon the glyphicon icon suffix name
  * @param string $title the title to display on hover
  *
  * @return string
  */
 protected function getDefaultButton($type, $icon, $title)
 {
     $buttonOptions = $type . 'Options';
     $options = $this->{$buttonOptions};
     $label = ArrayHelper::remove($options, 'label', "<i class='glyphicon glyphicon-{$icon}'></i>");
     if (empty($options['class'])) {
         $options['class'] = 'kv-action-btn';
     }
     Html::addCssClass($options, 'kv-btn-' . $type);
     $options = ArrayHelper::merge(['title' => $title], $options);
     if ($this->tooltips) {
         $options['data-toggle'] = 'tooltip';
         $options['data-container'] = 'body';
     }
     switch ($type) {
         case 'reset':
             return Html::resetButton($label, $options);
         case 'save':
             return Html::submitButton($label, $options);
         case 'delete':
             $url = ArrayHelper::remove($options, 'url', '#');
             return Html::a($label, $url, $options);
     }
     $options['type'] = 'button';
     return Html::button($label, $options);
 }
开发者ID:rumatakira,项目名称:yii2-detail-view,代码行数:35,代码来源:DetailView.php

示例4: getDefaultButton

 /**
  * Gets the default button
  *
  * @param string $type the button type
  * @param string $icon the glyphicon icon suffix name
  * @param string $title the title to display on hover
  *
  * @return string
  */
 protected function getDefaultButton($type, $icon, $title)
 {
     $buttonOptions = $type . 'Options';
     $options = $this->{$buttonOptions};
     $btnStyle = empty($this->panel['type']) ? self::TYPE_DEFAULT : $this->panel['type'];
     $label = ArrayHelper::remove($options, 'label', "<i class='glyphicon glyphicon-{$icon}'></i>");
     if (empty($options['class'])) {
         $options['class'] = 'btn btn-xs btn-' . $btnStyle;
     }
     Html::addCssClass($options, 'kv-btn-' . $type);
     $options = ArrayHelper::merge(['title' => $title], $options);
     if ($this->tooltips) {
         $options['data-toggle'] = 'tooltip';
         $options['data-container'] = 'body';
     }
     if ($type === 'reset') {
         return Html::resetButton($label, $options);
     } elseif ($type === 'save') {
         return Html::submitButton($label, $options);
     } elseif ($type === 'delete') {
         $url = ArrayHelper::remove($options, 'url', '#');
         return Html::a($label, $url, $options);
     } else {
         $options['type'] = 'button';
         return Html::button($label, $options);
     }
 }
开发者ID:pdbangibang,项目名称:apc-softdev-gd121mi122-4,代码行数:36,代码来源:DetailView.php

示例5: getButtonGroup

 /**
  * Generates a bootstrap toggle button group (checkbox or radio type)
  *
  * @see http://getbootstrap.com/javascript/#buttons-checkbox-radio
  *
  * @param string $type whether checkbox or radio.
  * @param string $name the name attribute of each checkbox.
  * @param string|array $selection the selected value(s).
  * @param array $items the data item used to generate the checkboxes/radios. The array keys are the
  * checkbox/radio values, while the array values are the corresponding labels.
  * @param array $options options (name => config) for the checkbox/radio list container tag. The following
  * options are specially handled:
  *
  * - `tag`: _string_, the tag name of the container element.
  * - `unselect`: _string_, the value that should be submitted when none of the checkboxes/radios is selected. By
  *   setting this option, a hidden input will be generated.
  * - `encode`: boolean, whether to HTML-encode the checkbox/radio labels. Defaults to `true`. This option is ignored
  *   if `item` option is set.
  * - `separator`: _string_, the HTML code that separates items.
  * - `itemOptions`: _array_, the options for generating the checkbox/radio tag using [[checkbox()]]/[[radio()]].
  * - `item`: _Closure_, a callback that can be used to customize the generation of the HTML code corresponding to a
  *   single item in $items. The signature of this callback must be:
  *
  *   ~~~
  *   function ($index, $label, $name, $checked, $value)
  *   ~~~
  *
  *   where `$index` is the zero-based index of the checkbox/radio in the whole list; `$label` is the label for the
  *   checkbox/radio; and `$name`, `$value` and `$checked` represent the name, value and the checked status of the
  *   checkbox/radio input, respectively.
  *
  * See [[renderTagAttributes()]] for details on how attributes are being rendered.
  *
  * @return string the generated toggle button group
  */
 public static function getButtonGroup($type, $name, $selection = null, $items = [], $options = [])
 {
     $class = $type . 'List';
     static::addCssClass($options, 'btn-group');
     $options['data-toggle'] = 'buttons';
     $options['inline'] = true;
     if (!isset($options['itemOptions']['labelOptions']['class'])) {
         $options['itemOptions']['labelOptions']['class'] = 'btn btn-default';
     }
     if (!isset($options['item']) || !$options['item'] instanceof Closure) {
         /** @noinspection PhpUnusedParameterInspection */
         /**
          * @param string $index
          * @param string $label
          * @param string $name
          * @param boolean $checked
          * @param string $value
          */
         $options['item'] = function ($index, $label, $name, $checked, $value) use($type, $options) {
             $opts = isset($options['itemOptions']) ? $options['itemOptions'] : [];
             $encode = !isset($options['encode']) || $options['encode'];
             if (!isset($opts['labelOptions'])) {
                 $opts['labelOptions'] = ArrayHelper::getValue($options, 'itemOptions.labelOptions', []);
             }
             if ($checked) {
                 Html::addCssClass($opts['labelOptions'], 'active');
             }
             return static::$type($name, $checked, array_merge($opts, ['value' => $value, 'label' => $encode ? static::encode($label) : $label]));
         };
     }
     return static::$class($name, $selection, $items, $options);
 }
开发者ID:kartik-v,项目名称:yii2-helpers,代码行数:67,代码来源:Html.php

示例6: foreach

?>

<div class="properties-widget widget-<?php 
echo $widget_id;
?>
" itemprop="propertiesList" itemscope itemtype="http://schema.org/ItemList">

<?php 
if (!empty($object_property_groups)) {
    foreach ($object_property_groups as $i => $opg) {
        if ($opg->group->is_internal) {
            continue;
        }
        $options = ['id' => 'pg-' . $opg->group->id, 'class' => 'object-property-group'];
        if ($i == 0) {
            \kartik\helpers\Html::addCssClass($options, 'active');
        }
        echo \kartik\helpers\Html::beginTag('div', $options);
        /** @var \app\models\Property[] $properties */
        $properties = app\models\Property::getForGroupId($opg->group->id);
        foreach ($properties as $prop) {
            if ($property_values = $model->getPropertyValuesByPropertyId($prop->id)) {
                echo $prop->handler($form, $model->getAbstractModel(), $property_values, 'frontend_render_view');
            }
        }
        echo "</div>";
    }
} else {
    echo '<!-- Empty properties -->';
}
?>
开发者ID:yii2ApplicationCollect,项目名称:dotplant2,代码行数:31,代码来源:show-properties-widget.php

示例7: getDefaultButton

 /**
  * Gets the default button
  *
  * @param string $type the button type
  * @return string
  */
 protected function getDefaultButton($type, $label, $title, $options)
 {
     $btnStyle = empty($this->panel['type']) ? self::TYPE_DEFAULT : $this->panel['type'];
     $label = ArrayHelper::remove($options, 'label', $label);
     if (empty($options['class'])) {
         $options['class'] = 'btn btn-xs btn-' . $btnStyle;
     }
     Html::addCssClass($options, 'kv-btn-' . $type);
     $options = ArrayHelper::merge(['title' => Yii::t('kvdetail', $title)], $options);
     if ($type !== 'delete' && $type !== 'save') {
         $options['type'] = 'button';
         return Html::button($label, $options);
     } elseif ($type === 'delete') {
         $url = ArrayHelper::remove($options, 'url', '#');
         $options = ArrayHelper::merge(['data-method' => 'post', 'data-confirm' => Yii::t('kvdetail', 'Are you sure you want to delete this item?')], $options);
         return Html::a($label, $url, $options);
     } else {
         return Html::submitButton($label, $options);
     }
 }
开发者ID:ivan-shu,项目名称:x-tag,代码行数:26,代码来源:PhotoTag.php

示例8: getButtonGroup

 /**
  * Generates a bootstrap toggle button group (checkbox or radio type)
  * 
  * @param string $type whether checkbox or radio.
  * @param string $name the name attribute of each checkbox.
  * @param string|array $selection the selected value(s).
  * @param array $items the data item used to generate the checkboxes/radios.
  * The array keys are the checkbox/radio values, while the array values are the corresponding labels.
  * @param array $options options (name => config) for the checkbox/radio list container tag.
  * The following options are specially handled:
  *
  * - tag: string, the tag name of the container element.
  * - unselect: string, the value that should be submitted when none of the checkboxes/radios is selected.
  *   By setting this option, a hidden input will be generated.
  * - encode: boolean, whether to HTML-encode the checkbox/radio labels. Defaults to true.
  *   This option is ignored if `item` option is set.
  * - separator: string, the HTML code that separates items.
  * - itemOptions: array, the options for generating the checkbox/radio tag using [[checkbox/radio()]].
  * - item: callable, a callback that can be used to customize the generation of the HTML code
  *   corresponding to a single item in $items. The signature of this callback must be:
  *
  *   ~~~
  *   function ($index, $label, $name, $checked, $value)
  *   ~~~
  *
  *   where $index is the zero-based index of the checkbox/radio in the whole list; $label
  *   is the label for the checkbox/radio; and $name, $value and $checked represent the name,
  *   value and the checked status of the checkbox/radio input, respectively.
  *
  * See [[renderTagAttributes()]] for details on how attributes are being rendered.
  *
  * @return string the generated toggle button group
  */
 public static function getButtonGroup($type, $name, $selection = null, $items = [], $options = [])
 {
     $class = $type . 'List';
     static::addCssClass($options, 'btn-group');
     $options['data-toggle'] = 'buttons';
     $options['inline'] = true;
     if (!isset($options['itemOptions']['labelOptions']['class'])) {
         $options['itemOptions']['labelOptions']['class'] = 'btn btn-default';
     }
     $options['item'] = function ($index, $label, $name, $checked, $value) use($type, $options) {
         $opts = isset($options['itemOptions']) ? $options['itemOptions'] : [];
         $encode = !isset($options['encode']) || $options['encode'];
         if (!isset($opts['labelOptions'])) {
             $opts['labelOptions'] = ArrayHelper::getValue($options, 'itemOptions.labelOptions', []);
         }
         if ($checked) {
             Html::addCssClass($opts['labelOptions'], 'active');
         }
         return static::$type($name, $checked, array_merge($opts, ['value' => $value, 'label' => $encode ? static::encode($label) : $label]));
     };
     return static::$class($name, $selection, $items, $options);
 }
开发者ID:aiddroid,项目名称:yii2-helpers,代码行数:55,代码来源:Html.php

示例9: renderRawInput

 /**
  * Renders raw form input based on the attribute settings
  *
  * @param string $attribute the name of the attribute
  * @param string $id the input identifier
  * @param array  $settings the attribute settings
  *
  * @return string the form input markup
  * @throws \yii\base\InvalidConfigException
  */
 protected static function renderRawInput($attribute, &$id, $settings = [])
 {
     $type = ArrayHelper::getValue($settings, 'type', self::INPUT_TEXT);
     $i = strpos($attribute, ']');
     $attribName = $i > 0 ? substr($attribute, $i + 1) : $attribute;
     if (!in_array($type, static::$_validInputs)) {
         throw new InvalidConfigException("Invalid input type '{$type}' configured for the attribute '{$attribName}'.'");
     }
     $value = ArrayHelper::getValue($settings, 'value', null);
     $options = ArrayHelper::getValue($settings, 'options', []);
     $id = str_replace(['[]', '][', '[', ']', ' '], ['', '-', '-', '', '-'], $attribute);
     $id = strtolower($id);
     if ($type === self::INPUT_WIDGET) {
         $id = empty($options['options']['id']) ? $id : $options['options']['id'];
         $options['options']['id'] = $id;
     } else {
         $id = empty($options['id']) ? $id : $options['id'];
         $options['id'] = $id;
     }
     if ($type === self::INPUT_STATIC || $type === self::INPUT_HIDDEN_STATIC) {
         $opts = $options;
         if ($type === self::INPUT_HIDDEN_STATIC) {
             $opts = ArrayHelper::getValue($settings, 'hiddenStaticOptions', []);
         }
         Html::addCssClass($opts, 'form-control-static');
         $out = Html::tag('p', $value, $opts);
         if ($type === self::INPUT_HIDDEN_STATIC) {
             return $out . Html::hiddenInput($attribute, $value, $opts);
         }
         return $out;
     }
     if (!isset($options['class']) && $type !== self::INPUT_CHECKBOX_BUTTON_GROUP && $type !== self::INPUT_RADIO_BUTTON_GROUP) {
         $options['class'] = 'form-control';
     }
     if (isset(static::$_basicInputs[$type])) {
         return Html::$type($attribute, $value, $options);
     }
     if (isset(static::$_dropdownInputs[$type])) {
         if (!isset($settings['items'])) {
             throw new InvalidConfigException("You must setup the 'items' array for attribute '{$attribName}' since it is a '{$type}'.");
         }
         $items = ArrayHelper::getValue($settings, 'items', []);
         return Html::$type($attribute, $value, $items, $options);
     }
     if ($type === self::INPUT_CHECKBOX || $type === self::INPUT_RADIO) {
         $enclosedByLabel = ArrayHelper::getValue($settings, 'enclosedByLabel', true);
         $checked = !empty($value) && $value !== false ? true : false;
         $out = Html::$type($attribute, $checked, $options);
         return $enclosedByLabel ? "<div class='{$type}'>{$out}</div>" : $out;
     }
     if ($type === self::INPUT_HTML5) {
         $html5type = ArrayHelper::getValue($settings, 'html5type', 'text');
         return Html::input($html5type, $attribute, $value, $options);
     }
     if ($type === self::INPUT_WIDGET) {
         $widgetClass = ArrayHelper::getValue($settings, 'widgetClass', []);
         if (empty($widgetClass) && !$widgetClass instanceof InputWidget) {
             throw new InvalidConfigException("A valid 'widgetClass' for '{$attribute}' must be setup and extend from 'yii\\widgets\\InputWidget'.");
         }
         $options['name'] = $attribute;
         $options['value'] = $value;
         return $widgetClass::widget($options);
     }
     if ($type === self::INPUT_RAW) {
         return ArrayHelper::getValue($settings, 'value', '');
     }
     return null;
 }
开发者ID:rumatakira,项目名称:yii2-builder,代码行数:78,代码来源:BaseForm.php

示例10: button

 /**
  * Generates an action button
  *
  * @param string $key the button identification key
  * @param array  $params the parameters to pass to the button action.
  * @param array  $config the button configuration options to override. You can additionally set the `label` or
  * `icon` here.
  *
  * @return string
  */
 public function button($key, $params = [], $config = [])
 {
     $btn = ArrayHelper::getValue($this->buttons, $key, []);
     if (empty($btn)) {
         return '';
     }
     $iconPrefix = $this->iconPrefix;
     $labelNew = ArrayHelper::remove($config, 'label', '');
     $iconNew = ArrayHelper::remove($config, 'icon', '');
     $label = $icon = $action = $type = '';
     $options = [];
     $iconOptions = ['style' => 'margin-right:5px'];
     extract($btn);
     if (!empty($iconNew)) {
         $icon = $iconNew;
     }
     if (!empty($icon)) {
         Html::addCssClass($iconOptions, explode(' ', $iconPrefix . $icon));
         $icon = Html::tag('i', '', $iconOptions);
     }
     if (!empty($labelNew)) {
         $label = $labelNew;
     }
     $label = $icon . $label;
     $options = array_replace_recursive($options, $config);
     if (!empty($options['disabled'])) {
         $action = null;
     }
     if (!empty($action)) {
         $action = ArrayHelper::getValue($this->actionSettings, $action, $action);
         $action = Url::to([$action] + $params);
         return Html::a($label, $action, $options);
     }
     if (!empty($type) && $type === 'submit' || $type === 'reset') {
         $type .= 'Button';
     } else {
         $type = 'button';
     }
     return Html::$type($label, $options);
 }
开发者ID:communityii,项目名称:yii2-user,代码行数:50,代码来源:Module.php

示例11: getFormInput

 /**
  * Generate the input markup for an [[ActiveForm]] input.
  *
  * @return string the form input markup
  */
 protected function getFormInput()
 {
     Html::addCssClass($this->options, 'input-group');
     $fieldType = $this->type;
     $options1 = ArrayHelper::getValue($this->fieldConfig1, 'options', []);
     $options2 = ArrayHelper::getValue($this->fieldConfig2, 'options', []);
     Html::addCssClass($options1, 'kv-container-from form-control');
     Html::addCssClass($options2, 'kv-container-to form-control');
     $this->fieldConfig1 = ArrayHelper::merge($this->fieldConfig1, ['template' => '{input}{error}', 'options' => $options1]);
     $this->fieldConfig2 = ArrayHelper::merge($this->fieldConfig2, ['template' => '{input}{error}', 'options' => $options2]);
     Html::addCssClass($this->options1, 'form-control kv-field-from');
     Html::addCssClass($this->options2, 'form-control kv-field-to');
     $field1 = $this->form->field($this->model, $this->attribute1, $this->fieldConfig1);
     $field2 = $this->form->field($this->model, $this->attribute2, $this->fieldConfig2);
     if ($this->type === self::INPUT_HTML5_INPUT) {
         $input1 = $field1->{$fieldType}(ArrayHelper::remove($this->options1, 'type', 'text'), $this->options1);
         $input2 = $field2->{$fieldType}(ArrayHelper::remove($this->options2, 'type', 'text'), $this->options2);
     } elseif ($this->_isDropdown) {
         $input1 = $field1->{$fieldType}($this->items1, $this->options1);
         $input2 = $field2->{$fieldType}($this->items2, $this->options2);
     } elseif ($this->_isInput) {
         $input1 = $field1->{$fieldType}($this->options1);
         $input2 = $field2->{$fieldType}($this->options2);
     } else {
         $this->setWidgetOptions(1);
         $this->setWidgetOptions(2);
         $input1 = $field1->widget($this->widgetClass, $this->widgetOptions1);
         $input2 = $field2->widget($this->widgetClass, $this->widgetOptions2);
     }
     return $input1 . '<span class="input-group-addon kv-field-separator">' . $this->separator . '</span>' . $input2;
 }
开发者ID:kartik-v,项目名称:yii2-field-range,代码行数:36,代码来源:FieldRange.php


注:本文中的kartik\helpers\Html::addCssClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。