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


PHP Url::home方法代码示例

本文整理汇总了PHP中yii\helpers\Url::home方法的典型用法代码示例。如果您正苦于以下问题:PHP Url::home方法的具体用法?PHP Url::home怎么用?PHP Url::home使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\helpers\Url的用法示例。


在下文中一共展示了Url::home方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionAdd

 public function actionAdd()
 {
     if (User::thisUser()->reputation < Event::MIN_REPUTATION_EVENT_CREATE) {
         return Yii::$app->getResponse()->redirect(Url::home());
     }
     $event = new Event();
     if ($event->load(Yii::$app->request->post())) {
         $eventPost = Yii::$app->request->post('Event');
         $event->country = $eventPost['country'];
         $event->description = \yii\helpers\HtmlPurifier::process($event->description, []);
         $event->user_id = Yii::$app->user->identity->getId();
         $event->date = strtotime($eventPost['date']);
         $event->like_count = 0;
         $event->show_count = 0;
         if ($event->save()) {
             // Добавляем теги
             $tagsArr = explode(',', Yii::$app->request->post('tags'));
             $tags = array_shift($tagsArr);
             $event->saveTags($tags);
             // Добавляем картинки к записи
             $imgs = Yii::$app->request->post('imgs');
             if (!empty($imgs) && is_array($imgs)) {
                 $event->saveImgs($imgs);
             } else {
                 $event->saveImgs([]);
             }
             $event->saveLocations(Yii::$app->request->post('location'));
             return Yii::$app->getResponse()->redirect($event->getUrl());
         }
     }
     Yii::$app->params['jsZoukVar']['tagsAll'] = Tags::getTags(Tags::TAG_GROUP_ALL);
     return $this->render('add', ['event' => $event]);
 }
开发者ID:IVsevolod,项目名称:zouk,代码行数:33,代码来源:EventController.php

示例2: init

 /**
  * Initializes the widget. 
  */
 public function init()
 {
     parent::init();
     if ($this->baseUrl === null) {
         $this->baseUrl = Url::home();
     }
 }
开发者ID:bigbrush,项目名称:yii2-big,代码行数:10,代码来源:Editor.php

示例3: upload

 public static function upload($value)
 {
     $document = new Documents();
     foreach ($value as $item => $i) {
         $document->{$item} = $i;
     }
     $document->created_at = time();
     $document->updated_at = time();
     $document->user = $value['user'];
     $token = Util::generateRandomStringCode(20);
     $document->token = $token;
     // echo \yii\helpers\Url::home(true) . $value['original_url'];die;
     $document->money_url = Util::makeOuoUrl(\yii\helpers\Url::home(true) . $value['original_url']);
     //$value['user'] = 1; //for testing
     $user = Users::findOne(['id' => $value['user']]);
     if (!$user) {
         return Util::arrayError('Error !');
     }
     if ($document->save()) {
         $user->number_upload += 1;
         $user->points += 3;
         $user->save();
         return Util::arraySuccess('Success', $document->id);
     }
     return Util::arrayError('Error !');
 }
开发者ID:huynt57,项目名称:bluebee-ng,代码行数:26,代码来源:Documents.php

示例4: actionList

 /**
  * @param integer $id
  * @return mixed
  */
 public function actionList($id = 0)
 {
     if (Yii::$app->request->isAjax) {
         if (!$id) {
             echo '';
             Yii::$app->end();
         }
         $tourFields = Tour::find()->with('tourFields')->where(['id' => $id])->one();
         $booking = new Booking();
         $bookingFields = new BookingFields();
         $bookingColumns = $booking->getTableSchema()->columns;
         $sort = Json::decode($tourFields->sort);
         $data = array_merge_recursive($sort, $bookingColumns);
         $addField = [];
         if ($tourFields->tourFields) {
             foreach ($tourFields->tourFields as $field) {
                 $addField['add_field_' . $field->id] = ['sort' => $field->sort, 'name' => $field->name, 'type' => $field->type, 'tour_id' => $field->tour_id];
             }
         }
         $data = array_merge($data, $addField);
         unset($data['id']);
         unset($data['tour_id']);
         $data = $booking->customMultiSort($data, 'sort');
         echo $this->renderAjax('_list', ['booking' => $booking, 'bookingFields' => $bookingFields, 'data' => $data]);
         Yii::$app->end();
     }
     return $this->redirect(Url::home());
 }
开发者ID:RexGalicie,项目名称:test_booking,代码行数:32,代码来源:BookingController.php

