本文整理汇总了PHP中yii\bootstrap\Html::tag方法的典型用法代码示例。如果您正苦于以下问题:PHP Html::tag方法的具体用法?PHP Html::tag怎么用?PHP Html::tag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\bootstrap\Html
的用法示例。
在下文中一共展示了Html::tag方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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 });");
}
示例2: 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';
}
示例3: 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);
}
示例4: 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);
}
示例5: 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));
}
示例6: render
/**
* @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);
}
示例7: run
public function run()
{
if ($this->torAd) {
echo $this->render('full', ['torAd' => $this->torAd]);
} else {
echo Html::tag('div', '<em>По Вашему запросу ничего не найдено</em>', ['class' => 'text-center text-muted']);
}
$view = $this->view;
TorAdsAsset::register($view);
}
示例8: viewMessage
/**
* 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 '';
}
示例9: accountMenu
public function accountMenu()
{
if (Yii::$app->user->isGuest) {
$items[] = ['label' => 'Войти', 'url' => ['/site/login']];
$items[] = ['label' => 'Зарегистрироваться', 'url' => ['/site/signup']];
} else {
$user = User::findOne(Yii::$app->user->id);
$items[] = ['label' => $user->username . ' ' . Html::tag('span', preg_replace('/\\,00/', '', number_format($user->money, 2, ',', ' ')) . ' ' . Icon::show('user', ['class' => 'fa-btc'], Icon::FA), ['style' => 'margin: 0 2px 0 6px;']), 'items' => [['label' => 'Добавить лот на продажу', 'url' => ['/tor/mng-ad']], '<li class="divider"></li>', ['label' => 'Сменить пароль', 'url' => ['#']], ['label' => 'Выход', 'url' => ['/site/logout'], 'linkOptions' => ['data-method' => 'post']]]];
}
return $items;
}
示例10: renderDataCellContent
/**
* @inheritdoc
*/
protected function renderDataCellContent($model, $key, $index)
{
if ($this->content === null) {
$contentParts = [];
$variationBehavior = $this->getVariationBehavior($model);
foreach ($variationBehavior->getVariationModels() as $variationModel) {
$contentParts[] = '<tr><td><b>' . $this->getVariationLabel($model, $variationModel) . '</b></td><td>' . $this->getVariationValue($variationModel) . '</td>';
}
return Html::tag('table', implode("\n", $contentParts), $this->tableOptions);
}
return parent::renderDataCellContent($model, $key, $index);
}
示例11: renderButton
/**
* Generates the button dropdown.
* @return string the rendering result.
*/
protected function renderButton()
{
// Html::addCssClass($this->options, ['widget' => 'btn']);
$label = $this->label;
$options = $this->options;
if (!isset($options['href'])) {
$options['href'] = '#';
}
Html::addCssClass($options, ['toggle' => 'dropdown-toggle']);
$options['data-toggle'] = 'dropdown';
return Html::tag($this->tagName, $label, $options) . "\n";
}
示例12: testGridBoxRender
/**
* @dataProvider gridDataProvider
*/
public function testGridBoxRender($dataProvider)
{
$grid = GridBox::widget(['id' => 'gridbox-test-id', 'tools' => Html::tag('span', 'abc123', ['class' => '.tool-test']), 'dataProvider' => $dataProvider, 'columns' => ['id', ['attribute' => 'username', 'contentOptions' => ['class' => 'username']], 'email']]);
$dom = new Crawler($grid);
$root = $dom->filter('div#gridbox-test-id');
$this->assertEquals('gridbox-test-id', $root->attr('id'));
$this->assertEquals('grid-view box box-default', $root->attr('class'));
$header = $root->filter('div.box-header');
$tools = $header->filter('div.box-tools');
$this->assertContains('abc123', $tools->text());
$body = $root->filter('div.box-body');
$this->assertEquals('box-body no-padding', $body->attr('class'));
$this->assertNotNull($body->filter('table.table')->eq(0));
$this->assertEquals('bar', $body->filter('tr[data-key="1"] td.username')->text());
$footer = $header = $root->filter('div.box-footer');
$this->assertContains('Showing 1-3 of 3 items.', $footer->text());
}
示例13: run
public function run()
{
$link = Links::findOne(['url' => '/' . $this->url]);
$this->links_id[] = $link->id;
if ($link->child_exist == 1) {
$this->getLinksId($link->id);
}
$ads = TorAds::find()->where(['links_id' => $this->links_id])->orderBy(['created_at' => SORT_ASC, 'price' => SORT_ASC])->limit(20)->all();
$ads_promo = TorAds::find()->where(['links_id' => $this->links_id])->limit(5)->orderBy(['created_at' => rand()])->all();
if ($ads) {
echo $this->render('preview', ['ads' => $ads, 'ads_promo' => $ads_promo]);
} else {
echo Html::tag('div', '<em>Для заданных параметров товар не найден</em>', ['class' => 'text-center text-muted']);
}
$view = $this->view;
TorAdsAsset::register($view);
}
示例14: init
/**
* @inheritdoc
*/
public function init()
{
if (!isset($this->options['id'])) {
$this->options['id'] = $this->getId();
}
if ($this->requiresDjax()) {
ob_start();
ob_implicit_flush(false);
$view = $this->getView();
$view->clear();
$view->beginPage();
$view->head();
$view->beginBody();
if ($view->title !== null) {
echo Html::tag('title', Html::encode($view->title));
}
} else {
echo Html::beginTag('div', $this->options);
}
}
示例15: initDefaultButtons
/**
* @inheritdoc
*/
protected function initDefaultButtons()
{
if (!isset($this->buttons['enumeration-action'])) {
$this->buttons['enumeration-action'] = function ($url, $model, $key) {
$options = array_merge(['data-method' => 'POST', 'data-pjax' => '0', 'data-url' => $this->url, 'class' => 'btn btn-default btn-enumeration'], $this->buttonOptions);
$options['title'] = $options['aria-label'] = $this->type == static::TypeLeft ? Yii::t('easyii', 'Enumeration|MoveRight') : Yii::t('easyii', 'Enumeration|MoveLeft');
$options['data-status'] = $this->type == static::TypeLeft ? '1' : '0';
if ($model instanceof Enumeration2Model) {
$options['data-owner-id'] = $this->enumeration->owner_id;
$options['data-model-id'] = $model->model->primaryKey;
} else {
$options['data-owner-id'] = $this->enumeration->owner_id;
$options['data-model-id'] = $model->primaryKey;
}
if ($this->type == static::TypeLeft) {
return Html::a(Html::tag('span', '', ['class' => 'glyphicon glyphicon-menu-right']), $this->url, $options);
} else {
return Html::a(Html::tag('span', '', ['class' => 'glyphicon glyphicon-menu-left']), $this->url, $options);
}
};
}
}