From 14ff92d50780d42bf151dfb082c1c65c938df82d Mon Sep 17 00:00:00 2001 From: garvinhicking Date: Thu, 16 Mar 2006 13:43:41 +0000 Subject: [PATCH] Support better hooking possibilities, i.e. multilingual search. --- include/functions_entries.inc.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/include/functions_entries.inc.php b/include/functions_entries.inc.php index 1b7544e..f35145e 100644 --- a/include/functions_entries.inc.php +++ b/include/functions_entries.inc.php @@ -670,31 +670,31 @@ function serendipity_searchEntries($term, $limit = '') { $limit = serendipity_db_limit_sql($limit); $term = serendipity_db_escape_string($term); + $cond = array(); if ($serendipity['dbType'] == 'postgres') { $group = ''; $distinct = 'DISTINCT'; - $find_part = "(title ILIKE '%$term%' OR body ILIKE '%$term%' OR extended ILIKE '%$term%')"; + $cond['find_part'] = "(title ILIKE '%$term%' OR body ILIKE '%$term%' OR extended ILIKE '%$term%')"; } elseif ($serendipity['dbType'] == 'sqlite') { // Very extensive SQLite search. There currently seems no other way to perform fulltext search in SQLite // But it's better than no search at all :-D $group = 'GROUP BY e.id'; $distinct = ''; $term = serendipity_mb('strtolower', $term); - $find_part = "(lower(title) LIKE '%$term%' OR lower(body) LIKE '%$term%' OR lower(extended) LIKE '%$term%')"; + $cond['find_part'] = "(lower(title) LIKE '%$term%' OR lower(body) LIKE '%$term%' OR lower(extended) LIKE '%$term%')"; } else { $group = 'GROUP BY e.id'; $distinct = ''; $term = str_replace('"', '"', $term); if (preg_match('@["\+\-\*~<>\(\)]+@', $term)) { - $find_part = "MATCH(title,body,extended) AGAINST('$term' IN BOOLEAN MODE)"; + $cond['find_part'] = "MATCH(title,body,extended) AGAINST('$term' IN BOOLEAN MODE)"; } else { - $find_part = "MATCH(title,body,extended) AGAINST('$term')"; + $cond['find_part'] = "MATCH(title,body,extended) AGAINST('$term')"; } } - $cond = array(); $cond['and'] = " AND isdraft = 'false' " . (!serendipity_db_bool($serendipity['showFutureEntries']) ? " AND timestamp <= " . time() : ''); - serendipity_plugin_api::hook_event('frontend_fetchentries', $cond, array('source' => 'search')); + serendipity_plugin_api::hook_event('frontend_fetchentries', $cond, array('source' => 'search', 'term' => $term)); serendipity_ACL_SQL($cond, 'limited'); @@ -707,7 +707,7 @@ function serendipity_searchEntries($term, $limit = '') { ON e.id = ec.entryid {$cond['joins']} WHERE - $find_part + ({$cond['find_part']}) {$cond['and']}"; $querystring = "SELECT $distinct -- 2.39.5