$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');
ON e.id = ec.entryid
{$cond['joins']}
WHERE
- $find_part
+ ({$cond['find_part']})
{$cond['and']}";
$querystring = "SELECT $distinct