php yii-bootstrap-Html类(方法)实例源码

下面列出了php yii-bootstrap-Html 类(方法)源码代码实例,从而了解它的用法。

作者:specialnot    项目:myYi   
public function init()
 {
     if ($this->toUser || $this->subject || $this->content) {
         throw new Exception('邮件属性不能为空');
     }
     $this->subject = Html::encode($this->subject);
 }

作者:ASP9    项目:admi   
/**
  * @param string|array $item the item to be normalized.
  * @return string|array normalized item.
  */
 protected function normalizeItem($item)
 {
     if (is_array($item)) {
         if (isset($item['icon'])) {
             if (isset($item['label'])) {
                 $label = $item['label'];
                 $encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabels;
                 if ($encodeLabel) {
                     $label = Html::encode($label);
                 }
             } else {
                 $label = '';
             }
             $item['encode'] = false;
             $label = Html::icon($item['icon']) . ' ' . $label;
             $item['label'] = $label;
         }
         if (isset($item['items'])) {
             foreach ($item['items'] as $key => $value) {
                 $item['items'][$key] = $this->normalizeItem($value);
             }
         }
     }
     return $item;
 }

作者:tsyry    项目:mybrio   
public function getFileLink($class = false)
 {
     if (!$class) {
         $class = '';
     }
     return Html::a($this->vneshnee_imya_fajla, $this->getUri(), ['class' => 'file_item ' . $class, 'data-file-id' => $this->id]);
 }

作者:sibd    项目:yii2-synctransli   
public function run()
 {
     echo Html::beginTag('div', ['class' => 'input-group']);
     if (!isset($this->options['class'])) {
         $this->options['class'] = 'form-control';
     }
     $iconId = 'icon-' . $this->options['id'];
     if (!isset($this->options['aria-describedby'])) {
         $this->options['aria-describedby'] = $iconId;
     }
     if ($this->hasModel()) {
         $replace['{input}'] = Html::activeTextInput($this->model, $this->attribute, $this->options);
     } else {
         $replace['{input}'] = Html::textInput($this->name, $this->value, $this->options);
     }
     if ($this->icon != '') {
         $replace['{icon}'] = Html::tag('span', Icon::show($this->icon, [], Icon::FA), ['class' => 'input-group-addon', 'id' => $iconId]);
     }
     echo strtr($this->template, $replace);
     echo Html::endTag('div');
     $view = $this->getView();
     Assets::register($view);
     $idMaster = $this->hasModel() ? Html::getInputId($this->model, $this->fromField) : $this->fromField;
     $idSlave = $this->options['id'];
     $view->registerJs("\n        \$('#{$idMaster}').syncTranslit({\n            destination: '{$idSlave}',\n            type: 'url',\n            caseStyle: 'lower',\n            urlSeparator: '-'\n        });");
 }

