Info about the most recent changes of the plugin code can be found on the SourceForge SVN server:
Browse the history of NP_SearchHighlight at Sourceforge
<?php /** * Plugin for Nucleus CMS (http://plugins.nucleuscms.org/) * Copyright (C) 2003 The Nucleus Plugins Project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * see license.txt for the full license */ /* history: v0.3 (2003-08-01) made it even easier to add more search engines (karma) v0.2 (2003-07-31) added some engines and use a function to parse the querystring so it's more obvious how to add searchengines yourself (Xiffy) v0.1 (2003-07-30) initial version: Google only */ class NP_SearchHighlight extends NucleusPlugin { function getName() { return 'Search Highlight'; } function getAuthor() { return 'Wouter Demuynck'; } function getURL() { return 'http://nucleuscms.org/'; } function getVersion() { return '0.3'; } function getDescription() { return 'When a visitor arrives at an item-page through a search engine, the terms from the search query are highlighted automatically'; } function getMinNucleusVersion() { return 200; } function init() { /* extra engines can be added here. (make sure last line does not end with a comma) engine => series of possible query elements (comma separated) */ $this->aEngines = array( 'google' => 'q,as_q,as_oq,as_epq', 'altavista' => 'q', 'search.yahoo' => 'p', 'search.msn' => 'q', 'lycos' => 'query', 'hotbot' => 'query', 'ilse' => 'search_for', 'vinden' => 'query', 'zoeken' => 'query', 'advalvas' => 'WORD' ); } function supportsFeature($what) { switch($what) { case 'SqlTablePrefix': return 1; default: return 0; } } function getEventList() { return array('PreSkinParse'); } function event_PreSkinParse(&$data) { $referer = serverVar('HTTP_REFERER'); // parse query-string $url = parse_url($referer); parse_str($url,$res); global $highlight; $highlight = $this->engineString($url[host],$url[query]); } /** * Tries to parse a hostname and querystring into a search query * * @param $from * hostname (e.g. 'google.com') * @param $query * query string (e.g. 'hl=nl&q=jeuj&ie=UTF-8) * @return * search query words (if any) or an empty string */ function engineString($from, $query) { $from = strtolower($from); $q = ''; foreach ($this->aEngines as $engine => $fieldnames) { if (strstr($from, $engine)) { parse_str($query,$res); $aFields = explode(',', $fieldnames); foreach ($aFields as $field) { if ($res[$field]) $q .= ' ' . $res[$field]; } if ($q) break; } } return trim($q); } } ?>