upstream
This commit is contained in:
parent
4ee90aa2e5
commit
d30c3104f1
@ -1,10 +1,14 @@
|
||||
ChangeLog:
|
||||
""""""""""
|
||||
|
||||
[Version 1.8 2010/10/11] by Ian (Timbalu)
|
||||
- added highlighting static page, if not having a ['GET']['searchTerm'] REQUEST, but coming from a /search/ referrer
|
||||
- changed $_REQUEST to $serendipity['GET']
|
||||
|
||||
[Version 1.7 2010/09/30] by Ian (Timbalu)
|
||||
- added to support the wildcard(*) search which was added in core.
|
||||
it will now act like a fuzzy search, if you enter an asterisk search. The search 'word*' will highlight case insensive all occurences of '%word%'.
|
||||
- added the searchengine Bing (untested)
|
||||
- added to config the ability to highlight search results in static pages
|
||||
which are appended at the end of the search page. This does not work in the teaser itself, but on the opend static page.
|
||||
which are appended at the end of the search page. This does not work in the teaser itself, but inside the opened static page.
|
||||
- added lang files constants <en>, <de> and <de-utf8>
|
||||
|
@ -18,7 +18,7 @@ class serendipity_event_searchhighlight extends serendipity_event
|
||||
$propbag->add('description', PLUGIN_EVENT_SEARCHHIGHLIGHT_DESC);
|
||||
$propbag->add('stackable', false);
|
||||
$propbag->add('author', 'Tom Sommer');
|
||||
$propbag->add('version', '1.7');
|
||||
$propbag->add('version', '1.8');
|
||||
$propbag->add('requirements', array(
|
||||
'serendipity' => '0.8',
|
||||
'smarty' => '2.6.7',
|
||||
@ -135,7 +135,7 @@ class serendipity_event_searchhighlight extends serendipity_event
|
||||
$this->loadConstants();
|
||||
$url = parse_url($this->uri);
|
||||
parse_str($url['query'], $pStr);
|
||||
|
||||
|
||||
$s = $this->getSearchEngine();
|
||||
|
||||
switch ( $s ) {
|
||||
@ -145,8 +145,21 @@ class serendipity_event_searchhighlight extends serendipity_event
|
||||
if (!empty($_REQUEST['serendipity']['searchTerm'])) {
|
||||
$query = $_REQUEST['serendipity']['searchTerm'];
|
||||
}
|
||||
|
||||
if (!empty($serendipity['GET']['searchTerm'])) {
|
||||
$query = $serendipity['GET']['searchTerm'];
|
||||
}
|
||||
/* highlight selected static page, if not having a ['GET']['searchTerm'] REQUEST, but coming from a /search/ referrer */
|
||||
if(empty($query)) {
|
||||
// look out for path or query depending mod_rewrite setting
|
||||
$urlpath = (($serendipity['rewrite'] == 'rewrite') ? parse_url($_SERVER['HTTP_REFERER'], PHP_URL_PATH)
|
||||
: parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY)
|
||||
);
|
||||
if ( strpos($urlpath, 'search/') ) {
|
||||
$urlpath = htmlspecialchars(strip_tags($urlpath)); // avoid spoofing
|
||||
$path = explode('/', urldecode($urlpath)); // split and decode non ASCII
|
||||
$query = $path[(array_search('search', $path)+1)];
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@ -174,7 +187,7 @@ class serendipity_event_searchhighlight extends serendipity_event
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Clean the query */
|
||||
$query = trim($query);
|
||||
if (empty($query)) return false;
|
||||
@ -199,14 +212,15 @@ class serendipity_event_searchhighlight extends serendipity_event
|
||||
if (!isset($hooks[$event])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if ( $event == 'frontend_display' ) {
|
||||
if ( ($queries = $this->getQuery()) === false ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$_SESSION['is_searchengine_visitor'] = true;
|
||||
$_SESSION['search_referer'] = $this->uri;
|
||||
|
||||
|
||||
foreach ($this->markup_elements as $temp) {
|
||||
|
||||
if ( ! (serendipity_db_bool($this->get_config($temp['name'])) && isset($eventData[$temp['element']])) ) {
|
||||
@ -239,7 +253,7 @@ class serendipity_event_searchhighlight extends serendipity_event
|
||||
$_pattern = '/(\b'. preg_quote($word, '/') .'\b)/im';
|
||||
}
|
||||
}
|
||||
$element = preg_replace($_pattern, '<span class="serendipity_searchQuery">$1</span>', $element);
|
||||
$element = preg_replace($_pattern, '<span class="serendipity_searchQuery">$1</span>', $element);
|
||||
} // end foreach
|
||||
} // end foreach
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user