當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CUrlManager類代碼示例

本文整理匯總了PHP中CUrlManager的典型用法代碼示例。如果您正苦於以下問題:PHP CUrlManager類的具體用法?PHP CUrlManager怎麽用?PHP CUrlManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了CUrlManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例15: 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


注:本文中的CUrlManager類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。