diff options
author | Lukas Fleischer <lfleischer@archlinux.org> | 2015-05-22 12:06:46 +0200 |
---|---|---|
committer | Lukas Fleischer <lfleischer@archlinux.org> | 2015-05-22 13:08:06 +0200 |
commit | 20b838a90c5874c11cb68d3ca0bf7cc3bf3c0180 (patch) | |
tree | 5a85ebc063e1c6c4576dbf6778393ff6de2419b9 | |
parent | 913367606e27b5a5c72c63de4da4d5e09f499a03 (diff) | |
download | aurweb-20b838a90c5874c11cb68d3ca0bf7cc3bf3c0180.tar.xz |
Use keyword search by default
Change the default search mode such that packages that contain all of
the space-separated search terms are returned. For example, the query
image edit "command line"
returns all packages where "image", "edit" and "command line" occurs in
the package name or description. This is much more convenient and
general than a simple substring search (one can still perform a
substring search by quoting the whole search term).
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
-rw-r--r-- | web/lib/pkgfuncs.inc.php | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php index c71358a..8fd629f 100644 --- a/web/lib/pkgfuncs.inc.php +++ b/web/lib/pkgfuncs.inc.php @@ -601,9 +601,11 @@ function pkg_search_page($SID="") { } else { /* Search by name and description (default). */ - $K = "%" . addcslashes($_GET['K'], '%_') . "%"; - $q_where .= "AND (Packages.Name LIKE " . $dbh->quote($K) . " OR "; - $q_where .= "Description LIKE " . $dbh->quote($K) . ") "; + foreach (str_getcsv($_GET['K'], ' ') as $term) { + $term = "%" . addcslashes($term, '%_') . "%"; + $q_where .= "AND (Packages.Name LIKE " . $dbh->quote($term) . " OR "; + $q_where .= "Description LIKE " . $dbh->quote($term) . ") "; + } } } |