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


PHP Url::to方法代码示例

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


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

示例1: notify

 public static function notify($thread)
 {
     if (is_numeric($thread) && $thread > 0) {
         $email = Content::find()->where(['name' => 'email-sub'])->one();
         if ($email) {
             $topic = $email->topic;
             $content = $email->content;
         } else {
             $topic = 'New post in subscribed thread at {forum}';
             $content = '<p>There has been new post added in the thread you are subscribing. Click the following link to read the thread.</p><p>{link}</p><p>See you soon!<br />{forum}</p>';
         }
         $forum = Config::getInstance()->get('name');
         $subs = static::find()->where(['thread_id' => (int) $thread, 'post_seen' => static::POST_SEEN]);
         foreach ($subs->each() as $sub) {
             $sub->post_seen = static::POST_NEW;
             if ($sub->save()) {
                 if (Email::queue($sub->user->email, str_replace('{forum}', $forum, $topic), str_replace('{forum}', $forum, str_replace('{link}', Html::a(Url::to(['default/last', 'id' => $sub->thread_id], true), Url::to(['default/last', 'id' => $sub->thread_id], true)), $content)), !empty($sub->user_id) ? $sub->user_id : null)) {
                     Log::info('Subscription notice link queued', !empty($sub->user_id) ? $sub->user_id : '', __METHOD__);
                 } else {
                     Log::error('Error while queuing subscription notice link', !empty($sub->user_id) ? $sub->user_id : '', __METHOD__);
                 }
             }
         }
     }
 }
开发者ID:keltstr,项目名称:yii2-podium,代码行数:25,代码来源:Subscription.php

示例2: actionAdd

 public function actionAdd()
 {
     $id = !empty(yii::$app->request->get('id')) ? yii::$app->request->get('id') : 0;
     $item = $this->GetModel()->GetItem($id);
     if ($item) {
         $this->headerPage = "Редактировать слайдер " . $item["name"];
     } else {
         $this->headerPage = "Новый слайдер";
     }
     if (yii::$app->request->isPost) {
         $pathInfo = Yii::$app->request->pathInfo;
         $fields = Yii::$app->request->post();
         if (isset($fields["main"]["id"])) {
             $id = $fields["main"]["id"];
         } else {
             $id = Yii::$app->request->get('id') ? (int) Yii::$app->request->get('id') : 0;
         }
         $model = $this->GetModel();
         $model->attributes = $fields["main"];
         if ($model->validate()) {
             $insert_id = $model->Add($id, $fields["main"]);
             $this->redirect(Url::to(["/{$pathInfo}", "id" => $insert_id]));
         } else {
             $errors = $model->errors;
             app::PrintPre($errors);
         }
     }
     $interface = $this->MakeInterface($item);
     return $this->render('add', ['interface' => $interface, 'data' => $item]);
 }
开发者ID:developer-home,项目名称:project777,代码行数:30,代码来源:CatalogController.php

示例3: actionSaveComment

 public function actionSaveComment()
 {
     if (!isset($_POST['article_id'])) {
         return $this->redirect('/article');
     }
     Comment::saveComment($_POST, true);
     $this->redirect(Url::to('/article/show/' . $_POST['article_id']));
 }
开发者ID:ArtemRochev,项目名称:MVC-Framework,代码行数:8,代码来源:ControllerArticle.php

示例4: getUrl

 /**
  * Zwraca urla danego obiektu
  * @param integer $id
  * @return string
  */
 public function getUrl($id, $model)
 {
     $object = $model::find((int) $id);
     if (isset($object->url)) {
         $url = $object->url;
     }
     return \Url::to($url);
 }
开发者ID:zrosiak,项目名称:fields,代码行数:13,代码来源:TwigPostUrl.php

示例5: getUserDirectory

 /**
  * @param $user_id
  * @return mixed
  */
 private function getUserDirectory($user_id)
 {
     $uploads = Yii::$app->getModule('user')->uploads;
     $path = str_replace('\\', '/', Url::to('@webroot') . DIRECTORY_SEPARATOR . $uploads . DIRECTORY_SEPARATOR . $user_id);
     if (!file_exists($path)) {
         mkdir($path, 0700, true);
     }
     return $path;
 }
开发者ID:Dominus77,项目名称:blog,代码行数:13,代码来源:UploadForm.php

示例6: actionPing

 public function actionPing($src)
 {
     $filename = basename($src);
     $filepath = Url::to(ImgController::PING_IMG_DIR) . $filename;
     if (!file_exists($filepath)) {
         ImageHelper::createPingImg($src);
     }
     $path = Url::to(['/.resource/' . $filename], true);
     $this->renderJsonpForJquery(['src' => $path]);
     \Yii::$app->end();
 }
开发者ID:RyosukeMurai,项目名称:TokyoSearch,代码行数:11,代码来源:ImgController.php

