• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP CUrlManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: createUrl

 /**
  *
  * @see CUrlManager 
  *
  * Constructs a URL.
  * @param string the controller and the action (e.g. article/read)
  * @param array list of GET parameters (name=>value). Both the name and value will be URL-encoded.
  * If the name is '#', the corresponding value will be treated as an anchor
  * and will be appended at the end of the URL. This anchor feature has been available since version 1.0.1.
  * @param string the token separating name-value pairs in the URL. Defaults to '&'.
  * @return string the constructed URL
  */
 public function createUrl($route, $params = array(), $ampersand = '&')
 {
     // We added this by default to all links to show
     // Content based on language - Add only when not excplicity set
     if (!isset($params['lang'])) {
         $params['lang'] = Yii::app()->language;
     }
     if (isset($params['lang']) && $params['lang'] === false) {
         unset($params['lang']);
     }
     // Use parent to finish url construction
     return parent::createUrl($route, $params, $ampersand);
 }
开发者ID:hansenmakangiras,项目名称:yiiframework-cms,代码行数:25,代码来源:CustomUrlManager.php


示例2: parseUrl

 /**
  * Parses a URL based on this rule.
  * @param CUrlManager $manager the URL manager
  * @param CHttpRequest $request the request object
  * @param string $pathInfo path info part of the URL
  * @param string $rawPathInfo path info that contains the potential URL suffix
  * @return mixed the route that consists of the controller ID and action ID or false on error
  */
 public function parseUrl($manager, $request, $pathInfo, $rawPathInfo)
 {
     if ($this->verb !== null && !in_array($request->getRequestType(), $this->verb, true)) {
         return false;
     }
     if ($manager->caseSensitive && $this->caseSensitive === null || $this->caseSensitive) {
         $case = '';
     } else {
         $case = 'i';
     }
     if ($this->urlSuffix !== null) {
         $pathInfo = $manager->removeUrlSuffix($rawPathInfo, $this->urlSuffix);
     }
     // URL suffix required, but not found in the requested URL
     if ($manager->useStrictParsing && $pathInfo === $rawPathInfo) {
         $urlSuffix = $this->urlSuffix === null ? $manager->urlSuffix : $this->urlSuffix;
         if ($urlSuffix != '' && $urlSuffix !== '/') {
             return false;
         }
     }
     if ($this->hasHostInfo) {
         $pathInfo = strtolower($request->getHostInfo()) . rtrim('/' . $pathInfo, '/');
     }
     $pathInfo .= '/';
     if (preg_match($this->pattern . $case, $pathInfo, $matches)) {
         foreach ($this->defaultParams as $name => $value) {
             if (!isset($_GET[$name])) {
                 $_REQUEST[$name] = $_GET[$name] = $value;
             }
         }
         $tr = array();
         foreach ($matches as $key => $value) {
             if (isset($this->references[$key])) {
                 $tr[$this->references[$key]] = $value;
             } elseif (isset($this->params[$key])) {
                 $_REQUEST[$key] = $_GET[$key] = $value;
             }
         }
         if ($pathInfo !== $matches[0]) {
             // there're additional GET params
             $manager->parsePathInfo(ltrim(substr($pathInfo, strlen($matches[0])), '/'));
         }
         if ($this->routePattern !== null) {
             return strtr($this->route, $tr);
         } else {
             return $this->route;
         }
     } else {
         return false;
     }
 }
开发者ID:frogoscar,项目名称:mobcent-discuz,代码行数:59,代码来源:CUrlManager.php


示例3: createUrl

 public function createUrl($route, $params = array(), $ampersand = '&')
 {
     $route = trim($route, '/');
     //for admin and admin/*
     $parts = explode('/', $route);
     //do not mess with gii
     if ($parts[0] == 'gii') {
         return parent::createUrl($route, $params, $ampersand);
     }
     //        ignore defaultController
     if (Yii::app()->hasModule($parts[0]) && isset($parts[1]) && $parts[1] == Yii::app()->getModule($parts[0])->defaultController) {
         unset($parts[1]);
         $route = implode('/', $parts);
     }
     if (substr(Yii::app()->getRequest()->pathInfo, 0, 6) == 'admin/' || Yii::app()->getRequest()->pathInfo == 'admin') {
         $route = 'admin/' . trim($route, '/');
     }
     $url = parent::createUrl($route, $params, $ampersand);
     if (Settings::get('SEO', 'slugs_enabled')) {
         //handle slugs here
         if ($slug = Slug::getSlug(preg_replace('/' . trim(Yii::app()->baseUrl, '/') . '/', '', $url, 1))) {
             //if (Settings::get('SEO','externalSlug')
             $url = $slug;
             $url = Yii::app()->baseUrl . '/' . $url;
         }
     }
     return $url;
 }
