diff options
author | ArthurHoaro <arthur@hoa.ro> | 2017-05-25 15:54:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-25 15:54:20 +0200 |
commit | 3e395a6bc63cba16b0772a382f6cbac0ce4ab906 (patch) | |
tree | 220eaf3400aeeea821b7e150855a1d44f1b5bfe9 /application/LinkDB.php | |
parent | b2e2aa42e288e0becaa95bf9cc3be679743fc98e (diff) | |
parent | 7d86f40bdb2135655b5b4fe8cbcc1ac102114f86 (diff) | |
download | Shaarli-3e395a6bc63cba16b0772a382f6cbac0ce4ab906.tar.gz Shaarli-3e395a6bc63cba16b0772a382f6cbac0ce4ab906.tar.zst Shaarli-3e395a6bc63cba16b0772a382f6cbac0ce4ab906.zip |
Merge pull request #841 from ArthurHoaro/feature/search-no-tag
Empty tag search will look for not tagged links
Diffstat (limited to 'application/LinkDB.php')
-rw-r--r-- | application/LinkDB.php | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/application/LinkDB.php b/application/LinkDB.php index 7802cc8a..8ca0fab3 100644 --- a/application/LinkDB.php +++ b/application/LinkDB.php | |||
@@ -423,29 +423,12 @@ You use the community supported version of the original Shaarli project, by Seba | |||
423 | public function filterSearch($filterRequest = array(), $casesensitive = false, $visibility = 'all') | 423 | public function filterSearch($filterRequest = array(), $casesensitive = false, $visibility = 'all') |
424 | { | 424 | { |
425 | // Filter link database according to parameters. | 425 | // Filter link database according to parameters. |
426 | $searchtags = !empty($filterRequest['searchtags']) ? escape($filterRequest['searchtags']) : ''; | 426 | $searchtags = isset($filterRequest['searchtags']) ? escape($filterRequest['searchtags']) : ''; |
427 | $searchterm = !empty($filterRequest['searchterm']) ? escape($filterRequest['searchterm']) : ''; | 427 | $searchterm = isset($filterRequest['searchterm']) ? escape($filterRequest['searchterm']) : ''; |
428 | 428 | ||
429 | // Search tags + fullsearch. | 429 | // Search tags + fullsearch - blank string parameter will return all links. |
430 | if (! empty($searchtags) && ! empty($searchterm)) { | 430 | $type = LinkFilter::$FILTER_TAG | LinkFilter::$FILTER_TEXT; |
431 | $type = LinkFilter::$FILTER_TAG | LinkFilter::$FILTER_TEXT; | 431 | $request = [$searchtags, $searchterm]; |
432 | $request = array($searchtags, $searchterm); | ||
433 | } | ||
434 | // Search by tags. | ||
435 | elseif (! empty($searchtags)) { | ||
436 | $type = LinkFilter::$FILTER_TAG; | ||
437 | $request = $searchtags; | ||
438 | } | ||
439 | // Fulltext search. | ||
440 | elseif (! empty($searchterm)) { | ||
441 | $type = LinkFilter::$FILTER_TEXT; | ||
442 | $request = $searchterm; | ||
443 | } | ||
444 | // Otherwise, display without filtering. | ||
445 | else { | ||
446 | $type = ''; | ||
447 | $request = ''; | ||
448 | } | ||
449 | 432 | ||
450 | $linkFilter = new LinkFilter($this); | 433 | $linkFilter = new LinkFilter($this); |
451 | return $linkFilter->filter($type, $request, $casesensitive, $visibility); | 434 | return $linkFilter->filter($type, $request, $casesensitive, $visibility); |