[dokuwiki] Re: Search highlighting

----- Original Message -----
>Highlighting the search results when coming from Google is great! And only 
>a
>trivial extension to similarly include Yahoo as a valid referrer. See patch
>below. (If there's interest, perhaps there are other popular engines I
>should include?)

OK, after further research, it seems that _most_ search engines use only a 
few referrer styles, so I can make the code more generic, and cover these 
search engines:
    google, live/msn, aol, ask, altavista, alltheweb, gigablast, yahoo, 
lycos, netscape, clusty, hotbot, a9

I also assumed that not checking for a particular host will allow "unknown" 
referrers to also highlight.

See the alternate (and I think preferable) patch below.

Todd Augsburger
todd@xxxxxxxxxxxxxxxx
Roller Organs
www.rollerorgans.com


[Search engines result highlights
Todd Augsburger <todd@xxxxxxxxxxxxxxxx>**20070731000002
 Use a variety of referrer info styles to highlight search results
] {
hunk ./inc/common.php 905
-  if(!preg_match("#google\.#i",$url['host'])) return '';
-  $query = array();
-  parse_str($url['query'],$query);
-
-  return $query['q'];
+  $query = array();
+  parse_str($url['query'],$query);
+  if(isset($query['q']))
+    return $query['q'];        // google, live/msn, aol, ask, altavista, 
alltheweb, gigablast
+  elseif(isset($query['p']))
+    return $query['p'];        // yahoo
+  elseif(isset($query['query']))
+    return $query['query'];    // lycos, netscape, clusty, hotbot
+  elseif(preg_match("#a9\.com#i",$url['host'])) // a9
+    return urldecode(ltrim($url['path'],'/'));
+
+  return '';
}
 

-- 
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist

Other related posts: