]> git.mjollnir.org Git - s9y.git/commitdiff
Support better hooking possibilities, i.e. multilingual search.
authorgarvinhicking <garvinhicking>
Thu, 16 Mar 2006 13:43:41 +0000 (13:43 +0000)
committergarvinhicking <garvinhicking>
Thu, 16 Mar 2006 13:43:41 +0000 (13:43 +0000)
include/functions_entries.inc.php

index 1b7544e526759ac4e2f27d36e4ac4515ec81c5dd..f35145e452cd3321ab81d388ddfbc5d42ef7337b 100644 (file)
@@ -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('&quot;', '"', $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