示例5: actionLogin

 public function actionLogin()
 {
     $this->layout = false;
     if (!$this->user->isGuest) {
         $this->redirect(Yii::$app->getHomeUrl());
     }
     $model = new LoginForm();
     if ($this->isPost) {
         $model->attributes = $this->request->post();
         if ($model->login()) {
             if (!$this->isAjax) {
                 $cookies = $this->request->cookies;
                 if (isset($cookies[$this->user->returnUrlParam])) {
                     $backUrl = $cookies[$this->user->returnUrlParam]->value;
                     Yii::$app->response->cookies->remove($this->user->returnUrlParam);
                 } else {
                     $backUrl = Url::home(true);
                 }
                 $this->redirect($backUrl);
             }
         }
     }
     if ($this->isAjax && $this->isPost) {
         throw new UserError($model->getErrors());
     } else {
         return $this->render('login', ['model' => $model]);
     }
 }
开发者ID:weiyiyi,项目名称:base,代码行数:28,代码来源:SiteController.php

示例6: generateFeed

 /**
  * @param ATOM|RSS2 $feed
  * @return ATOM|RSS2
  */
 protected function generateFeed($feed)
 {
     /* @var Post[] $posts */
     $site_name = ArrayHelper::getValue(Yii::$app->params, 'site_name', Yii::$app->name);
     $posts = Post::find()->where(['status' => Post::STATUS_PUBLISHED])->orderBy(['post_time' => SORT_DESC, 'update_time' => SORT_DESC])->limit(20)->all();
     $feed->setTitle($site_name);
     $feed->setLink(Url::home(true));
     $feed->setSelfLink(Url::to(['feed/rss'], true));
     $feed->setAtomLink(Url::to(['feed/atom'], true));
     $feed->setDescription(ArrayHelper::getValue(Yii::$app->params, 'seo_description', '最新更新的文章'));
     if ($posts) {
         $feed->setDate($posts[0]->update_time);
     } else {
         $feed->setDate(time());
     }
     foreach ($posts as $post) {
         $entry = $feed->createNewItem();
         $entry->setTitle($post->title);
         $entry->setLink($post->getUrl(true));
         $entry->setDate(intval($post->post_time));
         $entry->setDescription($post->excerpt);
         $entry->setAuthor($post->author_name ? $post->author_name : $post->author->nickname);
         $entry->setId($post->alias);
         if ($feed instanceof ATOM) {
             $entry->setContent($post->content);
         }
         $feed->addItem($entry);
     }
     return $feed;
 }
开发者ID:heartshare,项目名称:yii2-crazydb-blog,代码行数:34,代码来源:FeedController.php

示例7: actionAdd

 public function actionAdd()
 {
     $user = User::thisUser();
     if (Yii::$app->request->isPost) {
         $img = new Img();
         $img->user_id = $user->id;
         if ($img->save()) {
             $img->imgFile = UploadedFile::getInstance($img, 'imgFile');
             if ($img->imgFile instanceof UploadedFile && $img->validate('imgFile')) {
                 $prefix = Yii::$app->params['prefix'];
                 if (empty($prefix)) {
                     $prefix = "no_prefix";
                 }
                 $dirName = 'user' . $user->id;
                 $path = '/' . $prefix . '/img/' . $dirName . '/';
                 $fileName = 'img_' . $user->id . '_' . $img->id . '.' . pathinfo($img->imgFile->name, PATHINFO_EXTENSION);
                 if (!empty($prefix)) {
                     $fileName = $prefix . '_' . $fileName;
                 }
                 /** @var YandexDiskComponent $yandexDisk */
                 $yandexDisk = Yii::$app->yandexDisk;
                 $yandexDisk->setClientInfoImgDefault();
                 // Тест папки $path на существование
                 $pathInfo = $yandexDisk->getProperty($path);
                 if (!$pathInfo) {
                     $pathInfoMusic = $yandexDisk->getProperty('/' . $prefix . '/');
                     if (!$pathInfoMusic) {
                         $yandexDisk->createDirectory('/' . $prefix . '/');
                     }
                     $pathInfoMusic = $yandexDisk->getProperty('/' . $prefix . '/img/');
                     if (!$pathInfoMusic) {
                         $yandexDisk->createDirectory('/' . $prefix . '/img/');
                     }
                     $yandexDisk->createDirectory($path);
                 }
                 $fileInfo = $yandexDisk->getProperty($path . $fileName);
                 if (!$fileInfo) {
                     // Такого файла еще нет
                     $uploadInfo = $yandexDisk->uploadFile($path, (array) $img->imgFile, $fileName);
                 }
                 $publishInfo = $yandexDisk->startPublishing($path . $fileName);
                 if (is_string($publishInfo) && !empty($publishInfo)) {
                     $img->url = $publishInfo;
                     $shortUrl = Yii::$app->google->getShortUrl('https://getfile.dokpub.com/yandex/get/' . $publishInfo);
                     if (!empty($shortUrl['id'])) {
                         $img->short_url = $shortUrl['id'];
                     }
                 }
                 $img->key = $yandexDisk->key;
                 $img->entity_key = $yandexDisk::THIS_ENTITY;
                 $img->save();
             }
         }
         $result = ['id' => $img->id, 'short_url' => $img->short_url];
         return json_encode($result);
     }
     $this->redirect(Url::home());
 }
