本文整理汇总了PHP中Piwik_Common::getSearchEngineUrls方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik_Common::getSearchEngineUrls方法的具体用法?PHP Piwik_Common::getSearchEngineUrls怎么用?PHP Piwik_Common::getSearchEngineUrls使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik_Common
的用法示例。
在下文中一共展示了Piwik_Common::getSearchEngineUrls方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Piwik_getSearchEngineUrlFromUrlAndKeyword
/**
* Return search engine URL for URL and keyword
*
* @see core/DataFiles/SearchEnginges.php
*
* @param string $url Domain name, e.g., search.piwik.org
* @param string $keyword Keyword, e.g., web+analytics
* @return string URL, e.g., http://search.piwik.org/q=web+analytics
*/
function Piwik_getSearchEngineUrlFromUrlAndKeyword($url, $keyword)
{
$searchEngineUrls = Piwik_Common::getSearchEngineUrls();
$keyword = urlencode($keyword);
$keyword = str_replace(urlencode('+'), urlencode(' '), $keyword);
$path = @$searchEngineUrls[Piwik_getSearchEngineHostPathFromUrl($url)][2];
if(empty($path))
{
return false;
}
$path = str_replace("{k}", $keyword, $path);
return $url . (substr($url, -1) != '/' ? '/' : '') . $path;
}
示例2: Piwik_getSearchEngineUrlFromUrlAndKeyword
/**
* Return search engine URL for URL and keyword
*
* @see core/DataFiles/SearchEnginges.php
*
* @param string $url Domain name, e.g., search.piwik.org
* @param string $keyword Keyword, e.g., web+analytics
* @return string URL, e.g., http://search.piwik.org/q=web+analytics
*/
function Piwik_getSearchEngineUrlFromUrlAndKeyword($url, $keyword)
{
if ($keyword === Piwik_Referers::LABEL_KEYWORD_NOT_DEFINED) {
return 'http://piwik.org/faq/general/#faq_144';
}
$searchEngineUrls = Piwik_Common::getSearchEngineUrls();
$keyword = urlencode($keyword);
$keyword = str_replace(urlencode('+'), urlencode(' '), $keyword);
$path = @$searchEngineUrls[Piwik_getSearchEngineHostPathFromUrl($url)][2];
if (empty($path)) {
return false;
}
$path = str_replace("{k}", $keyword, $path);
return $url . (substr($url, -1) != '/' ? '/' : '') . $path;
}