作者:veton    项目:tok   
/**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (!isset($this->options['name'])) {
         $this->options['name'] = $this->hasModel() ? Html::getInputName($this->model, $this->attribute) : $this->name;
     }
 }

作者:spiro-stathaki    项目:project   
public function renderHtmlInput($input_type_id, $options = [])
 {
     $field = $options['prefix_text'] . " ";
     switch ($input_type_id) {
         case Types::$input_type['small_text']['id']:
             $field .= Html::textInput(sprintf('question_%s', $options['screening_question_id']), '', ['style' => 'width:60px']);
             break;
         case Types::$input_type['med_text']['id']:
             $field .= Html::textInput(sprintf('question_%s', $options['screening_question_id']), '', []);
             break;
         case Types::$input_type['large_text']['id']:
             $field .= Html::textInput(sprintf('question_%s', $options['screening_question_id']), '', ['style' => 'width:240px']);
             break;
         case Types::$input_type['date']['id']:
             $field = sprintf('');
             break;
         case Types::$input_type['radio']['id']:
             // Enable tristate behavior with custom indeterminate value, custom toggle icon, and a custom label for the indeterminate state.
             $options['tristate_option_id'] == Types::$boolean['true']['id'] ? $tristate = true : ($tristate = false);
             $field = Html::radioList(sprintf('question_%s', $options['screening_question_id']), Types::$boolean['null']['id'], [Types::$boolean['true']['description'] => Types::$boolean['true']['description'], Types::$boolean['false']['description'] => Types::$boolean['false']['description']], ['unselect' => Types::$boolean['null']['description'], 'separator' => '   ']);
             break;
         case Types::$input_type['text_agreement']['id']:
         case Types::$input_type['text_agreement']['id']:
             $field = Html::radioList(sprintf('question_%s', $options['screening_question_id']), Types::$boolean['null']['id'], [yii::t('app', 'Agree') => yii::t('app', 'Agree'), yii::t('app', 'Disagree') => yii::t('app', 'Disagree')], ['unselect' => Types::$boolean['null']['description'], 'separator' => '   ']);
             break;
             break;
         case Types::$input_type['image_overlay']['id']:
             $field = sprintf('image overlay');
             break;
     }
     $field .= " " . $options['suffix_text'];
     return $field;
 }

作者:sibd    项目:yii2-gridhelpe   
/**
  * Initializes the default button rendering callbacks.
  */
 protected function initDefaultButtons()
 {
     /* TODO: Add support!
        if (!isset($this->buttons['view'])) {
            $this->buttons['view'] = function ($url, $model, $key) {
                $options = array_merge([
                    'title' => self::t('yii', 'View'),
                    'aria-label' => self::t('yii', 'View'),
                    'data-pjax' => '0',
                ], $this->buttonOptions);
                return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', $url, $options);
            };
        }
        */
     if (!isset($this->buttons['update'])) {
         $this->buttons['update'] = function ($url, $model, $key) {
             $options = array_merge(['title' => self::t('messages', 'Edit'), 'aria-label' => self::t('messages', 'Edit'), 'data-pjax' => '0'], $this->buttonOptions);
             return Html::a(trim(Icon::show('pencil')), $url, $options);
         };
     }
     if (!isset($this->buttons['copy'])) {
         $this->buttons['copy'] = function ($url, $model, $key) {
             $options = array_merge(['title' => self::t('messages', 'Copy'), 'aria-label' => self::t('messages', 'Copy')], $this->buttonOptions);
             if ($model->hasMethod('duplicate') && ($model->hasAttribute('removed') && !$model->removed)) {
                 return Html::a(trim(Icon::show('copy')), $url, $options);
             }
         };
     }
     if (!isset($this->buttons['lock'])) {
         $this->buttons['lock'] = function ($url, $model, $key) {
             $options = array_merge(['title' => self::t('messages', 'Lock'), 'aria-label' => self::t('messages', 'Lock')], $this->buttonOptions);
             if ($model->hasAttribute('locked') && !$model->locked && ($model->hasAttribute('removed') && !$model->removed)) {
                 return Html::a(trim(Icon::show('lock')), $url, $options);
             }
         };
     }
     if (!isset($this->buttons['unlock'])) {
         $this->buttons['unlock'] = function ($url, $model, $key) {
             $options = array_merge(['title' => self::t('messages', 'Unlock'), 'aria-label' => self::t('messages', 'Unlock')], $this->buttonOptions);
             if ($model->hasAttribute('locked') && $model->locked && ($model->hasAttribute('removed') && !$model->removed)) {
                 return Html::a(trim(Icon::show('unlock')), $url, $options);
             }
         };
     }
     if (!isset($this->buttons['restore'])) {
         $this->buttons['restore'] = function ($url, $model, $key) {
             $options = array_merge(['title' => self::t('messages', 'Restore'), 'aria-label' => self::t('messages', 'Restore'), 'data-confirm' => self::t('messages', 'Are you sure you want to restore this item?'), 'data-method' => 'post', 'data-pjax' => '0'], $this->buttonOptions);
             if ($model->hasAttribute('removed') && $model->removed) {
                 return Html::a(trim(Icon::show('share-square-o')), $url, $options);
             }
         };
     }
     if (!isset($this->buttons['delete'])) {
         $this->buttons['delete'] = function ($url, $model, $key) {
             $name = $model->hasAttribute('removed') && !$model->removed ? self::t('messages', 'To trash') : self::t('messages', 'Delete');
             $options = array_merge(['title' => $name, 'aria-label' => $name, 'data-confirm' => self::t('messages', 'Are you sure you want to delete this item?'), 'data-method' => 'post', 'data-pjax' => '0'], $this->buttonOptions);
             return Html::a(trim(Icon::show('trash')), $url, $options);
         };
     }
 }