开发者ID:IVsevolod,项目名称:zouk,代码行数:58,代码来源:ImgController.php

示例8: isAdmin

 public function isAdmin()
 {
     $rHostInfo = Url::home(true);
     if (!\Yii::$app->user->isGuest && strpos(\Yii::$app->request->absoluteUrl, $rHostInfo . 'admin') !== false) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:oakcms,项目名称:oakcms,代码行数:9,代码来源:CoreView.php

示例9: actionDelete

 /**
  * Deletes this Space
  */
 public function actionDelete()
 {
     $this->ownerOnly();
     $model = new DeleteForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $this->getSpace()->delete();
         return $this->redirect(Url::home());
     }
     return $this->render('delete', array('model' => $model, 'space' => $this->getSpace()));
 }
开发者ID:SimonBaeumer,项目名称:humhub,代码行数:13,代码来源:DefaultController.php

示例10: getCallback

 /**
  * {@url to="/path" /}
  * {@url /}
  *
  * @return callable
  */
 public function getCallback()
 {
     return function ($chunk, $context, $bodies, $params) {
         if ($params->to) {
             $code = Url::to($params->to);
         } else {
             $code = Url::home();
         }
         return $chunk->write($code);
     };
 }
开发者ID:byromul,项目名称:yii2-dust,代码行数:17,代码来源:UrlHelper.php

示例11: lightbox

 public function lightbox($title, $source, $target, $align = "left", $size = "")
 {
     $target_url = Url::home(true) . "images/" . $target;
     $image_url = Url::home(true) . "images/" . $source;
     $image_path = \Yii::getAlias('@app/web/images/') . $source;
     if (is_file($image_path)) {
         $image_info = array_values(getimagesize($image_path));
         list($width, $height, $type, $attr) = $image_info;
     }
     return "<a href=\"" . $target_url . "\"" . " data-lightbox=\"" . str_replace('.', '_', str_replace('/', '_', $target)) . "\"" . " data-title=\"" . $title . "\"" . " title=\"" . $title . "\" class=\"sb\"><span class=\"imagewrap\"><img src=\"" . $image_url . "\" alt=\"" . $title . "\" title=\"" . $title . "\" class=\"gallery th " . $align . " floated image\"" . (!isset($width) ? "" : " width=\"" . $width . "\" ") . (!isset($height) ? "" : " height=\"" . $height . "\" ") . "/></span></a>";
 }
开发者ID:jacmoe,项目名称:bugitor,代码行数:11,代码来源:snippets.php

示例12: init

 public function init()
 {
     $pages = Page::find()->selectNoText()->published()->all();
     $this->_htmlStr = '<ul class="menu">';
     $this->_htmlStr .= '<li role="presentation" ' . ($this->active('site', 'index', '') ? 'class="nav-current"' : '') . '>' . Html::a('首页', Url::home()) . '</li>';
     if (!empty($pages)) {
         foreach ($pages as $page) {
             $this->_htmlStr .= '<li role="presentation" ' . ($this->active('site', 'page', $page->slug) ? 'class="nav-current"' : '') . '>' . Html::a($page->title, ['site/page', 'slug' => $page->slug, $this->options]) . '</li>';
         }
     }
     $this->_htmlStr .= '</ul>';
 }
开发者ID:Penton,项目名称:MoBlog,代码行数:12,代码来源:NavBar.php

示例13: actionFeedback

 public function actionFeedback()
 {
     $model = new Feedback();
     if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     if ($model->load($_POST) && $model->validate()) {
         $model->send();
         Yii::$app->controller->redirect(Url::home());
     }
 }
开发者ID:nurastana,项目名称:familyclinickz,代码行数:12,代码来源:DefaultController.php

示例14: run

 /**
  * Runs the action
  *
  * @return string result content
  */
 public function run()
 {
     $this->controller->layout = $this->layout;
     if (Yii::$app->auth0->sdk()->getUser()) {
         if (Yii::$app->auth0->login()) {
             Yii::$app->user->login(Yii::$app->auth0->localUser);
             Yii::$app->tenant->login();
         }
         return $this->controller->redirect(isset($this->redirectUrl) ? $this->redirectUrl : Url::home());
     }
     return $this->controller->render($this->view);
 }
开发者ID:simbiosis-group,项目名称:yii2-user,代码行数:17,代码来源:LoginAction.php

示例15: actionUrl

 public function actionUrl()
 {
     $urls = [];
     $urls[] = Url::base();
     $urls[] = Url::current();
     $urls[] = Url::previous();
     // use before Url::remember()
     $urls[] = Url::home();
     $urls[] = Url::to('/');
     $urls[] = Url::to('/test');
     $urls[] = Url::to(['book']);
     return VarDumper::dumpAsString($urls, 10, true);
 }
开发者ID:arossokha,项目名称:webcamp_php_adv_29_11,代码行数:13,代码来源:SiteController.php


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