/** * Given the Input URL, will exclude all query parameters set for this site * * @static * @param $originalUrl * @param $idSite * @return bool|string Returned URL is HTML entities decoded */ public static function excludeQueryParametersFromUrl($originalUrl, $idSite) { $originalUrl = self::cleanupUrl($originalUrl); $parsedUrl = @parse_url($originalUrl); $parsedUrl = self::cleanupHostAndHashTag($parsedUrl, $idSite); $parametersToExclude = self::getQueryParametersToExclude($idSite); if (empty($parsedUrl['query'])) { if (empty($parsedUrl['fragment'])) { return UrlHelper::getParseUrlReverse($parsedUrl); } // Exclude from the hash tag as well $queryParameters = UrlHelper::getArrayFromQueryString($parsedUrl['fragment']); $parsedUrl['fragment'] = UrlHelper::getQueryStringWithExcludedParameters($queryParameters, $parametersToExclude); $url = UrlHelper::getParseUrlReverse($parsedUrl); return $url; } $queryParameters = UrlHelper::getArrayFromQueryString($parsedUrl['query']); $parsedUrl['query'] = UrlHelper::getQueryStringWithExcludedParameters($queryParameters, $parametersToExclude); $url = UrlHelper::getParseUrlReverse($parsedUrl); return $url; }
/** * Returns an array mapping query paramater names with query parameter values for * the current URL. * * @return array If current URL is `"http://example.org/dir1/dir2/index.php?param1=value1¶m2=value2"` * this will return: * * array( * 'param1' => string 'value1', * 'param2' => string 'value2' * ) * @api */ public static function getArrayFromCurrentQueryString() { $queryString = self::getCurrentQueryString(); $urlValues = UrlHelper::getArrayFromQueryString($queryString); return $urlValues; }