本文整理汇总了PHP中yii\helpers\Html::a方法的典型用法代码示例。如果您正苦于以下问题:PHP Html::a方法的具体用法?PHP Html::a怎么用?PHP Html::a使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\helpers\Html
的用法示例。
在下文中一共展示了Html::a方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionIndex
/**
* Lists all StaticPageTable models.
* @return mixed
*/
public function actionIndex()
{
if (!Yii::$app->user->can('static-page-table/index')) {
Yii::$app->session->setFlash('error', 'Нет доступа!');
return $this->redirect('/');
}
if (isset($_POST['sort_list_2'])) {
$mas = explode(',', $_POST['sort_list_2']);
for ($i = 0; $i <= sizeof($mas) - 1; $i++) {
$model = $this->findModel($mas[$i]);
$model->position = $i;
$model->save();
}
}
$staticPagesTrue = StaticPageTable::find()->where(['status' => 1])->orderBy(['position' => SORT_ASC])->all();
$staticPagesFalse = StaticPageTable::find()->where(['status' => 0])->orderBy(['position' => SORT_ASC])->all();
$list = [];
$value = "";
foreach ($staticPagesTrue as $statispage) {
$list[$statispage->id] = ['content' => Html::a(FA::icon($statispage->icon) . " " . $statispage->name, ['view', 'url' => $statispage->url])];
$value .= $statispage->id . ",";
}
foreach ($staticPagesFalse as $statispage) {
$list[$statispage->id] = ['content' => Html::a(FA::icon($statispage->icon) . " " . $statispage->name, ['view', 'url' => $statispage->url]), 'disabled' => true];
$value .= $statispage->id . ",";
}
$value = substr($value, 0, -1);
return $this->render('index', ['list' => $list, 'value' => $value]);
}
示例2: run
public function run()
{
if ($this->encode) {
$this->text = Html::encode($this->text);
}
if (!$this->minimal) {
$maxOembedCount = 3;
// Maximum OEmbeds
$oembedCount = 0;
// OEmbeds used
$this->text = preg_replace_callback('/(https?:\\/\\/.*?)(\\s|$)/i', function ($match) use(&$oembedCount, &$maxOembedCount) {
// Try use oembed
if ($maxOembedCount > $oembedCount) {
$oembed = UrlOembed::GetOembed($match[0]);
if ($oembed) {
$oembedCount++;
return $oembed;
}
}
return Html::a($match[1], Html::decode($match[1]), array('target' => '_blank')) . $match[2];
}, $this->text);
}
// get user and space details from guids
$this->text = self::translateMentioning($this->text, $this->minimal ? false : true);
// create image tag for emojis
$this->text = self::translateEmojis($this->text, $this->minimal ? false : true);
if ($this->maxLength != 0) {
$this->text = \humhub\libs\Helpers::truncateText($this->text, $this->maxLength);
}
return nl2br($this->text);
}
示例3: defaultColumns
public static function defaultColumns()
{
return ['fqdn' => ['attribute' => 'fqdn', 'value' => function ($model) {
return $model->fqdn;
}], 'type' => ['value' => function ($model) {
return strtoupper($model->type);
}], 'value' => ['value' => function ($model) {
return $model->getValueText();
}], 'zone' => ['class' => MainColumn::className(), 'label' => Yii::t('hipanel:dns', 'Zone'), 'attribute' => 'name'], 'actions' => ['class' => ActionColumn::className(), 'template' => '{update} {delete}', 'visibleButtonsCount' => 2, 'options' => ['style' => 'width: 15%'], 'buttons' => ['update' => function ($url, $model, $key) {
if ($model->is_system) {
return Html::tag('div', Html::a('<i class="fa fa-pencil"></i> ' . Yii::t('hipanel', 'Update'), null, ['class' => 'btn btn-default btn-xs disabled']), ['data-placement' => 'top', 'data-toggle' => 'tooltip', 'title' => Yii::t('hipanel:dns', 'This record was created by hosting panel automatically and cannot be updated'), 'style' => 'display: inline-block; cursor: not-allowed;']);
}
$data = Html::a('<i class="fa fa-pencil"></i> ' . Yii::t('hipanel', 'Update'), null, ['class' => 'btn btn-default btn-xs edit-dns-toggle', 'data' => ['record_id' => $model->id, 'hdomain_id' => $model->hdomain_id, 'load-url' => Url::to(['@dns/record/update', 'hdomain_id' => $model->hdomain_id, 'id' => $model->id])]]);
$progress = Json::htmlEncode("<tr><td colspan='5'>" . Progress::widget(['id' => 'progress-bar', 'percent' => 100, 'barOptions' => ['class' => 'active progress-bar-striped', 'style' => 'width: 100%']]) . '</td></tr>');
Yii::$app->view->registerJs("\n \$('.edit-dns-toggle').click(function () {\n var record_id = \$(this).data('id');\n var hdomain_id = \$(this).data('hdomain_id');\n\n var currentRow = \$(this).closest('tr');\n var newRow = \$({$progress});\n\n \$(newRow).data({'record_id': record_id, hdomain_id: hdomain_id});\n \$('tr').filter(function () { return \$(this).data('id') == record_id; }).find('.btn-cancel').click();\n \$(newRow).insertAfter(currentRow);\n\n jQuery.ajax({\n url: \$(this).data('load-url'),\n type: 'GET',\n timeout: 0,\n error: function() {\n\n },\n success: function(data) {\n newRow.find('td').html(data);\n newRow.find('.btn-cancel').on('click', function (event) {\n event.preventDefault();\n newRow.remove();\n });\n }\n });\n\n });\n ");
return $data;
}, 'delete' => function ($url, $model, $key) {
if ($model->type === 'ns' && $model->is_system) {
return Html::tag('div', Html::a('<i class="fa text-danger fa-trash-o"></i> ' . Yii::t('hipanel', 'Delete'), null, ['class' => 'btn btn-default btn-xs disabled']), ['data-placement' => 'top', 'data-toggle' => 'tooltip', 'title' => Yii::t('hipanel:dns', 'This record is important for the domain zone viability and can not be deleted'), 'style' => 'display: inline-block; cursor: not-allowed;']);
}
return ModalButton::widget(['model' => $model, 'scenario' => 'delete', 'submit' => ModalButton::SUBMIT_PJAX, 'form' => ['action' => Url::to('@dns/record/delete')], 'button' => ['class' => 'btn btn-default btn-xs', 'label' => '<i class="fa text-danger fa-trash-o"></i> ' . Yii::t('hipanel', 'Delete')], 'modal' => ['header' => Html::tag('h4', Yii::t('hipanel:dns', 'Confirm DNS record deleting')), 'headerOptions' => ['class' => 'label-danger'], 'footer' => ['label' => Yii::t('hipanel:dns', 'Delete record'), 'data-loading-text' => Yii::t('hipanel:dns', 'Deleting record...'), 'class' => 'btn btn-danger']], 'body' => function ($model) {
echo Html::activeHiddenInput($model, 'hdomain_id');
echo Yii::t('hipanel:dns', 'Are you sure, that you want to delete record {name}?', ['name' => $model->fqdn]);
}]);
}]]];
}
示例4: renderItems
protected function renderItems($items, $options = [])
{
$lines = [];
foreach ($items as $i => $item) {
if (isset($item['visible']) && !$item['visible']) {
continue;
}
if (is_string($item)) {
$lines[] = $item;
continue;
}
if (!array_key_exists('label', $item)) {
throw new InvalidConfigException("The 'label' option is required.");
}
$encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabels;
$label = $encodeLabel ? Html::encode($item['label']) : $item['label'];
$itemOptions = ArrayHelper::getValue($item, 'options', []);
$linkOptions = ArrayHelper::getValue($item, 'linkOptions', []);
$linkOptions['tabindex'] = '-1';
$url = array_key_exists('url', $item) ? $item['url'] : null;
if (empty($item['items'])) {
if ($url === null) {
$content = $label;
} else {
$content = Html::a($label, $url, $linkOptions);
}
} else {
$submenuOptions = $options;
unset($submenuOptions['id']);
$content = Html::a($label, $url === null ? '#' : $url, $linkOptions) . $this->renderItems($item['items'], $submenuOptions);
}
$lines[] = Html::tag('li', $content, $itemOptions);
}
return Html::tag('ul', implode("\n", $lines), $options);
}
示例5: actionIndex
public function actionIndex()
{
$actions = [];
$rc = new \ReflectionClass($this);
$publicMethods = $rc->getMethods(\ReflectionMethod::IS_PUBLIC);
$availableActions = [];
foreach ($publicMethods as $publicMethod) {
$methodName = $publicMethod->name;
if ($methodName == 'actions') {
continue;
}
if (StringHelper::startsWith($methodName, 'action')) {
$availableActions[] = $methodName;
}
}
if (count($this->actions()) > 0) {
$availableActions = $availableActions + array_keys($this->actions());
}
$menus = [];
foreach ($availableActions as $actionName) {
$routeId = Inflector::camel2id(substr($actionName, strlen('action')));
$menus[] = Html::a($actionName, [$routeId]);
}
echo implode('<br/>', $menus);
}
示例6: sendMail
public function sendMail()
{
/* @var $user User */
$user = User::findOne(['status' => User::STATUS_ACTIVE, 'email' => $this->email]);
if ($user) {
if (!User::isPasswordResetTokenValid($user->password_reset_token)) {
$user->generatePasswordResetToken();
}
if ($user->save()) {
$setting = Setting::find()->where(['id' => 1])->one();
$username = $setting->sendgridUsername;
$password = $setting->sendgridPassword;
$mail_admin = $setting->emailAdmin;
$sendgrid = new \SendGrid($username, $password, array("turn_off_ssl_verification" => true));
$email = new \SendGrid\Email();
$mail = $user->email;
//echo $user->email;exit(0);
$resetLink = \Yii::$app->urlManager->createAbsoluteUrl(['site/reset-password', 'token' => $user->password_reset_token]);
$body_message = 'Hello ' . Html::encode($user->username) . ', <br>
Follow the link below to reset your password: <br>
' . Html::a(Html::encode($resetLink), $resetLink);
$email->addTo($user->email)->setFrom($mail_admin)->setSubject('Password reset for ' . \Yii::$app->name)->setHtml($body_message);
$response = $sendgrid->send($email);
//print_r($response); exit(0);
return $response;
}
}
return false;
}
示例7: init
public function init()
{
parent::init();
$this->content = function (ModelBase $model, $key, $index, DataColumn $column) {
return Html::a($model->{$column->attribute}, ['view', 'id' => $model->primaryKey], ['title' => Yii::t('common', 'View')]);
};
}
示例8: getCategoryParentsLinks
/**
* @param Model $model
* @return string
*/
public static function getCategoryParentsLinks(Model $model)
{
$parents = array_map(function (Model $model) {
return Html::a($model->title, ['view', 'id' => $model->id]);
}, $model->parents);
return implode(', ', $parents);
}
示例9: run
function run()
{
foreach ($this->data as $n => $v) {
if (isset($this->{$n})) {
$this->{$n} = $v;
}
}
$this->view->registerCssFile('http://code.ionicframework.com/ionicons/1.5.2/css/ionicons.min.css');
$link = $this->link;
if (is_array($link)) {
$link = Url::to($link);
}
if ($this->link_text === null) {
$this->link_text = \Yii::t('app', 'More info');
}
$html = "<!-- small box -->\n";
$html .= "<div class=\"col-lg-3 col-xs-6\">\n";
$html .= " <div class=\"small-box {$this->color}\">\n";
$html .= " <div class=\"inner\">";
$html .= Html::tag('h3', $this->count . Html::tag('sup', $this->count_type, ['style' => "font-size: 20px"]));
$html .= Html::tag('p', $this->text);
$html .= "</div>\n";
$html .= " <div class=\"icon\">";
$html .= Html::tag('i', '', ['class' => 'ion ' . $this->icon]);
$html .= "</div>\n";
$html .= " ";
$html .= Html::a($this->link_text . " <i class=\"fa fa-arrow-circle-right\"></i>", $link, ['class' => 'small-box-footer']);
$html .= " </div>";
$html .= "</div>";
return $html;
}
示例10: run
public function run()
{
return Html::ul($this->flatPageList, ['class' => $this->htmlClass, 'item' => function ($flatPage, $index) {
$class = $flatPage->url == Yii::$app->controller->action->id ? $this->activeLiClass : null;
return Html::tag('li', Html::a($flatPage->anchor, [$flatPage->url]), ['class' => $class]);
}]);
}
示例11: actions
/**
* @return string $template
* @return mixed
*/
public function actions($template = '{update} {delete}')
{
$this->columns = array_merge($this->columns, [['class' => ActionColumn::className(), 'controller' => SELF::CONTROLLER, 'template' => $template, 'buttons' => ['update' => function ($url, $model, $key) {
return Html::a('<i class="fa fa-pencil"></i>', false, ['value' => Url::to([SELF::CONTROLLER . '/update', 'id' => $model->id]), 'title' => 'Update', 'class' => 'showModalButton']);
}], 'contentOptions' => ['class' => 'text-right']]]);
return $this;
}
示例12: a
/**
* Hide link if user hasn't access to it
*
* @inheritdoc
*/
public static function a($text, $url = null, $options = [])
{
if (in_array($url, [null, '', '#'])) {
return parent::a($text, $url, $options);
}
return User::canRoute($url) ? parent::a($text, $url, $options) : '';
}
示例13: api_widget
public function api_widget($width, $height, $clientOptions = [])
{
if (!count($this->_items)) {
return LIVE_EDIT ? Html::a(Yii::t('easyii/carousel/api', 'Create carousel'), ['/admin/carousel/a/create'], ['target' => '_blank']) : '';
}
if (count($clientOptions)) {
$this->clientOptions = array_merge($this->clientOptions, $clientOptions);
}
$items = [];
foreach ($this->_items as $item) {
$temp = ['content' => Html::img($item->thumb($width, $height)), 'caption' => ''];
if ($item->link) {
$temp['content'] = Html::a($temp['content'], $item->link);
}
if ($item->title) {
$temp['caption'] .= '<h3>' . $item->title . '</h3>';
}
if ($item->text) {
$temp['caption'] .= '<p>' . $item->text . '</p>';
}
$items[] = $temp;
}
$widget = \yii\bootstrap\Carousel::widget(['options' => ['class' => 'slide'], 'clientOptions' => $this->clientOptions, 'items' => $items]);
return LIVE_EDIT ? API::liveEdit($widget, Url::to(['/admin/carousel']), 'div') : $widget;
}
示例14: nameWithLink
/**
* @return mixed
*/
public function nameWithLink()
{
$this->columns = array_merge($this->columns, [['attribute' => 'name', 'value' => function ($model, $key, $index, $column) {
return Html::a(Html::encode($model->name), [SELF::CONTROLLER . '/view', 'id' => $model->id]);
}, 'format' => 'raw']]);
return $this;
}
示例15: run
/**
* Renders the widget.
* @return string
*/
public function run()
{
echo Html::a('', false, ['name' => 'footer']);
echo Html::beginTag('footer', ['class' => 'c-layout-footer c-layout-footer-4 c-bg-footer-8']);
echo Html::beginTag('div', ['class' => 'c-footer']);
echo Html::beginTag('div', ['class' => 'container']);
echo Html::beginTag('div', ['class' => 'row']);
echo Html::beginTag('div', ['class' => 'col-md-6 c-footer-4-p-right']);
echo Html::beginTag('div', ['class' => 'c-content-title-1']);
echo Html::tag('h3', $this->title, ['class' => 'c-font-uppercase c-font-bold c-font-white c-border']);
echo Html::endTag('div');
echo Html::tag('p', $this->about, ['class' => 'c-about']);
echo Html::tag('ul', $this->social, ['class' => 'c-socials']);
echo Html::endTag('div');
echo Html::beginTag('div', ['class' => 'col-md-6 c-footer-4-p-right']);
echo Html::beginTag('div', ['class' => 'c-feedback']);
echo Html::tag('h3', 'CONTACT', ['class' => 'c-font-thin']);
echo Html::tag('p', $this->contact, ['class' => 'c-contact c-font-white']);
echo Html::endTag('div');
echo Html::endTag('div');
echo Html::endTag('div');
echo Html::endTag('div');
echo Html::endTag('div');
echo Html::endTag('footer');
}