mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-15 17:25:57 +00:00
search: simplify code, allow searching by note and title content (note:blah, title:blah)
This commit is contained in:
@@ -2132,31 +2132,50 @@
|
|||||||
|
|
||||||
$commandpair = explode(":", mb_strtolower($k), 2);
|
$commandpair = explode(":", mb_strtolower($k), 2);
|
||||||
|
|
||||||
if ($commandpair[0] == "note" && $commandpair[1]) {
|
switch ($commandpair[0]) {
|
||||||
|
case "title":
|
||||||
|
if ($commandpair[1]) {
|
||||||
|
array_push($query_keywords, "($not (LOWER(ttrss_entries.title) LIKE '%".
|
||||||
|
db_escape_string($link, mb_strtolower($commandpair[1]))."%'))");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "author":
|
||||||
|
if ($commandpair[1]) {
|
||||||
|
array_push($query_keywords, "($not (LOWER(author) LIKE '%".
|
||||||
|
db_escape_string($link, mb_strtolower($commandpair[1]))."%'))");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "note":
|
||||||
|
if ($commandpair[1]) {
|
||||||
if ($commandpair[1] == "true")
|
if ($commandpair[1] == "true")
|
||||||
array_push($query_keywords, "($not (note IS NOT NULL AND note != ''))");
|
array_push($query_keywords, "($not (note IS NOT NULL AND note != ''))");
|
||||||
else if ($commandpair[1] == "false")
|
else if ($commandpair[1] == "false")
|
||||||
array_push($query_keywords, "($not (note IS NULL OR note = ''))");
|
array_push($query_keywords, "($not (note IS NULL OR note = ''))");
|
||||||
else
|
else
|
||||||
array_push($query_keywords, "($not (note LIKE '%".
|
array_push($query_keywords, "($not (LOWER(note) LIKE '%".
|
||||||
db_escape_string($link, $commandpair[1])."%'))");
|
db_escape_string($link, mb_strtolower($commandpair[1]))."%'))");
|
||||||
|
}
|
||||||
} else if ($commandpair[0] == "star" && $commandpair[1]) {
|
break;
|
||||||
|
case "star":
|
||||||
|
|
||||||
|
if ($commandpair[1]) {
|
||||||
if ($commandpair[1] == "true")
|
if ($commandpair[1] == "true")
|
||||||
array_push($query_keywords, "($not (marked = true))");
|
array_push($query_keywords, "($not (marked = true))");
|
||||||
else
|
else
|
||||||
array_push($query_keywords, "($not (marked = false))");
|
array_push($query_keywords, "($not (marked = false))");
|
||||||
|
}
|
||||||
} else if ($commandpair[0] == "pub" && $commandpair[1]) {
|
break;
|
||||||
|
case "pub":
|
||||||
|
if ($commandpair[1]) {
|
||||||
if ($commandpair[1] == "true")
|
if ($commandpair[1] == "true")
|
||||||
array_push($query_keywords, "($not (published = true))");
|
array_push($query_keywords, "($not (published = true))");
|
||||||
else
|
else
|
||||||
array_push($query_keywords, "($not (published = false))");
|
array_push($query_keywords, "($not (published = false))");
|
||||||
|
|
||||||
} else if (strpos($k, "@") === 0) {
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (strpos($k, "@") === 0) {
|
||||||
|
|
||||||
$user_tz_string = get_pref($link, 'USER_TIMEZONE', $_SESSION['uid']);
|
$user_tz_string = get_pref($link, 'USER_TIMEZONE', $_SESSION['uid']);
|
||||||
$orig_ts = strtotime(substr($k, 1));
|
$orig_ts = strtotime(substr($k, 1));
|
||||||
@@ -2170,6 +2189,7 @@
|
|||||||
OR UPPER(ttrss_entries.content) $not LIKE UPPER('%$k%'))");
|
OR UPPER(ttrss_entries.content) $not LIKE UPPER('%$k%'))");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$search_query_part = implode("AND", $query_keywords);
|
$search_query_part = implode("AND", $query_keywords);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user