示例7: actionSaveComment

 public function actionSaveComment()
 {
     if (!isset($_POST['article_id'])) {
         return $this->redirect('/article');
     }
     $comment = new Comment();
     $comment->author_id = $_POST['author_id'];
     $comment->article_id = $_POST['article_id'];
     $comment->text = $_POST['text'];
     $comment->save();
     $this->redirect(Url::to('/article/show-article', ['id' => $_POST['article_id']]));
 }
开发者ID:AJIACTOP,项目名称:MVC-Framework,代码行数:12,代码来源:ControllerArticle.php

示例8: getDefaultAvatar

 /**
  * @return bool|mixed
  */
 private function getDefaultAvatar()
 {
     $defaultPath = Url::to('@webroot') . DIRECTORY_SEPARATOR . $this->uploads . DIRECTORY_SEPARATOR . 'default';
     $dataFile = Url::to('@app') . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'user' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . $this->uploads . DIRECTORY_SEPARATOR . 'default' . DIRECTORY_SEPARATOR . $this->defaultAvatar;
     $newFile = $defaultPath . DIRECTORY_SEPARATOR . $this->defaultAvatar;
     if (!file_exists($defaultPath)) {
         mkdir($defaultPath, 0700, true);
         if (!copy($dataFile, $newFile)) {
             return false;
         }
     }
     $urlDefaultAvatar = str_replace('\\', '/', Url::to(DIRECTORY_SEPARATOR . $this->uploads . DIRECTORY_SEPARATOR . 'default' . DIRECTORY_SEPARATOR . $this->defaultAvatar));
     return $urlDefaultAvatar;
 }
开发者ID:Dominus77,项目名称:blog,代码行数:17,代码来源:AvatarWidget.php

示例9: jsFile

 /**
  * Generates a script tag that refers to an external JavaScript file.
  * @param  string $url     the URL of the external JavaScript file. This parameter will be processed by [[\yii\helpers\Url::to()]].
  * @param  array  $options the tag options in terms of name-value pairs. These will be rendered as
  *                         the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
  *                         If a value is null, the corresponding attribute will not be rendered.
  *                         See [[renderTagAttributes()]] for details on how attributes are being rendered.
  * @return string the generated script tag
  * @see \yii\helpers\Url::to()
  */
 public static function jsFile($url, $options = [])
 {
     $options['src'] = Url::to($url);
     if (!empty($options['conditions'])) {
         foreach ($options['conditions'] as $file => $condition) {
             if (strpos($url, $file) !== false) {
                 unset($options['conditions']);
                 return static::conditionalComment(static::tag('script', '', $options), $condition);
             }
         }
     }
     unset($options['conditions']);
     return static::tag('script', '', $options);
 }
开发者ID:diginova,项目名称:yii2-metronic,代码行数:24,代码来源:Html.php

示例10: get

 static function get($img, $w = "", $h = "", $crop = true, $params = array())
 {
     $fullPath = public_path() . '/' . $img;
     if (!File::exists($fullPath)) {
         return false;
     }
     $format = '';
     $width = '';
     $htmlWidth = '';
     $height = '';
     $htmlHeight = '';
     $filter = "";
     $method = '';
     $lazyParams = '';
     $ext = File::extension($fullPath);
     if ($ext == 'png') {
         $firstBytes = @file_get_contents($fullPath, false, null, 25, 1);
         if (ord($firstBytes) & 4) {
             $format = "f=png";
             //for transparent pngs
         }
     }
     if ($w) {
         $width = 'w=' . $w;
         $htmlWidth = 'width="' . $w . '"';
     }
     if ($h) {
         $height = 'h=' . $h;
         $htmlHeight = 'height="' . $h . '"';
     }
     if (count($params) > 0) {
         $filter = implode('&', $params);
         //eg: fltr[]=gray
     }
     if ($w != "" && $h != "") {
         if ($crop) {
             $method = 'zc=1';
         } else {
             $method = 'far=1&bg=FFFFFF';
         }
     }
     $image = 'src=' . $img;
     $optionsSlices = array($method, $width, $height, $filter, $image, $format);
     $options = implode('&', array_filter($optionsSlices));
     $src = Url::to('/phpthumb') . "?" . $options;
     $htmlOptionsSlices = array($htmlWidth, $htmlHeight, $lazyParams);
     $htmlOptions = implode(' ', array_filter($htmlOptionsSlices));
     return '<img src="' . $src . '" ' . $htmlOptions . ' />';
 }
开发者ID:matteoantoci,项目名称:phpthumb,代码行数:49,代码来源:PhpthumbHelper.php

