当前位置: 首页>>代码示例>>PHP>>正文


PHP Url::current方法代码示例

本文整理汇总了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();
 }
开发者ID:DenisCherniatev,项目名称:easyii,代码行数:25,代码来源:Feedback.php

示例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]);
 }
开发者ID:cboy868,项目名称:nana,代码行数:7,代码来源:Goods.php

示例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]);
 }
开发者ID:psych88,项目名称:fifa,代码行数:29,代码来源:CommentWidget.php

示例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]);
 }
开发者ID:tdimdimich,项目名称:tt_yii2,代码行数:11,代码来源:BookController.php

示例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;
         }
     }
 }
开发者ID:kravchukdim,项目名称:yii2seo,代码行数:36,代码来源:Seo.php

示例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();
 }
开发者ID:engmohamedamer,项目名称:gotest,代码行数:35,代码来源:Feedback.php

示例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]);
 }
开发者ID:Sywooch,项目名称:EVE-Manager-Yii-2.x,代码行数:35,代码来源:DemandController.php

示例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]);
 }
开发者ID:Sywooch,项目名称:EVE-Manager-Yii-2.x,代码行数:10,代码来源:IndexController.php

示例9: isItemActive

 protected function isItemActive($item)
 {
     if (isset($item['url']) && is_string($item['url']) && $item['url'] === Url::current()) {
         return true;
     }
     return parent::isItemActive($item);
 }
开发者ID:andreyvaslv,项目名称:crb,代码行数:7,代码来源:Nav.php

示例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();
 }
开发者ID:engmohamedamer,项目名称:gotest,代码行数:32,代码来源:Feedback.php

示例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]);
 }
开发者ID:mark38,项目名称:yii2-site-mng,代码行数:30,代码来源:DefaultController.php

示例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]));
 }
开发者ID:noboru-sakamoto,项目名称:yii2,代码行数:8,代码来源:UrlTest.php

示例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);
 }
开发者ID:tsyrya,项目名称:mybriop,代码行数:8,代码来源:PlanProspektGodPanel.php

示例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;
 }
开发者ID:lav45,项目名称:yii2-translated-behavior-demo,代码行数:11,代码来源:LangHelper.php

示例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]);
 }
开发者ID:b2ik,项目名称:yii2-module-sample,代码行数:12,代码来源:DefaultController.php


注:本文中的yii\helpers\Url::current方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。