本文整理汇总了PHP中yii\bootstrap\Html::a方法的典型用法代码示例。如果您正苦于以下问题:PHP Html::a方法的具体用法?PHP Html::a怎么用?PHP Html::a使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\bootstrap\Html
的用法示例。
在下文中一共展示了Html::a方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLessonsList
private function getLessonsList($lessons_array, $week, $day)
{
foreach ($lessons_array as $key => $element) {
if ($element->week != $week || $element->day != $day) {
unset($lessons_array[$key]);
}
}
$lessons = $lessons_array;
$items = array();
$result = array();
foreach ($lessons as $lesson) {
foreach ($this->attributes as $attr) {
if ($attr == $this->group) {
$items[] = Html::tag('td', Html::a($lesson->{$attr}, Url::to(['//group/view', 'id' => $lesson->groupHasDiscipline->group->id])));
} elseif ($attr == $this->teacher) {
$items[] = Html::tag('td', Html::button($lesson->{$attr}, ['value' => Url::to(['//teacher/view', 'id' => $lesson->teacherHasDiscipline->teacher->id]), 'class' => 'btn-link modalButton']));
} elseif ($attr == $this->discipline && (Yii::$app->user->can('chief') || isset(Yii::$app->user->identity->student) && $lesson->groupHasDiscipline->checkStudent(Yii::$app->user->identity->student->id) || isset(Yii::$app->user->identity->teacher) && $lesson->groupHasDiscipline->checkTeacher(Yii::$app->user->identity->teacher->id))) {
$items[] = Html::tag('td', Html::a($lesson->groupHasDiscipline->discipline->name, Url::to(['//group-has-discipline', 'id' => $lesson->groupHasDiscipline->id]), ['class' => 'btn-link']));
} else {
$items[] = Html::tag('td', $lesson->{$attr});
}
}
$result[] = Html::tag('tr', implode("\n", $items));
$items = null;
}
return Html::tag('tr', implode("\n", $result));
}
示例2: 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]);
}
示例3: 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);
};
}
}
示例4: actionUpdate
/**
* Updates an existing Person model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
Yii::$app->session->setFlash('alert', ['body' => \Yii::t('app', 'Person {name} was updated', ['name' => Html::a($model->getFullName(), Url::toRoute(['view', 'id' => $model->id]))]), 'options' => ['class' => 'alert-success']]);
return $this->redirect(['index']);
} else {
return $this->render('update', ['model' => $model]);
}
}
示例5: deleteButtonFn
/**
*
* @param type $url
* @param Language $model
* @param type $key
*/
public static function deleteButtonFn($url, $model, $key)
{
$glyphSuffix = 'ok';
$actionPrefix = 'enable';
if ($model['status'] == 0) {
$glyphSuffix = 'remove';
$actionPrefix = 'disable';
}
$options = ['class' => $actionPrefix . '-language-button', 'data-pjax' => 'language-grid', 'url' => \yii\helpers\Url::to([$actionPrefix . '-language', 'id' => $model['id']]), 'title' => Yii::t('yii', 'Delete'), 'aria-label' => Yii::t('yii', 'Delete'), 'style' => 'cursor:pointer'];
return Html::a('<span class="glyphicon glyphicon-' . $glyphSuffix . '"></span>', false, $options);
}
示例6: run
public function run()
{
$out = '';
if (\Yii::$app->user->isGuest) {
if ($this->enableSignUp) {
$out .= \yii\bootstrap\Html::a('Signup', ['/user/account/signup']);
$out .= $this->separator;
}
$out .= \yii\bootstrap\Html::a('Login', ['/user/account/login']);
} else {
$out = '<li>' . Html::beginForm(['/user/account/logout'], 'post') . Html::submitButton('Logout (' . \Yii::$app->user->identity->email . ')', ['class' => 'btn btn-link']) . Html::endForm() . '</li>';
}
return $out;
}
示例7: initDefaultButtons
protected function initDefaultButtons()
{
if (!isset($this->buttons['update'])) {
$this->buttons['update'] = function ($url, $model, $key) {
$options = array_merge(['title' => \Yii::t('app', 'Edit'), 'class' => 'btn btn-xs green', 'style' => 'margin-right:0', 'data-toggle' => 'tooltip', 'data-pjax' => '0'], $this->buttonOptions);
return Html::a('<span class="fa fa-edit"></span> ', $url, $options);
};
}
if (!isset($this->buttons['delete'])) {
$this->buttons['delete'] = function ($url, $model, $key) {
$options = array_merge(['title' => \Yii::t('app', 'Delete'), 'class' => 'btn red btn-xs', 'data-toggle' => 'tooltip', 'data-confirm' => \Yii::t('yii', 'Are you sure you want to delete this item?'), 'data-method' => 'post', 'data-pjax' => '0'], $this->buttonOptions);
return Html::a('<span class="fa fa-trash-o"></span>', $url, $options);
};
}
}
示例8: defaultColumns
public static function defaultColumns()
{
return ['zone' => ['class' => MainColumn::className(), 'label' => Yii::t('hipanel:dns', 'Zone'), 'attribute' => 'name'], 'domain' => ['class' => MainColumn::className(), 'filterAttribute' => 'domain_like'], 'idn' => ['class' => MainColumn::className(), 'filterAttribute' => 'idn_like'], 'actions' => ['class' => MenuColumn::class, 'menuClass' => DnsActionsMenu::class], 'nss' => ['format' => 'raw', 'attribute' => 'nss_like', 'label' => Yii::t('hipanel:dns', 'NS servers'), 'value' => function ($model) {
return ArraySpoiler::widget(['data' => $model->nss]);
}], 'dns_on' => ['format' => 'raw', 'filter' => function ($column, $model, $attribute) {
return Html::activeDropDownList($model, $attribute, ['' => Yii::t('hipanel:dns', '---'), '1' => Yii::t('hipanel:dns', 'Enabled'), '0' => Yii::t('hipanel:dns', 'Disabled')], ['class' => 'form-control']);
}, 'value' => function ($model) {
return Label::widget(['color' => $model->dns_on ? 'success' : '', 'label' => $model->dns_on ? Yii::t('hipanel:dns', 'Enabled') : Yii::t('hipanel:dns', 'Disabled'), 'labelOptions' => ['title' => Yii::t('hipanel:dns', 'Means that the panel will publish DNS records on the NS servers')]]);
}], 'bound_to' => ['format' => 'raw', 'label' => Yii::t('hipanel:dns', 'Bound to'), 'value' => function ($model) {
if (Yii::getAlias('@domain') !== null && $model->is_reg_domain) {
return Html::a(Yii::t('hipanel:dns', 'Registered domain'), ['@domain/view', 'id' => $model->id]);
} elseif ($model->server_id) {
return Html::a($model->account . '@' . $model->server, ['@hdomain/view', 'id' => $model->id]);
} else {
return Yii::$app->formatter->nullDisplay;
}
}]];
}
示例9: torMenu
public function torMenu($parent = null, $level = 1)
{
$links = Links::find()->where(['categories_id' => $this->categories_id, 'parent' => $parent])->orderBy(['seq' => SORT_ASC])->all();
$items = Html::beginTag('ul', ['class' => 'tor-nav-' . $level . ' ' . ($level > 2 ? 'list-unstyled' : 'list-inline')]);
/** @var $link Links */
foreach ($links as $link) {
$items .= '<li>' . Html::a($link->anchor, $link->url);
if ($link->child_exist == 1) {
if ($link->level == 1) {
$items .= '<span class="caret"></span>' . Html::tag('div', $this->torMenu($link->id, $link->level + 1), ['class' => 'tor-sub-nav']);
} else {
$items .= $this->torMenu($link->id, $link->level + 1);
}
}
$items .= '</li>';
}
$items .= Html::endTag('ul');
return $items;
}
示例10: run
/**
* @inheritdoc
*/
public function run()
{
if ($this->user->isCurrentUser() || \Yii::$app->user->isGuest) {
return;
}
// Add class for javascript handling
$this->followOptions['class'] .= ' followButton';
$this->unfollowOptions['class'] .= ' unfollowButton';
// Hide inactive button
if ($this->user->isFollowedByUser()) {
$this->followOptions['style'] .= ' display:none;';
} else {
$this->unfollowOptions['style'] .= ' display:none;';
}
// Add UserId Buttons
$this->followOptions['data-userid'] = $this->user->id;
$this->unfollowOptions['data-userid'] = $this->user->id;
$this->view->registerJsFile('@web/resources/user/followButton.js');
return Html::a($this->unfollowLabel, $this->user->createUrl('/user/profile/unfollow'), $this->unfollowOptions) . Html::a($this->followLabel, $this->user->createUrl('/user/profile/follow'), $this->followOptions);
}
示例11: run
public function run()
{
parent::run();
$content = Html::submitButton($this->model->isNewRecord ? self::t('messages', 'Create') : self::t('messages', 'Update'), ['class' => $this->model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
$jsCreateClose = <<<JS
var action = \$(this).parents('form').attr('action');
var submitButton = \$(this).parent().find('button[type=submit]');
\$(this).parents('form').attr('action', action + '&close=true');
submitButton.click();
return false;
JS;
$content .= ' ' . Html::a($this->model->isNewRecord ? self::t('messages', 'Create and close') : self::t('messages', 'Update and close'), '#', ['class' => 'btn btn-default btn-sm', 'onclick' => $jsCreateClose]);
$returnUrl = null;
if (\Yii::$app->controller->defaultAction === null) {
$returnUrl = \Yii::$app->user->returnUrl;
} else {
$returnUrl = [\Yii::$app->controller->defaultAction];
}
$content .= ' ' . Html::a(self::t('messages', 'Close'), $returnUrl, ['class' => 'btn btn-default btn-sm']);
$content = Html::tag('div', $content, ['class' => 'col-sm-8']) . Html::tag('div', $this->getInfoRecord(), ['class' => 'col-sm-4 text-right']);
return Html::tag('div', $content, ['class' => 'form-group well row']);
}
示例12: successMessage
/**
* @inheritdoc
*/
public function successMessage()
{
if (Yii::$app->hasModule($this->moduleID)) {
$link = Html::a('try it now', Yii::$app->getUrlManager()->createUrl($this->moduleID), ['target' => '_blank']);
return "The module has been generated successfully. You may {$link}.";
}
$output = <<<EOD
<p>The module has been generated successfully.</p>
<p>To access the module, you need to add this to your application configuration:</p>
EOD;
$code = <<<EOD
<?php
......
'modules' => [
'{$this->moduleID}' => [
'class' => '{$this->moduleClass}',
],
],
......
EOD;
return $output . '<pre>' . highlight_string($code, true) . '</pre>';
}
示例13: 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);
}
};
}
}
示例14:
echo FA::fw('bar-chart-o');
?>
Charts<?php
echo $arrowIcon;
?>
</a>
<?php
echo Nav::widget(['encodeLabels' => false, 'options' => ['class' => 'nav nav-second-level'], 'items' => [['label' => 'Flot Charts', 'url' => ['/site/page', 'view' => 'flot']], ['label' => 'Morris.js Charts', 'url' => ['/site/page', 'view' => 'morris']]]]);
?>
</li><!-- Charts -->
<li><?php
echo Html::a(FA::fw('table') . 'Tables', Url::to(['/site/page', 'view' => 'tables']));
?>
</li><!-- Tables -->
<li><?php
echo Html::a(FA::fw('edit') . 'Forms', Url::to(['/site/page', 'view' => 'forms']));
?>
</li><!-- Forms -->
<li>
<a href="#"><?php
echo FA::fw('calendar');
?>
Calendar</a>
<!-- <a href="calendar.php"><?php
echo FA::fw('calendar');
?>
Calendar</a> -->
</li><!-- Calendar -->
<li>
<a href="#"><?php
echo FA::fw('wrench');
示例15: function
<button type="button" class="btn btn-default btn-sm checkDeleted"><i class="fa fa-trash-o"></i></button>
<button type="button" class="btn btn-default btn-sm checkPublish"><i class="fa fa-eye"></i></button>
<button type="button" class="btn btn-default btn-sm checkUnpublish"><i class="fa fa-eye-slash"></i></button>
</div>
<button type="button" class="btn btn-default btn-sm checkSeed"><i class="fa fa-check"></i></button>', 'footer' => '<div class="btn-group">
<button type="button" class="btn btn-default btn-sm checkDeleted"><i class="fa fa-trash-o"></i></button>
<button type="button" class="btn btn-default btn-sm checkPublish"><i class="fa fa-eye"></i></button>
<button type="button" class="btn btn-default btn-sm checkUnpublish"><i class="fa fa-eye-slash"></i></button>
</div>
<button type="button" class="btn btn-default btn-sm checkSeed"><i class="fa fa-check"></i></button>'], 'panelTemplate' => '<div class="panel {type}">{panelHeading}{items}{panelFooter}<div class="text-center">{pager}</div></div>', 'panelFooterTemplate' => '{footer}<div class="clearfix"></div>', 'dataProvider' => $comments, 'bordered' => false, 'summary' => false, 'hover' => true, 'id' => 'commentsGrid', 'pjax' => true, 'pjaxSettings' => ['linkSelector' => '#commentsGrid .pagination a'], 'striped' => false, 'layout' => '{items}', 'containerOptions' => ['class' => 'box-body table-responsive no-padding'], 'resizableColumns' => false, 'columns' => [['class' => \kartik\grid\CheckboxColumn::className()], ['format' => 'raw', 'attribute' => 'author', 'hAlign' => GridView::ALIGN_CENTER, 'vAlign' => GridView::ALIGN_MIDDLE, 'value' => function ($model) {
return Html::tag('span', $model->author, ['title' => "IP: {$model->ip} email: {$model->email}", 'data-toggle' => 'tooltip']);
}], ['label' => 'Статья', 'format' => 'raw', 'value' => function ($model) {
if (empty($model->news)) {
return 'отсутствует';
}
return Html::a($model->news->title, '/news/show/' . $model->news->id, ['class' => 'longLink newsTitle']);
}], ['attribute' => 'text', 'format' => 'html', 'hAlign' => GridView::ALIGN_LEFT, 'vAlign' => GridView::ALIGN_MIDDLE, 'value' => function ($model) {
return Html::tag('span', $model->text, ['class' => 'longLink commentText']);
}], ['attribute' => 'date', 'hAlign' => GridView::ALIGN_CENTER, 'vAlign' => GridView::ALIGN_MIDDLE, 'value' => function ($model) {
return \Yii::$app->formatter->asRelativeTime($model->date);
}], ['header' => ' ', 'width' => '100px', 'hAlign' => GridView::ALIGN_CENTER, 'vAlign' => GridView::ALIGN_MIDDLE, 'class' => \kartik\grid\ActionColumn::className(), 'buttons' => ['view' => function ($key, $model) {
return Html::button(FA::i($model->published == 1 ? 'eye' : 'eye-slash'), ['class' => 'publishComment btn btn-sm btn-default']);
}, 'update' => function ($model) {
return Html::button(FA::i('pencil'), ['class' => 'editComment btn btn-sm btn-default']);
}], 'template' => Html::tag('div', '{view}{update}', ['class' => 'btn-group btn-group-sm'])]]]);
?>
</div>
</div>
</div>
</div>
<?php