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


PHP CUrlManager::parsePathInfo方法代碼示例

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


在下文中一共展示了CUrlManager::parsePathInfo方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: parseUrl

 /**
  * Parases a URL based on this rule.
  * @param CUrlManager the URL manager
  * @param string path info part of the URL
  * @param string path info that contains the potential URL suffix
  * @return string the route that consists of the controller ID and action ID
  */
 public function parseUrl($manager, $pathInfo, $rawPathInfo)
 {
     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 && ($this->urlSuffix != '' || $this->urlSuffix === null && $manager->urlSuffix != '')) {
         throw new CHttpException(404, Yii::t('yii', 'Unable to resolve the request "{route}".', array('{route}' => $rawPathInfo)));
     }
     $pathInfo .= '/';
     if (preg_match($this->pattern . $case, $pathInfo, $matches)) {
         foreach ($this->defaultParams as $name => $value) {
             if (!isset($_GET[$name])) {
                 $_GET[$name] = $value;
             }
         }
         $tr = array();
         foreach ($matches as $key => $value) {
             if (isset($this->references[$key])) {
                 $tr[$this->references[$key]] = $value;
             } else {
                 if (isset($this->params[$key])) {
                     $_GET[$key] = $value;
                 }
             }
         }
         if ($pathInfo !== $matches[0]) {
             // there're additional GET params
             CUrlManager::parsePathInfo(ltrim(substr($pathInfo, strlen($matches[0])), '/'));
         }
         if ($this->routePattern !== null) {
             return strtr($this->route, $tr);
         } else {
             return $this->route;
         }
     } else {
         return false;
     }
 }
開發者ID:Bitcoinsulting,項目名稱:yiimp,代碼行數:51,代碼來源:CUrlManager.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: parseActionParams

 /**
  * Parses a path info into an action ID and GET variables.
  * @param string path info
  * @return string action ID
  * @since 1.0.3
  */
 protected function parseActionParams($pathInfo)
 {
     if (($pos = strpos($pathInfo, '/')) !== false) {
         CUrlManager::parsePathInfo((string) substr($pathInfo, $pos + 1));
         $actionID = substr($pathInfo, 0, $pos);
         return $this->getUrlManager()->caseSensitive ? $actionID : strtolower($actionID);
     } else {
         return $pathInfo;
     }
 }
開發者ID:Bitcoinsulting,項目名稱:yiimp,代碼行數:16,代碼來源:CWebApplication.php


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