开发者ID:awecode,项目名称:awecms,代码行数:28,代码来源:AweUrlManager.php


示例4: createUrl

 public function createUrl($route, $params = array(), $ampersand = '&')
 {
     if (empty($params['language']) && Yii::app()->language !== 'ru') {
         $params['language'] = Yii::app()->language;
     }
     if (!isset(Yii::app()->controller->module->id)) {
         if (!strstr($route, 'register')) {
             if (isset($_POST['city'])) {
                 $cookie = new CHttpCookie('city', $_POST['city']);
                 Yii::app()->request->cookies['city'] = $cookie;
                 $cookie->expire = time() + 3600;
                 $c = City::model()->localized('ru')->findByPk($_POST['city'])->name;
                 $params['city'] = Settings::toLatin($c);
             } elseif (isset(Yii::app()->request->cookies['city'])) {
                 $c = City::model()->localized('ru')->findByPk(Yii::app()->request->cookies['city']->value)->name;
                 $params['city'] = Settings::toLatin($c);
             } else {
                 unset($params['city']);
             }
         } else {
             unset($params['city']);
         }
     }
     /*if (!strstr($route,'/')) {
           $route = '/cat/'.$route;
       }*/
     return Yii::app()->request->hostInfo . parent::createUrl($route, $params, $ampersand);
 }
开发者ID:schur-maksim,项目名称:happymoments.ua,代码行数:28,代码来源:UrlManager.php


示例5: createUrl

 public function createUrl($route, $params = array(), $ampersand = '&')
 {
     if (isset($params[$this->languageParam])) {
         $language = $params[$this->languageParam];
         $forceLanguage = true;
         unset($params[$this->languageParam]);
     } else {
         $language = Yii::app()->language;
         $forceLanguage = false;
     }
     $url = parent::createUrl($route, $params, $ampersand);
     $request = Yii::app()->request;
     if (!$forceLanguage && !$request->redirectDefault && $language === $request->getDefaultLanguage()) {
         return $url;
     }
     $key = array_search($language, $request->languages);
     if (is_string($key)) {
         $language = $key;
     }
     if (($baseUrl = $this->getBaseUrl()) === '') {
         return '/' . $language . $url;
     } else {
         return strtr($url, array($baseUrl => $baseUrl . '/' . $language));
     }
 }
开发者ID:fedemotta,项目名称:localeurls,代码行数:25,代码来源:LocaleUrlManager.php


示例6: processRules

 protected function processRules()
 {
     $rules = array();
     $method = strtolower(Yii::app()->getRequest()->getRequestType());
     //transform method's rules keys to lowercase
     $this->rules = array_combine(array_map(array($this, '__atToLowerCase'), array_keys($this->rules)), array_values($this->rules));
     //check if it has an index the same as the request type and if it does add its rules
     if (key_exists("@{$method}", $this->rules)) {
         $rules = $this->rules["@{$method}"];
     }
     //add the default rules
     if (is_array($rules)) {
         foreach ($this->rules as $k => $rule) {
             if (substr($k, 0, 1) !== '@') {
                 $rules[$k] = $rule;
             }
         }
     } elseif (is_string($rules)) {
         $rules = array("." => $rules);
     }
     //override the existing rules with only those that matche with the request type
     $this->rules = $rules;
     //disable cache that causes it to load wrong rules
     //cant use it as its defined as a constant and not able to change to use method's specific cache
     $this->cacheID = false;
     parent::processRules();
 }
开发者ID:aer123456,项目名称:yougou,代码行数:27,代码来源:VerbUrlManager.php


示例7: createUrl

 public function createUrl($route, $params = array(), $ampersand = '&')
 {
     if (!isset($params['language'])) {
         $params['language'] = Yii::app()->language;
     }
     return parent::createUrl($route, $params, $ampersand);
 }
开发者ID:mryuhancai,项目名称:newphemu,代码行数:7,代码来源:XUrlManager.php


示例8: createLangUrl

 public function createLangUrl($language, $ampersand = '&')
 {
     $route = Yii::app()->controller->route;
     $params = $_GET;
     unset($params[$this->routeVar]);
     $params[$this->langParam] = $language;
     return parent::createUrl($route, $params, $ampersand);
 }
