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


PHP CUrlManager::createUrl方法代码示例

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


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

示例1: createUrl

 public function createUrl($route, $params = array(), $ampersand = '&')
 {
     if (preg_match('/[A-Z]/', $route) !== 0) {
         $route = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '-\\1', $route));
     }
     return parent::createUrl($route, $params, $ampersand);
 }
开发者ID:bryglen,项目名称:yii-advanced-template,代码行数:7,代码来源:UrlManager.php

示例2: createUrl

 public function createUrl($route, $params = array(), $ampersand = '&')
 {
     $route = preg_replace_callback('/(?<![A-Z])[A-Z]/', function ($matches) {
         return '-' . lcfirst($matches[0]);
     }, $route);
     return parent::createUrl($route, $params, $ampersand);
 }
开发者ID:annamoorjani,项目名称:dental,代码行数:7,代码来源:UrlManager.php

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

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

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

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

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

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

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

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

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

示例14: createUrl

 public function createUrl($route, $params = array(), $ampersand = '&')
 {
     $url = parent::createUrl($route, $params, $ampersand);
     // If already an absolute URL, return it directly
     if (strpos($url, 'http') === 0) {
         return $url;
     }
     // Check if the current protocol matches the expected protocol of the route
     // If not, prefix the generated URL with the correct host info.
     $secureRoute = $this->isSecureRoute($route);
     if (Yii::app()->request->isSecureConnection) {
         return $secureRoute ? $url : $this->hostInfo . $url;
     } else {
         return $secureRoute ? $this->secureHostInfo . $url : $url;
     }
 }
开发者ID:bfyang5130,项目名称:zzl,代码行数:16,代码来源:UrlManager.php

示例15: createUrl

 public function createUrl($route, $params = array(), $ampersand = '&')
 {
     if ($route !== 'tstranslation') {
         if ($this->showLangInUrl) {
             if (empty($params['_lang'])) {
                 $params['_lang'] = Yii::app()->language;
             }
         } else {
             if (isset($params['_lang'])) {
                 unset($params['_lang']);
             }
         }
     } else {
         $params = array();
     }
     return parent::createUrl($route, $params, $ampersand);
 }
开发者ID:nilojan,项目名称:yii-cms,代码行数:17,代码来源:TsUrlManager.php


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