diff options
author | matt <matt@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2009-05-31 15:31:14 +0400 |
---|---|---|
committer | matt <matt@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2009-05-31 15:31:14 +0400 |
commit | 1e11d3289f3961924280e5440d0ae15ad0e6ad00 (patch) | |
tree | e67cbf2d1f837dffeaaacdb98f7fa237a3312241 /plugins/Referers/functions.php | |
parent | c37b3a8b5ab04df8b5602d1a63222c0ccf4d68ef (diff) |
- on a rainy sunday night, implented one of the most requested feature which was little work and should make a lot of users happy!
fixes #747
adding links on both sub tables for search engines and keywords linking directly to the search engine page for this keyword
added definition for the main search engines (approx 15) users can contribute more if they like; if a definition, eg. "search?q={k}" for Google is not found, then we simply link to the search engine homepage.
updated FAQ on how to add a search engine see http://piwik.org/faq/general/#faq_39
added tests to check that the search engine file is defined properly
- renamed queuefilter to queueFilter for consistency
Diffstat (limited to 'plugins/Referers/functions.php')
-rw-r--r-- | plugins/Referers/functions.php | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/plugins/Referers/functions.php b/plugins/Referers/functions.php index 1683d9bdbc..c0118ae837 100644 --- a/plugins/Referers/functions.php +++ b/plugins/Referers/functions.php @@ -23,14 +23,10 @@ function Piwik_getSearchEngineUrlFromName($name) return $url; } - -function Piwik_getSearchEngineLogoFromName($url) +function Piwik_getSearchEngineLogoFromUrl($url) { - require_once "DataFiles/SearchEngines.php"; - $beginningUrl = strpos($url,'//') + 2; - $pathInPiwik = 'plugins/Referers/images/searchEngines/%s.png'; - $pathWithCode = sprintf($pathInPiwik, substr($url,$beginningUrl)); + $pathWithCode = sprintf($pathInPiwik, Piwik_getSearchEngineHostFromUrl($url)); $absolutePath = PIWIK_INCLUDE_PATH . '/' . $pathWithCode; if(file_exists($absolutePath)) { @@ -39,6 +35,24 @@ function Piwik_getSearchEngineLogoFromName($url) return sprintf($pathInPiwik, 'xx'); } +function Piwik_getSearchEngineHostFromUrl($url) +{ + return substr($url, strpos($url,'//') + 2); +} + +function Piwik_getSearchEngineUrlFromUrlAndKeyword($url, $keyword) +{ + require_once "DataFiles/SearchEngines.php"; + $keyword = urlencode($keyword); + $path = @$GLOBALS['Piwik_SearchEngines'][Piwik_getSearchEngineHostFromUrl($url)][2]; + $path = str_replace("{k}", $keyword, $path); + return $url . '/' . $path; +} + +function Piwik_getSearchEngineUrlFromKeywordAndUrl($keyword, $url) +{ + return Piwik_getSearchEngineUrlFromUrlAndKeyword($url, $keyword); +} function Piwik_getRefererTypeLabel($label) { |