开发者ID:kumar-akhmadiyev,项目名称:yii-components,代码行数:8,代码来源:CLangUrlManager.php


示例9: parseUrl

 public function parseUrl($request)
 {
     $route = parent::parseUrl($request);
     if (substr_count($route, '-') > 0) {
         $route = lcfirst(str_replace(' ', '', ucwords(str_replace('-', ' ', $route))));
     }
     return $route;
 }
开发者ID:bryglen,项目名称:yii-advanced-template,代码行数:8,代码来源:UrlManager.php


示例10: createUrl

 public function createUrl($route, $params = array(), $ampersand = '&')
 {
     $url = parent::createUrl($route, $params, $ampersand);
     if ($this->getFrontendMode()) {
         $baseUrl = $this->getBaseUrl();
         return mb_substr($url, mb_strlen($baseUrl));
     }
     return $url;
 }
开发者ID:kot-ezhva,项目名称:ygin,代码行数:9,代码来源:BackendUrlManager.php


示例11: processRules

 /**
  * Build the rules from the DB
  */
 protected function processRules()
 {
     if (($this->rules = Yii::app()->cache->get('customurlrules')) === false) {
         // Site Rules
         $this->rules = array('project/<id:\\d+>/<alias>' => 'site/projects/viewproject', 'issue/<id:\\d+>/<alias>' => 'site/tickets/viewticket', 'issues/<type:(priority|version|fixedin|type|status|category|project|milestone)>/<id:\\d+>/<alias>' => 'site/tickets/filterissues', 'issues/<type:(priority|version|fixedin|type|status|category|project|milestone)>/<id:\\d+>/<alias>/<rss:\\w+>' => 'site/tickets/filterissues', 'issues/tag/<tag>' => 'site/tickets/filterissuesbytag', 'wiki/<id:\\d+>/<alias>' => 'site/wiki/viewpage', 'wiki/<id:\\d+>/<alias>/<revisionid:\\d+>' => 'site/wiki/viewpagerevision', '' => 'site/index/index', '<_c:([a-zA-z0-9-]+)>' => 'site/<_c>/index', '<_c:([a-zA-z0-9-]+)>/<_a:([a-zA-z0-9-]+)>' => 'site/<_c>/<_a>', '<_c:([a-zA-z0-9-]+)>/<_a:([a-zA-z0-9-]+)>//*' => 'site/<_c>/<_a>/');
         Yii::app()->cache->set('customurlrules', $this->rules);
     }
     // Run parent
     parent::processRules();
 }
开发者ID:IuriiP,项目名称:yii-tracker,代码行数:13,代码来源:CustomUrlManager.php


示例12: createUrl

 public function createUrl($route,$params=array(),$ampersand='&')
 {
     if (!isset($params['language'])) {
         if (Yii::app()->user->hasState('language'))
             Yii::app()->language = Yii::app()->user->getState('language');
         else if(isset(Yii::app()->request->cookies['language']))
             Yii::app()->language = Yii::app()->request->cookies['language']->value;
         $params['language']=Yii::app()->language;
     }
     return parent::createUrl($route, $params, $ampersand);
 }
开发者ID:schiz,项目名称:teff,代码行数:11,代码来源:UrlManager.php


示例13: createUrl

 public function createUrl($route, $params = array(), $ampersand = '&')
 {
     if ($route != 'min/serve' && $route != 'site/uploadimage') {
         $langs = Lang::getActiveLangs();
         $countLangs = count($langs);
         if (!isFree() && empty($params['lang']) && ($countLangs > 1 || $countLangs == 1 && param('useLangPrefixIfOneLang'))) {
             $params['lang'] = Yii::app()->language;
         }
     }
     return parent::createUrl($route, $params, $ampersand);
 }
开发者ID:alexjkitty,项目名称:estate,代码行数:11,代码来源:CustomUrlManager.php


示例14: createUrl

 /**
  * Create url based on current language.
  * @param mixed $route
  * @param array $params
  * @param string $ampersand
  * @param boolean $respectLang
  * @access public
  * @return string
  */
 public function createUrl($route, $params = array(), $ampersand = '&', $respectLang = true)
 {
     $result = parent::createUrl($route, $params, $ampersand);
     if ($respectLang === true) {
         $langPrefix = Yii::app()->languageManager->getUrlPrefix();
         if ($langPrefix) {
             $result = '/' . $langPrefix . $result;
         }
     }
     return $result;
 }
开发者ID:buildshop,项目名称:bs-common,代码行数:20,代码来源:CManagerUrl.php


