本文整理汇总了PHP中yii\helpers\Url::current方法的典型用法代码示例。如果您正苦于以下问题:PHP Url::current方法的具体用法?PHP Url::current怎么用?PHP Url::current使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\helpers\Url
的用法示例。
在下文中一共展示了Url::current方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: api_form
public function api_form($options = [])
{
$model = new FeedbackModel();
$settings = Yii::$app->getModule('admin')->activeModules['feedback']->settings;
$options = array_merge($this->_defaultFormOptions, $options);
ob_start();
$form = ActiveForm::begin(['enableClientValidation' => true, 'action' => Url::to(['/admin/feedback/send'])]);
echo Html::hiddenInput('errorUrl', $options['errorUrl'] ? $options['errorUrl'] : Url::current([self::SENT_VAR => 0]));
echo Html::hiddenInput('successUrl', $options['successUrl'] ? $options['successUrl'] : Url::current([self::SENT_VAR => 1]));
echo $form->field($model, 'name');
echo $form->field($model, 'email')->input('email');
if ($settings['enablePhone']) {
echo $form->field($model, 'phone');
}
if ($settings['enableTitle']) {
echo $form->field($model, 'title');
}
echo $form->field($model, 'text')->textarea();
if ($settings['enableCaptcha']) {
echo $form->field($model, 'reCaptcha')->widget(ReCaptcha::className());
}
echo Html::submitButton(Yii::t('easyii', 'Send'), ['class' => 'btn btn-primary']);
ActiveForm::end();
return ob_get_clean();
}
示例2: makeUrl
public static function makeUrl($attr_id, $val_id)
{
// $get = Yii::$app->getRequest()->get();
// $so = isset($get['so']) ? $get['so'] . ',' : '';
$so = $attr_id . '_' . $val_id;
return Url::current(['so' => $so]);
}
示例3: run
public function run()
{
$model = new Comments();
if (!is_string($this->model)) {
$model->post_id = $this->model->getPrimaryKey();
$model->module = get_class($this->model);
$order = '';
} else {
$model->post_id = 0;
$model->module = $this->model;
$order = 'DESC';
}
// Получаем комментарии этого модуля и пост айди
$models = Comments::getComments($model->module, $model->post_id, $order);
// Получаем кол-во страниц комментариев для редиректа
$page = $models['pages']->totalCount / $models['pages']->pageSize + 1;
if ($model->load(Yii::$app->request->post())) {
if ($model->save()) {
Url::remember(Url::current());
Yii::$app->getSession()->setFlash('success', '<i class="fa fa-check fa-1x"></i> Good! ');
if (!is_string($this->model)) {
return Yii::$app->getResponse()->redirect('/post/' . $this->model->slug . '/' . $model->post_id . '?page=' . round($page) . '#' . $model->id);
} else {
return Yii::$app->getResponse()->refresh();
}
}
}
return $this->render('widgetComment', ['model' => $model, 'models' => $models['models'], 'pages' => $models['pages'], 'options' => $this->options]);
}
示例4: actionIndex
/**
* Lists all Book models.
* @return mixed
*/
public function actionIndex()
{
Url::remember(Url::current(), 'books');
$searchModel = new BookSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
}
示例5: __construct
/**
* Create $this->seoPage by current url
* @author Kravchuk Dmitry
* @throws Exception
*/
private function __construct()
{
// find seo model by url
$url = Url::current();
$actionId = Yii::$app->controller->action->uniqueId;
$i = 1;
$seoModelQuery = SeoModel::find()->select('*')->byUrl($url)->active();
$seoModelQuery->union(SeoModel::find()->byUrlRuleWithTableAlias('/' . trim($actionId, '/'), 'rule' . $i), true);
$actionIdArray = explode('/', $actionId);
if (is_array($actionIdArray)) {
do {
++$i;
array_pop($actionIdArray);
$urlRule = empty($actionIdArray) ? '/*' : '/' . implode('/', $actionIdArray) . '/*';
$unionQuery = SeoModel::find()->byUrlRuleWithTableAlias($urlRule, 'rule' . $i);
$seoModelQuery->union($unionQuery, true);
} while (!empty($actionIdArray));
}
$seoModel = $seoModelQuery->one();
if (!empty($seoModel)) {
$category = $seoModel->category;
$config = ['class' => $seoModel->seoPageClass, 'metaTitle' => !empty($category) && empty($seoModel->metaTitle) ? $category->metaTitle : $seoModel->metaTitle, 'metaKeyWords' => !empty($category) && empty($seoModel->metaKeywords) ? $category->metaKeywords : $seoModel->metaKeywords, 'metaDescription' => !empty($category) && empty($seoModel->metaDescription) ? $category->metaDescription : $seoModel->metaDescription, 'pageContent' => !empty($category) && empty($seoModel->pageContent) ? $category->pageContent : $seoModel->pageContent];
$seoPage = Yii::createObject($config);
if (!empty($seoPage)) {
if (!is_subclass_of($seoPage, 'kravchukdim\\yii2seo\\components\\SeoPageInterface')) {
throw new Exception('Error, invalid seo page class');
}
$this->seoPage = $seoPage;
}
}
}
示例6: api_form
public function api_form($options = [])
{
$model = new FeedbackModel();
$settings = Yii::$app->getModule('admin')->activeModules['agencies']->settings;
$options = array_merge($this->_defaultFormOptions, $options);
ob_start();
$form = ActiveForm::begin(['enableClientValidation' => true, 'action' => Url::to(['/admin/feedback/send'])]);
echo Html::hiddenInput('errorUrl', $options['errorUrl'] ? $options['errorUrl'] : Url::current([self::SENT_VAR => 0]));
echo Html::hiddenInput('successUrl', $options['successUrl'] ? $options['successUrl'] : Url::current([self::SENT_VAR => 1]));
var_dump($model->getErrors());
echo ' <input type="text" placeholder="Title" class="form-control" name="Feedback[title]" >
<input type="text" placeholder="Company Name" class="form-control" name="Feedback[name]" id="feedback-name">
<div class="help-block"></div>
<input type="text" placeholder="Phone" class="form-control" name="Feedback[phone]" >
<input type="text" placeholder="Email" class="form-control" name="Feedback[email]" >
<textarea name="Feedback[text]" id="feedback-text" class="form-control msg" rows="5" placeholder="your message"></textarea>
<div class="row">
<div class="col-md-12">
<button class="btn dry-btn center-block" type="submit">Send Request</button>
</div>
</div>';
// echo $form->field($model, 'name');
// echo $form->field($model, 'email')->input('email');
//
// if($settings['enablePhone']) echo $form->field($model, 'phone');
// if($settings['enableTitle']) echo $form->field($model, 'title');
//
// echo $form->field($model, 'text')->textarea();
//
// if($settings['enableCaptcha']) echo $form->field($model, 'reCaptcha')->widget(ReCaptcha::className());
//
// echo Html::submitButton(Yii::t('easyii', 'Send'), ['class' => 'btn btn-primary']);
ActiveForm::end();
return ob_get_clean();
}
示例7: actionCreate
/**
* @param int $characterID
*
* @return string
* @throws \yii\web\NotFoundHttpException
*/
public function actionCreate($characterID)
{
Url::remember(Url::current(), self::REMEMBER_NAME);
$character = $this->loadCharacter($characterID);
$this->getView()->addBread(['label' => 'Demands', 'url' => ['demand/index', 'characterID' => $characterID]])->addBread(['label' => 'Create'])->setCharacter($character);
$marketDemand = new MarketDemand();
$marketDemand->characterID = $characterID;
$marketDemand->userID = \Yii::$app->user->id;
if ($this->isAjax()) {
$type = $this->get('sType');
if ($type == 'station') {
$sql = '(SELECT sStation.stationID, sStation.stationName, sStation.stationTypeID FROM staStations as sStation WHERE sStation.stationName LIKE "%' . $_GET['q'] . '%")
UNION
(SELECT cStation.stationID, cStation.stationName, cStation.stationTypeID FROM api_eve_conquerableStation as cStation WHERE cStation.stationName LIKE "%' . $_GET['q'] . '%")';
} elseif ($type == 'item') {
$sql = 'SELECT typeID, typeName FROM invTypes WHERE typeName LIKE "%' . $_GET['q'] . '%" AND published ="1" ORDER BY typeName';
}
$return = \Yii::$app->db->createCommand($sql)->queryAll();
echo Json::encode($return);
// @todo change response type
\Yii::$app->end();
} elseif ($this->isPost() && $marketDemand->load($this->post())) {
if ($marketDemand->save()) {
UpdaterEveCentral::addType($marketDemand->typeID);
return $this->redirect(['demand/list', 'characterID' => $characterID]);
}
}
return $this->render('create', ['marketDemand' => $marketDemand]);
}
示例8: actionList
/**
* @return string
*/
public function actionList()
{
Url::remember(Url::current(), self::REMEMBER_NAME);
$this->getView()->addBread('List');
$searchPrice = new SearchPrice();
return $this->render('list', ['searchPrice' => $searchPrice]);
}
示例9: isItemActive
protected function isItemActive($item)
{
if (isset($item['url']) && is_string($item['url']) && $item['url'] === Url::current()) {
return true;
}
return parent::isItemActive($item);
}
示例10: api_form
public function api_form($options = [])
{
$model = new FeedbackModel();
$settings = Yii::$app->getModule('admin')->activeModules['awarness']->settings;
$options = array_merge($this->_defaultFormOptions, $options);
ob_start();
$form = ActiveForm::begin(['enableClientValidation' => true, 'action' => Url::to(['/admin/awarness/send']), 'options' => ['class' => 'col-md-offset-4']]);
echo Html::hiddenInput('errorUrl', $options['errorUrl'] ? $options['errorUrl'] : Url::current([self::SENT_VAR => 0]));
echo Html::hiddenInput('successUrl', $options['successUrl'] ? $options['successUrl'] : Url::current([self::SENT_VAR => 1]));
echo '
<div class="form-group center-block col-md-6">';
' <input class="form-control" placeholder="Name" name="Feedback[name]">
<input class="form-control" placeholder="Subject" name="Feedback[title]">
<input class="form-control" placeholder="Your Mail" name="Feedback[email]" >
<textarea class="form-control" rows="3" placeholder="Your Message" name="Feedback[text]" id="feedback-text"></textarea>
<button type="submit" class="btn dry-btn-3 center-block">Send Request</button>
</div>
';
// echo $form->field($model, 'name');
// echo $form->field($model, 'email')->input('email');
//
// if($settings['enablePhone']) echo $form->field($model, 'phone');
// if($settings['enableTitle']) echo $form->field($model, 'title');
//
// echo $form->field($model, 'text')->textarea();
//
// if($settings['enableCaptcha']) echo $form->field($model, 'reCaptcha')->widget(ReCaptcha::className());
//
// echo Html::submitButton(Yii::t('easyii', 'Send'), ['class' => 'btn btn-primary']);
ActiveForm::end();
return ob_get_clean();
}
示例11: actionContent
public function actionContent($links_id, $id = null)
{
$link = Links::findOne($links_id);
if (Yii::$app->request->get('action')) {
switch (Yii::$app->request->get('action')) {
case "add":
$content = new Contents();
$content->links_id = $link->id;
$content->seq = $content->findLastSequence($link->id, $id) + 1;
$content->save();
break;
case "del":
Contents::deleteAll(['id' => $id]);
(new Contents())->reSort($link->id);
break;
}
return $this->redirect(Url::current(['action' => null, 'id' => null]));
}
$contents = Contents::find()->where(['links_id' => $links_id])->orderBy(['seq' => SORT_ASC])->all();
if (Yii::$app->request->post()) {
foreach ($contents as $index => $content) {
if (Yii::$app->request->post('content-' . $index)) {
$contents[$index]->load(Yii::$app->request->post());
$contents[$index]->text = Yii::$app->request->post('content-' . $index);
$contents[$index]->save();
}
}
}
return $this->render('content', ['link' => $link, 'contents' => $contents]);
}
示例12: testCurrent
public function testCurrent()
{
$this->mockAction('page', 'view', null, []);
\Yii::$app->request->setQueryParams(['id' => 10, 'name' => 'test']);
$this->assertEquals('/base/index.php?r=page%2Fview&id=10&name=test', Url::current());
$this->assertEquals('/base/index.php?r=page%2Fview&id=20&name=test', Url::current(['id' => 20]));
$this->assertEquals('/base/index.php?r=page%2Fview&name=test', Url::current(['id' => null]));
}
示例13: run
public function run()
{
$header = Html::tag('span', 'План проспект');
$btnGroup = ButtonGroup::widget(['buttons' => array_map(function ($year) {
return ['label' => ArrayHelper::getValue($this->yearLabels, $year), 'tagName' => 'a', 'options' => ['href' => Url::current(['god' => $year]), 'class' => ['active' => $year === $this->getGod() ? 'active' : null]]];
}, $this->years)]);
return Html::tag('div', $header . $btnGroup);
}
示例14: getList
/**
* @return \Generator
*/
public function getList()
{
$items = [];
foreach ((array) $this->langs as $lang_id => $urlName) {
$items[] = ['label' => $urlName, 'active' => $lang_id == $this->currentLang, 'url' => Yii::$app->getErrorHandler()->exception !== null ? Url::toRoute([Yii::$app->getHomeUrl(), $this->langAttribute => $lang_id]) : Url::current([$this->langAttribute => $lang_id])];
}
return $items;
}
示例15: actionIndex
/**
* Lists all Books models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new BooksSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
// Save state of the current url
Yii::$app->getUser()->setReturnUrl(Url::current());
return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
}