作者:VasileGabrie    项目:humhu   
/**
  * @inheritdoc
  */
 public function run()
 {
     if (!$this->height) {
         $this->height = $this->width;
     }
     if (!isset($this->linkOptions['href'])) {
         $this->linkOptions['href'] = $this->space->getUrl();
     }
     if ($this->space->color != null) {
         $color = Html::encode($this->space->color);
     } else {
         $color = '#d7d7d7';
     }
     if (!isset($this->htmlOptions['class'])) {
         $this->htmlOptions['class'] = "";
     }
     if (!isset($this->htmlOptions['style'])) {
         $this->htmlOptions['style'] = "";
     }
     $acronymHtmlOptions = $this->htmlOptions;
     $imageHtmlOptions = $this->htmlOptions;
     $acronymHtmlOptions['class'] .= " space-profile-acronym-" . $this->space->id . " space-acronym";
     $acronymHtmlOptions['style'] .= " background-color: " . $color . "; width: " . $this->width . "px; height: " . $this->height . "px;";
     $acronymHtmlOptions['style'] .= " " . $this->getDynamicStyles($this->width);
     $imageHtmlOptions['class'] .= " space-profile-image-" . $this->space->id . " img-rounded profile-user-photo";
     $imageHtmlOptions['style'] .= " width: " . $this->width . "px; height: " . $this->height . "px";
     $imageHtmlOptions['alt'] = Html::encode($this->space->name);
     $defaultImage = basename($this->space->getProfileImage()->getUrl()) == 'default_space.jpg' || basename($this->space->getProfileImage()->getUrl()) == 'default_space.jpg?cacheId=0' ? true : false;
     if (!$defaultImage) {
         $acronymHtmlOptions['class'] .= " hidden";
     } else {
         $imageHtmlOptions['class'] .= " hidden";
     }
     return $this->render('image', ['space' => $this->space, 'acronym' => $this->getAcronym(), 'link' => $this->link, 'linkOptions' => $this->linkOptions, 'acronymHtmlOptions' => $acronymHtmlOptions, 'imageHtmlOptions' => $imageHtmlOptions]);
 }

作者:VasileGabrie    项目:humhu   
/**
  * @inheritdoc
  */
 public function getAsHtml()
 {
     $contentInfo = $this->getContentInfo($this->getCommentedRecord());
     if ($this->groupCount > 1) {
         return Yii::t('CommentModule.notification', "{displayNames} commented {contentTitle}.", array('displayNames' => $this->getGroupUserDisplayNames(), 'contentTitle' => $contentInfo));
     }
     return Yii::t('CommentModule.notification', "{displayName} commented {contentTitle}.", array('displayName' => Html::tag('strong', Html::encode($this->originator->displayName)), 'contentTitle' => $contentInfo));
 }

作者:caron    项目:yii2-component   
public static function begin2($config = [])
 {
     $error = Html::tag('div', '{error}', ["class" => "col-lg-8"]);
     $input = Html::tag('div', '{input}', ["class" => "col-lg-4"]);
     $template = "{label}\n" . $input . $error;
     $config = ArrayHelper::merge(['options' => ['class' => 'form-horizontal'], 'fieldConfig' => ['template' => $template, 'labelOptions' => ['class' => 'col-lg-3 control-label']]], $config);
     return self::begin($config);
 }

作者:ahb36    项目:kalpo   
private function renderDropdown()
 {
     if ($this->hasModel()) {
         echo Html::activeDropDownList($this->model, $this->attribute, $this->getItems(), $this->options);
     } else {
         echo Html::dropDownList($this->name, $this->value, $this->getItems(), $this->options);
     }
 }