示例11: redirect

 public function redirect($url, $force = false, $statusCode = 302)
 {
     $params = Yii::$app->request->queryParams;
     // Meta redirect
     if (headers_sent() || ob_get_contents()) {
         $url = !empty($params['_return_url']) ? $params['_return_url'] : $url;
         $url = Url::to($url);
         $this->ech(Html::tag('meta', '', ['http-equiv' => 'Refresh', 'content' => '1;URL=' . $url . '']));
         $this->ech(Html::a(__('Continue'), $url));
     }
     if (!empty($params['_return_url']) && !$force) {
         return Yii::$app->getResponse()->redirect($params['_return_url'], $statusCode);
     }
     return parent::redirect($url, $statusCode);
 }
开发者ID:vsguts,项目名称:crm,代码行数:15,代码来源:AbstractController.php

示例12: athenticateTwitter

 public static function athenticateTwitter()
 {
     $return_url = Url::to('/backend/system/settings/update/radiantweb/problog/settings');
     $pb_auth = DB::table('radiantweb_twitter_auth')->first();
     $oauth_token = Session::get('oauth_token');
     $oauth_token_secret = Session::get('oauth_token_secret');
     /* Create TwitteroAuth object with app key/secret and token key/secret from default phase */
     $connection = new TwitterOAuth($pb_auth->twitter_key, $pb_auth->twitter_secret, $oauth_token, $oauth_token_secret);
     /* Request access tokens from twitter */
     $access_token = $connection->getAccessToken($_REQUEST['oauth_verifier']);
     $data = array('twitter_auth_token' => $access_token['oauth_token'], 'twitter_auth_secret' => $access_token['oauth_token_secret']);
     DB::table('radiantweb_twitter_auth')->where('twitter_key', $pb_auth->twitter_key)->update($data);
     header('Location: ' . $return_url);
     //return Redirect::to($return_url);
 }
开发者ID:fuunnx,项目名称:loveandzucchini,代码行数:15,代码来源:AuthenticateTwitter.php

示例13: open

 /**
  * TODO Comments.
  */
 public function open($action = null, $method = 'post', $enctype = false, $attributes = array())
 {
     if (is_null($action)) {
         $action = Url::toCurrent();
     } else {
         $action = Url::to($action);
     }
     $attr = '';
     if ($attributes) {
         foreach ($attributes as $k => $v) {
             $attr .= sprintf(' %s="%s"', $k, $v);
         }
     }
     $enctype = $enctype ? ' enctype="multipart/form-data"' : '';
     return sprintf('<form method="%s" action="%s"%s%s>', $method, $action, $enctype, $attr);
 }
开发者ID:simudream,项目名称:caffeine,代码行数:19,代码来源:html_form.php

示例14: onDoTweet

 function onDoTweet()
 {
     $settings = ProblogSettingsModel::instance();
     $blogPost = $settings->get('blogPost');
     $pb_auth = DB::table('radiantweb_twitter_auth')->first();
     $PB_AUTH_TOKEN = $pb_auth->twitter_auth_token;
     $PB_AUTH_SECRET = $pb_auth->twitter_auth_secret;
     $PB_APP_KEY = $pb_auth->twitter_key;
     $PB_APP_SECRET = $pb_auth->twitter_secret;
     if ($PB_AUTH_TOKEN) {
         $connection = new TwitterOAuth($PB_APP_KEY, $PB_APP_SECRET, $PB_AUTH_TOKEN, $PB_AUTH_SECRET);
         $url = Url::to('/') . '/' . $blogPost . '/' . $this->model->slug . '/';
         $msg = str_replace('{{url}}', $url, $_REQUEST['message']);
         $update_status = $connection->post('statuses/update', ['status' => $msg]);
     }
 }
开发者ID:fuunnx,项目名称:loveandzucchini,代码行数:16,代码来源:PostToTwitter.php

示例15: authenticate

 /**
  * Tries to authenticate user via social network. If user has already used
  * this network's account, he will be logged in. Otherwise, it will try
  * to create new user account.
  *
  * @param ClientInterface $client
  */
 public function authenticate(ClientInterface $client)
 {
     $account = $this->finder->findAccount()->byClient($client)->one();
     if ($account === null) {
         $account = Account::create($client);
     }
     if ($account->user instanceof User) {
         if ($account->user->isBlocked) {
             Yii::$app->session->setFlash('danger', Yii::t('user', 'Your account has been blocked.'));
             $this->action->successUrl = Url::to(['/user/security/login']);
         } else {
             if ($account->user->esActivo) {
                 Yii::$app->user->login($account->user, $this->module->rememberFor);
                 $this->action->successUrl = Yii::$app->getUser()->getReturnUrl();
             }
         }
     } else {
         $this->action->successUrl = $account->getConnectUrl();
     }
 }
开发者ID:apmauj,项目名称:1f8bf10ab74d6f5ca69f7c07b7ee1c38,代码行数:27,代码来源:SeguridadController.php


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