本文整理汇总了PHP中yii\helpers\Url::canonical方法的典型用法代码示例。如果您正苦于以下问题:PHP Url::canonical方法的具体用法?PHP Url::canonical怎么用?PHP Url::canonical使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\helpers\Url
的用法示例。
在下文中一共展示了Url::canonical方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
SelectAsset::register($this->view);
FilterAsset::register($this->view);
$values = [];
foreach ($this->data as $value) {
$value = strval($value);
$values[$value] = $value;
}
if (!$this->default) {
$this->default = $this->multiple ? array_keys($values) : key($values);
}
$selected = $this->selected($this->default);
// Setup options
$options = ['id' => $this->name, 'name' => $this->name . '[]', 'style' => 'width: 300px;', 'class' => 'selectpicker'];
$extra = ['title' => 'Not selected'];
if ($this->multiple) {
$extra['multiple'] = 'multiple';
}
if ($this->placeholder) {
$extra['title'] = strval($this->placeholder);
}
$options = array_merge($options, $extra);
if (!$this->method) {
$this->method = 'get';
}
// Render
echo Html::beginForm(Url::canonical(), $this->method, ['data-pjax' => '1', 'id' => $this->name]);
echo Html::beginTag('select', $options, ['data-pjax' => '1']);
echo Html::renderSelectOptions($selected, $values);
echo Html::endTag("select");
echo Html::endForm();
parent::run();
}
示例2: beforeAction
/**
* @inheritdoc
*/
public function beforeAction($action)
{
if (parent::beforeAction($action)) {
$this->view->registerLinkTag(['rel' => 'canonical', 'href' => Url::canonical()]);
if (\Yii::$app->request->get('page') == 1) {
$this->redirect(str_replace('/page/1', '', \Yii::$app->request->getUrl()));
}
return true;
} else {
return false;
}
}
示例3: run
public function run()
{
$id = $this->getId();
echo Html::beginForm(Url::canonical(), 'get', ['data-pjax' => '1', 'id' => $this->name]);
echo Html::beginTag('div');
echo Html::beginTag("select", ['id' => $id, 'multiple' => 'multiple', 'class' => 'invisible', 'style' => 'width: ' . $this->width . 'px;', 'name' => $this->name . '[]']);
echo Html::renderSelectOptions($this->selectedValues, $this->_allValues);
echo Html::endTag("select");
echo Html::submitButton('OK', ['style' => 'margin: 0 5px;']);
echo Html::endTag('div');
echo Html::endForm();
echo "<script type='text/javascript'>";
echo "\$('#{$id}').removeClass('invisible');";
echo "\$('#{$id}').multipleSelect()";
echo "</script>";
}
示例4:
<?php
use thedollarsign\themes\adminlte\ThemeAsset;
use yii\helpers\Html;
use yii\helpers\Url;
?>
<title><?php
echo Html::encode($this->title);
?>
</title>
<?php
$this->head();
ThemeAsset::register($this);
$this->registerMetaTag(['charset' => Yii::$app->charset]);
$this->registerMetaTag(['name' => 'viewport', 'content' => 'width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no']);
$this->registerLinkTag(['rel' => 'canonical', 'href' => Url::canonical()]);
echo Html::csrfMetaTags();
?>
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
示例5:
$( this ).off( event );
});
JS
);
?>
<title><?php
echo Html::encode($this->title);
?>
</title>
<?php
echo Html::csrfMetaTags();
?>
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
<meta charset="<?php
echo Yii::$app->charset;
?>
">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<meta rel="canonical" href="<?php
echo Url::canonical();
?>
"/>
<?php
$this->head();
示例6: _prepareVars
/**
* Init default variables for autoreplace
*
* @return $this
*/
protected function _prepareVars()
{
$this->setVar(['HOME_URL' => Url::home(true), 'CANONICAL_URL' => Url::canonical(), 'LOCALE' => Yii::$app->formatter->locale]);
return $this;
}
示例7: actionPublish
public function actionPublish()
{
//Publish it
$_file = Yii::getAlias('@apisDirectory') . '/' . ucfirst($this->_core);
$swagger = new Swagger($_file);
$actual_link = str_replace('/rebuildschema/publish', '', Url::canonical());
$writeFiles = new FileManipulation();
$writeFiles->setFilename(ucfirst($this->_core) . '/api-docs.json');
$writeFiles->write_file($swagger->getResourceList(array('output' => 'json', 'basePath' => $actual_link . '/api-docs/Core')));
foreach ($swagger->registry as $api_name => $api) {
$writeFiles->setFilename(ucfirst($this->_core) . '/' . $api_name);
$writeFiles->write_file($swagger->getResource($api_name, array('output' => 'json')));
}
return $this->redirect(['index']);
}
示例8:
<?php
echo Html::a('Delete', ['delete', 'id' => $model->id_product], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Are you sure you want to delete this item?', 'method' => 'post']]);
?>
</div>
</div>
</div>
<div class="col-lg-6">
<style>
.tab-content {
border: 1px #e0e0e0 solid;
border-top: none;
padding: 20px;
}
</style>
<?php
Pjax::begin(['id' => 'pjax', 'enablePushState' => false, 'clientOptions' => ['url' => \yii\helpers\Url::canonical()]]);
?>
<?php
echo Html::beginForm('', 'post', ['id' => 'input-form', 'data-pjax' => '#pjax']);
?>
<?php
echo Html::hiddenInput('action');
?>
<?php
echo Tabs::widget(['items' => [['label' => 'Uoms', 'content' => $this->render('_form_uom', ['model' => $model]), 'active' => $active == 'uom'], ['label' => 'Barcode', 'content' => $this->render('_form_barcode', ['model' => $model]), 'active' => $active == 'barcode']]]);
?>
</div>
<?php
echo Html::endForm();
Pjax::end();
示例9: actionWadl
public function actionWadl($id)
{
$apiName = $this->actionPublish($id);
$basePathPart = Url::canonical();
$basePathPart = explode('swagger', $basePathPart);
$basePathPart = explode('hydra', $basePathPart[0]);
$basePathPart = explode('raml', $basePathPart[0]);
$basePathPart = explode('wadl', $basePathPart[0]);
$basePathPart = explode('/apis/', $basePathPart[0]);
$basePathPart[0] .= '/api-docs/';
$url = 'http://imagine.epu.ntua.gr:2015/transform/?location=';
$url .= $basePathPart[0] . $apiName . '/api-docs.json';
$url .= '&original_format=swagger&to_format=wadl';
$response = Yii::$app->getResponse();
$response->sendContentAsFile(file_get_contents($url), 'wadl.xml');
Yii::$app->end();
}
示例10: function
$this->params['breadcrumbs'][] = $this->title;
echo Html::csrfMetaTags();
?>
<div class="sale-order-index">
<h1><?php
echo Html::encode($this->title);
?>
</h1>
<?php
// echo $this->render('_search', ['model' => $searchModel]);
?>
<p>
<?php
echo Html::beginForm(Url::canonical(), 'get', []);
?>
<?php
echo Html::textInput('page', null, ['placeholder' => 'Go to Page', 'style' => 'width:80px;']);
?>
<?php
echo Html::endForm();
?>
</p>
<?php
$url = \yii\helpers\Url::to(['sale-order/get-all-user-list']);
$url2 = \yii\helpers\Url::to(['sale-order/get-all-creator-list']);
// Script to initialize the selection based on the value of the select2 element
$script = function ($uri) {
return 'function (element, callback) {
var id=$(element).val();
示例11: testCanonical
public function testCanonical()
{
$this->mockAction('page', 'view', null, ['id' => 10]);
$this->assertEquals('http://example.com/base/index.php?r=page%2Fview&id=10', Url::canonical());
$this->removeMockedAction();
}
示例12: urldecode
?>
">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="robots" content="index, follow">
<meta name="author" content="Jafaripur">
<meta name="rating" content="general">
<?php
echo Html::csrfMetaTags();
?>
<link rel="canonical" href="<?php
echo urldecode(Url::canonical());
?>
">
<meta property="og:url" content="<?php
echo urldecode(Url::canonical());
?>
" />
<meta property="og:title" content="<?php
echo Html::encode($this->title);
?>
" />
<meta property="fb:app_id" content="348428045334410" />
<meta property="article:author" content="https://www.facebook.com/jafaripur" />
<?php
//<meta property="article:publisher" content="https://www.facebook.com/cnn" />
?>
<link rel='alternate' type='application/rss+xml' title='RSS' href='<?php
echo Url::to(['/feed/rss'], true);
?>
'>
示例13:
<?php
use yii\helpers\Html;
use yii\widgets\ListView;
if (count(Yii::$app->request->get())) {
$this->registerLinkTag(['rel' => 'canonical', 'href' => \yii\helpers\Url::canonical()]);
}
$this->title = $category->metaTitle;
$this->registerMetaTag(['name' => 'description', 'content' => $category->metaDescription]);
$this->registerMetaTag(['name' => 'keywords', 'content' => $category->metaDescription]);
$this->params['breadcrumbs'] = array_merge($this->params['breadcrumbs'], $category->breadcrumbs);
$layout = $app->itemsColumns > 1 ? '<div class="uk-grid uk-grid-width-medium-1-' . $app->itemsColumns . ' uk-grid-match items" data-uk-grid-margin>{items}</div>' : '<div class="items">{items}</div><div class="pager">{pager}</div>';
if ($app->itemsSort) {
$layout = '<div class="sorter">Упорядочить по {sorter}</div>' . $layout;
}
$pjaxId = $app->name . '-category';
?>
<div class="<?php
echo $app->name;
?>
<?php
echo $app->name;
?>
-category">
<?php
\yii\widgets\Pjax::begin(['id' => $pjaxId, 'timeout' => 5000, 'options' => ['data-uk-observe' => true]]);
?>
<h1><?php
echo Html::encode($category->name);
示例14:
<?php
/**
* Created by PhpStorm.
* User: albert
* Date: 15.03.15
* Time: 18:28
* @var $this \yii\base\View
* @var $context \common\widgets\Share
*/
$context = $this->context;
use ijackua\sharelinks\ShareLinks;
use yii\helpers\Html;
Yii::$app->view->registerMetaTag(['name' => "keywords", 'content' => $context->title]);
Yii::$app->view->registerMetaTag(['property' => "og:type", 'content' => 'article']);
Yii::$app->view->registerMetaTag(['property' => "og:url", 'content' => \yii\helpers\Url::canonical()]);
Yii::$app->view->registerMetaTag(['property' => "og:image", 'itemprop' => "image primaryImageOfPage", 'content' => $context->image]);
//twitter
Yii::$app->view->registerMetaTag(['name' => "twitter:card", 'content' => 'summary']);
Yii::$app->view->registerMetaTag(['name' => "twitter:domain", 'content' => Yii::$app->getHomeUrl()]);
Yii::$app->view->registerMetaTag(['name' => "twitter:title", 'property' => 'og:title', 'itemprop' => 'title name', 'content' => \common\helpers\String::truncate($context->title, 140)]);
Yii::$app->view->registerMetaTag(['name' => "twitter:description", 'property' => "og:description", 'itemprop' => "description", 'content' => \common\helpers\String::truncate($context->description, 140)]);
Yii::$app->view->registerMetaTag(['name' => "twitter:image", 'content' => $context->image]);
?>
<div class="socialShareBlock">
<?php
echo Html::a('', $context->shareUrl(ShareLinks::SOCIAL_FACEBOOK), ['title' => 'Поделиться в Facebook', 'class' => "socicon socicon-facebook"]);
?>
<?php
echo Html::a('', $context->shareUrl(ShareLinks::SOCIAL_TWITTER), ['title' => 'Поделиться в Twitter', 'class' => "socicon socicon-twitter"]);
?>
示例15:
?>
<title><?= Html::encode($this->title); ?></title>
<?= Html::csrfMetaTags(); ?>
<?php $this->head(); ?>
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
<?php AppAsset::register($this);
$this->registerMetaTag(
[
'charset' => Yii::$app->charset
]
);
$this->registerMetaTag(
[
'name' => 'viewport',
'content' => 'width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no'
]
);
$this->registerLinkTag(
[
'rel' => 'canonical',
'href' => Url::canonical()
]
); ?>