作者:mark3    项目:yii2-to   
public function run()
 {
     NavBar::begin(['brandLabel' => false, 'options' => ['class' => 'tor-nav']]);
     echo Html::tag('div', $this->torMenu(), ['class' => 'container']);
     NavBar::end();
     $view = $this->view;
     NavAsset::register($view);
 }

作者:snezbritski    项目:lift-fortres   
public function renderItem($message, $options)
 {
     echo Html::beginTag('div', $options) . "\n";
     echo Html::beginTag('p');
     echo $message;
     echo Html::endTag('p');
     echo "\n" . Html::endTag('div');
 }

作者:haunt    项目:help-cente   
/**
  * Returns Bootstrap label widget with user's role
  * @param User $user
  * @return string
  */
 public function getRoleLabel(User $user)
 {
     $roles = [User::ROLE_USER => ['success', Yii::t('app', 'User')], User::ROLE_EDITOR => ['warning', Yii::t('app', 'Editor')], User::ROLE_ADMINISTRATOR => ['danger', Yii::t('app', 'Administrator')]];
     if (isset($roles[$user->role])) {
         return Html::tag('span', $roles[$user->role][1], ['class' => 'label label-' . $roles[$user->role][0]]);
     }
     return 'N/A';
 }

作者:ivphpa    项目:darhan-butiqu   
public function actionImagine()
 {
     $product = ProductRecord::find()->lang()->one();
     echo Html::img($product->image->source);
     echo Html::img($product->imageSrc('200x200', \yii\image\drivers\Image::CROP));
     echo Html::img($product->imageSrc('100x200', \yii\image\drivers\Image::CROP));
     echo Html::img($product->imageSrc('500x200'));
 }

作者:edofr    项目:yii2-slider-pr   
/**
  * @return string
  */
 public function render()
 {
     if (isset($this->htmlOptions['class'])) {
         $this->htmlOptions['class'] = self::LAYER_CLASS . ' ' . $this->htmlOptions['class'];
     } else {
         $this->htmlOptions['class'] = self::LAYER_CLASS;
     }
     return \yii\bootstrap\Html::tag($this->tag, $this->content, $this->htmlOptions);
 }

作者:ExtPoin    项目:project-boilerplat   
public function submitButton($label, $options = [])
 {
     $buttonStr = Html::submitButton($label, array_merge($options, ['class' => 'btn btn-primary']));
     if ($this->layout == 'horizontal') {
         return "<div class=\"form-group\"><div class=\"col-sm-offset-3 col-sm-6\">{$buttonStr}</div></div>";
     } else {
         return "<div class=\"form-group\">{$buttonStr}</div>";
     }
 }

作者:edofr    项目:yii2-slider-pr   
/**
  * @return string
  */
 public function render()
 {
     if (isset($this->htmlOptions['class'])) {
         $this->htmlOptions['class'] = self::IMAGE_CLASS . ' ' . $this->htmlOptions['class'];
     } else {
         $this->htmlOptions['class'] = self::IMAGE_CLASS;
     }
     return \yii\bootstrap\Html::img($this->src, $this->htmlOptions);
 }

作者:nagse    项目:page   
public function run()
 {
     if ($this->hasModel()) {
         echo Html::activeTextarea($this->model, $this->attribute, $this->options);
     } else {
         echo Html::textarea($this->name, $this->value, $this->options);
     }
     $this->registerPlugin();
 }

作者:kalyabi    项目:comitk   
/**
  * Renders system message at frontend.
  *
  * @return string
  */
 public function viewMessage()
 {
     $alert = Yii::$app->session->getFlash('system-alert');
     $type = ArrayHelper::getValue($alert, 'type', self::INFO);
     $message = ArrayHelper::getValue($alert, 'message', '');
     if (!empty($message)) {
         return Html::tag('div', $message, ['class' => 'alert alert-' . $type]);
     }
     return '';
 }


问题


面经


文章

微信
公众号

扫码关注公众号