getParseUrlReverse() публичный статический Метод

Copied from the PHP comments at http://php.net/parse_url.
public static getParseUrlReverse ( array $parsed ) : false | string
$parsed array Result of [parse_url](http://php.net/manual/en/function.parse-url.php).
Результат false | string The URL or `false` if `$parsed` isn't an array.
Пример #1
0
 /**
  * Build the full URL from the prefix ID and the rest.
  *
  * @param string $url
  * @param integer $prefixId
  * @return string
  */
 public static function reconstructNormalizedUrl($url, $prefixId)
 {
     $map = array_flip(self::$urlPrefixMap);
     if ($prefixId !== null && isset($map[$prefixId])) {
         $fullUrl = $map[$prefixId] . $url;
     } else {
         $fullUrl = $url;
     }
     // Clean up host & hash tags, for URLs
     $parsedUrl = @parse_url($fullUrl);
     $parsedUrl = PageUrl::cleanupHostAndHashTag($parsedUrl);
     $url = UrlHelper::getParseUrlReverse($parsedUrl);
     if (!empty($url)) {
         return $url;
     }
     return $fullUrl;
 }
Пример #2
0
 protected function detectSiteSearchFromUrl($website, $parsedUrl)
 {
     $doRemoveSearchParametersFromUrl = true;
     $separator = '&';
     $count = $actionName = $categoryName = false;
     $keywordParameters = isset($website['sitesearch_keyword_parameters']) ? $website['sitesearch_keyword_parameters'] : array();
     $queryString = (!empty($parsedUrl['query']) ? $parsedUrl['query'] : '') . (!empty($parsedUrl['fragment']) ? $separator . $parsedUrl['fragment'] : '');
     $parametersRaw = UrlHelper::getArrayFromQueryString($queryString);
     // strtolower the parameter names for smooth site search detection
     $parameters = array();
     foreach ($parametersRaw as $k => $v) {
         $parameters[Common::mb_strtolower($k)] = $v;
     }
     // decode values if they were sent from a client using another charset
     $pageEncoding = $this->request->getParam('cs');
     PageUrl::reencodeParameters($parameters, $pageEncoding);
     // Detect Site Search keyword
     foreach ($keywordParameters as $keywordParameterRaw) {
         $keywordParameter = Common::mb_strtolower($keywordParameterRaw);
         if (!empty($parameters[$keywordParameter])) {
             $actionName = $parameters[$keywordParameter];
             break;
         }
     }
     if (empty($actionName)) {
         return false;
     }
     $categoryParameters = isset($website['sitesearch_category_parameters']) ? $website['sitesearch_category_parameters'] : array();
     foreach ($categoryParameters as $categoryParameterRaw) {
         $categoryParameter = Common::mb_strtolower($categoryParameterRaw);
         if (!empty($parameters[$categoryParameter])) {
             $categoryName = $parameters[$categoryParameter];
             break;
         }
     }
     if (isset($parameters['search_count']) && $this->isValidSearchCount($parameters['search_count'])) {
         $count = $parameters['search_count'];
     }
     // Remove search kwd from URL
     if ($doRemoveSearchParametersFromUrl) {
         // @see excludeQueryParametersFromUrl()
         // Excluded the detected parameters from the URL
         $parametersToExclude = array($categoryParameterRaw, $keywordParameterRaw);
         if (isset($parsedUrl['query'])) {
             $parsedUrl['query'] = UrlHelper::getQueryStringWithExcludedParameters(UrlHelper::getArrayFromQueryString($parsedUrl['query']), $parametersToExclude);
         }
         if (isset($parsedUrl['fragment'])) {
             $parsedUrl['fragment'] = UrlHelper::getQueryStringWithExcludedParameters(UrlHelper::getArrayFromQueryString($parsedUrl['fragment']), $parametersToExclude);
         }
     }
     $url = UrlHelper::getParseUrlReverse($parsedUrl);
     if (is_array($actionName)) {
         $actionName = reset($actionName);
     }
     $actionName = trim(urldecode($actionName));
     if (empty($actionName)) {
         return false;
     }
     if (is_array($categoryName)) {
         $categoryName = reset($categoryName);
     }
     $categoryName = trim(urldecode($categoryName));
     return array($url, $actionName, $categoryName, $count);
 }