示例15: createUrl

 /**
  * @inheritDoc
  */
 public function createUrl($route, $params = array(), $ampersand = '&')
 {
     $oldUrlSuffix = $this->urlSuffix;
     if (isset($params['_ext'])) {
         $this->urlSuffix = '.' . $params['_ext'];
         unset($params['_ext']);
     }
     $url = parent::createUrl($route, $params, $ampersand);
     $this->urlSuffix = $oldUrlSuffix;
     return $url;
 }
开发者ID:codemix,项目名称:restyii,代码行数:14,代码来源:UrlManager.php


示例16: parseUrl

 public function parseUrl($request)
 {
     $searchPaths = array($request->pathInfo);
     // Also search for paths that end with the wildcard "*" (e.g. with news details)
     if ($lastPathSeparatorPos = strrpos($request->pathInfo, '/')) {
         $searchPaths[] = substr($request->pathInfo, 0, $lastPathSeparatorPos + 1) . '*';
     }
     $page = CmsPage::model()->findByAttributes(array('path' => $searchPaths));
     if ($page !== null) {
         return 'cms/page/default/id/' . $page->id;
     }
     return parent::parseUrl($request);
 }
开发者ID:rolandschaub,项目名称:roland-cms,代码行数:13,代码来源:CmsUrlManager.php


示例17: init

 /**
  * @return null
  */
 public function init()
 {
     parent::init();
     // Set this to false so extra query string parameters don't get the path treatment
     $this->appendParams = false;
     // makes more sense to set in HttpRequest
     if (craft()->config->usePathInfo()) {
         $this->setUrlFormat(static::PATH_FORMAT);
     } else {
         $this->setUrlFormat(static::GET_FORMAT);
     }
     $this->_routeVariables = array();
 }
开发者ID:nathanedwards,项目名称:cowfields.craft,代码行数:16,代码来源:UrlManager.php


示例18: processRules

 /**
  * Overrides processRules, allowing us to inject our own ruleset into the URL Manager
  * Takes no parameters
  **/
 protected function processRules()
 {
     $this->addBasicRules();
     $this->cacheRules('content', $this->contentUrlRulesId);
     $this->cacheRules('categories', $this->categoriesUrlRulesId);
     // Allow Sphinx Search settings to be dynamically via CiiSettings
     if (Cii::getConfig('sphinx_enabled')) {
         $this->rules['/search/<page:\\d+>'] = '/site/search';
         $this->rules['/search'] = '/site/search';
     }
     // Append our cache rules BEFORE we run the defaults
     $this->rules['<controller:\\w+>/<action:\\w+>/<id:\\d+>'] = '<controller>/<action>';
     $this->rules['<controller:\\w+>/<action:\\w+>'] = '<controller>/<action>';
     return parent::processRules();
 }
开发者ID:fandikurnia,项目名称:CiiMS,代码行数:19,代码来源:CiiURLManager.php


示例19: parseUrl

 public function parseUrl($request)
 {
     $path = '/' . $request->pathInfo;
     if (!empty($path)) {
         $Content = Content::model()->findByAttributes(array('path' => $path));
     }
     if ($Content && $Content->id) {
         $route = 'content/view/id/' . $Content->id;
         $_GET['path'] = $Content->path;
         //So that menu items become active
     } else {
         $route = parent::parseUrl($request);
     }
     return lcfirst(str_replace(' ', '', ucwords(str_replace('-', ' ', $route))));
 }
开发者ID:snapfrozen,项目名称:snapcms,代码行数:15,代码来源:SnapUrlManager.php


示例20: parseUrl

 public function parseUrl($request)
 {
     $route = parent::parseUrl($request);
     // Perform a 301 redirection if the current protocol
     // does not match the expected protocol
     $secureRoute = $this->isSecureRoute($route);
     $sslRequest = $request->isSecureConnection;
     if ($secureRoute !== $sslRequest) {
         $hostInfo = $secureRoute ? $this->secureHostInfo : $this->hostInfo;
         if (strpos($hostInfo, 'https') === 0 xor $sslRequest) {
             $request->redirect($hostInfo . $request->url, true, 301);
         }
     }
     return $route;
 }
开发者ID:aakbar24,项目名称:CollegeCorner_Ver_2.0,代码行数:15,代码来源:UrlManager.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP CUrlRewriter类代码示例发布时间:2022-05-20
下一篇:
PHP CUrlHelper类代码示例发布时间:2022-05-20
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap