本文整理汇总了PHP中Piwik_Common::getParseUrlReverse方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik_Common::getParseUrlReverse方法的具体用法?PHP Piwik_Common::getParseUrlReverse怎么用?PHP Piwik_Common::getParseUrlReverse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik_Common
的用法示例。
在下文中一共展示了Piwik_Common::getParseUrlReverse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: excludeQueryParametersFromUrl
static public function excludeQueryParametersFromUrl($originalUrl, $idSite)
{
$website = Piwik_Common::getCacheWebsiteAttributes( $idSite );
$originalUrl = Piwik_Common::unsanitizeInputValue($originalUrl);
$originalUrl = self::cleanupString($originalUrl);
$parsedUrl = @parse_url($originalUrl);
if(empty($parsedUrl['query']))
{
return $originalUrl;
}
$campaignTrackingParameters = Piwik_Common::getCampaignParameters();
$campaignTrackingParameters = array_merge(
$campaignTrackingParameters[0], // campaign name parameters
$campaignTrackingParameters[1] // campaign keyword parameters
);
$excludedParameters = isset($website['excluded_parameters'])
? $website['excluded_parameters']
: array();
$parametersToExclude = array_merge( $excludedParameters,
self::$queryParametersToExclude,
$campaignTrackingParameters);
$parametersToExclude = array_map('strtolower', $parametersToExclude);
$queryParameters = Piwik_Common::getArrayFromQueryString($parsedUrl['query']);
$validQuery = '';
$separator = '&';
foreach($queryParameters as $name => $value)
{
if(!in_array(strtolower($name), $parametersToExclude))
{
if (is_array($value))
{
foreach ($value as $param)
{
if($param === false)
{
$validQuery .= $name.'[]'.$separator;
}
else
{
$validQuery .= $name.'[]='.$param.$separator;
}
}
}
else if($value === false)
{
$validQuery .= $name.$separator;
}
else
{
$validQuery .= $name.'='.$value.$separator;
}
}
}
$parsedUrl['query'] = substr($validQuery,0,-strlen($separator));
$url = Piwik_Common::getParseUrlReverse($parsedUrl);
printDebug('Excluding parameters "'.implode(',',$excludedParameters).'" from URL');
if($originalUrl != $url)
{
printDebug(' Before was "'.$originalUrl.'"');
printDebug(' After is "'.$url.'"');
}
return $url;
}
示例2: detectSiteSearchFromUrl
protected function detectSiteSearchFromUrl($website, $parsedUrl)
{
$doRemoveSearchParametersFromUrl = false;
$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'] : '');
$parameters = Piwik_Common::getArrayFromQueryString($queryString);
self::reencodeParameters($parameters, $this->pageEncoding);
// Detect Site Search
foreach ($keywordParameters as $keywordParameter) {
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 $categoryParameter) {
if (!empty($parameters[$categoryParameter])) {
$categoryName = $parameters[$categoryParameter];
break;
}
}
if (isset($parameters[self::PARAMETER_NAME_SEARCH_COUNT]) && $this->isValidSearchCount($parameters[self::PARAMETER_NAME_SEARCH_COUNT])) {
$count = $parameters[self::PARAMETER_NAME_SEARCH_COUNT];
}
// Remove search kwd from URL
if ($doRemoveSearchParametersFromUrl) {
// @see excludeQueryParametersFromUrl()
// Excluded the detected parameters from the URL
$parametersToExclude = array($categoryParameter, $keywordParameter);
$parsedUrl['query'] = self::getQueryStringWithExcludedParameters(Piwik_Common::getArrayFromQueryString($parsedUrl['query']), $parametersToExclude);
$parsedUrl['fragment'] = self::getQueryStringWithExcludedParameters(Piwik_Common::getArrayFromQueryString($parsedUrl['fragment']), $parametersToExclude);
}
$url = Piwik_Common::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);
}