本文整理汇总了PHP中yii\bootstrap\Html类的典型用法代码示例。如果您正苦于以下问题:PHP Html类的具体用法?PHP Html怎么用?PHP Html使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Html类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
if ($this->toUser || $this->subject || $this->content) {
throw new Exception('邮件属性不能为空');
}
$this->subject = Html::encode($this->subject);
}
示例2: normalizeItem
/**
* @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;
}
示例3: getFileLink
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]);
}
示例4: run
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 });");
}
示例5: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if (!isset($this->options['name'])) {
$this->options['name'] = $this->hasModel() ? Html::getInputName($this->model, $this->attribute) : $this->name;
}
}
示例6: renderHtmlInput
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;
}
示例7: initDefaultButtons
/**
* 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);
};
}
}
示例8: run
/**
* @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]);
}
示例9: getAsHtml
/**
* @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));
}
示例10: begin2
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);
}
示例11: renderDropdown
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);
}
}
示例12: run
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);
}
示例13: renderItem
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');
}
示例14: getRoleLabel
/**
* 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';
}
示例15: actionImagine
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'));
}