diff options
author | ArthurHoaro <arthur@hoa.ro> | 2017-04-01 12:17:37 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2017-05-25 15:51:12 +0200 |
commit | 7d86f40bdb2135655b5b4fe8cbcc1ac102114f86 (patch) | |
tree | c70ac4ad89a4fc84b8e52114aca7d9755cc92086 /application/LinkDB.php | |
parent | b64d83cd2b60b6851741787f8ce2ae2c93092841 (diff) | |
download | Shaarli-7d86f40bdb2135655b5b4fe8cbcc1ac102114f86.tar.gz Shaarli-7d86f40bdb2135655b5b4fe8cbcc1ac102114f86.tar.zst Shaarli-7d86f40bdb2135655b5b4fe8cbcc1ac102114f86.zip |
Empty tag search will look for not tagged links
Fixes #784
From now, searching for tags with an empty value will return only not tagged links,
with the search bar showing `x results [not tagged]`.
Note that using the api, the searchtags request parameter must be set to `false` to get the same result.
- [ ] Update API doc
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 4cee2af9..a03c2c06 100644 --- a/application/LinkDB.php +++ b/application/LinkDB.php | |||
@@ -450,29 +450,12 @@ You use the community supported version of the original Shaarli project, by Seba | |||
450 | public function filterSearch($filterRequest = array(), $casesensitive = false, $visibility = 'all') | 450 | public function filterSearch($filterRequest = array(), $casesensitive = false, $visibility = 'all') |
451 | { | 451 | { |
452 | // Filter link database according to parameters. | 452 | // Filter link database according to parameters. |
453 | $searchtags = !empty($filterRequest['searchtags']) ? escape($filterRequest['searchtags']) : ''; | 453 | $searchtags = isset($filterRequest['searchtags']) ? escape($filterRequest['searchtags']) : ''; |
454 | $searchterm = !empty($filterRequest['searchterm']) ? escape($filterRequest['searchterm']) : ''; | 454 | $searchterm = isset($filterRequest['searchterm']) ? escape($filterRequest['searchterm']) : ''; |
455 | 455 | ||
456 | // Search tags + fullsearch. | 456 | // Search tags + fullsearch - blank string parameter will return all links. |
457 | if (! empty($searchtags) && ! empty($searchterm)) { | 457 | $type = LinkFilter::$FILTER_TAG | LinkFilter::$FILTER_TEXT; |
458 | $type = LinkFilter::$FILTER_TAG | LinkFilter::$FILTER_TEXT; | 458 | $request = [$searchtags, $searchterm]; |
459 | $request = array($searchtags, $searchterm); | ||
460 | } | ||
461 | // Search by tags. | ||
462 | elseif (! empty($searchtags)) { | ||
463 | $type = LinkFilter::$FILTER_TAG; | ||
464 | $request = $searchtags; | ||
465 | } | ||
466 | // Fulltext search. | ||
467 | elseif (! empty($searchterm)) { | ||
468 | $type = LinkFilter::$FILTER_TEXT; | ||
469 | $request = $searchterm; | ||
470 | } | ||
471 | // Otherwise, display without filtering. | ||
472 | else { | ||
473 | $type = ''; | ||
474 | $request = ''; | ||
475 | } | ||
476 | 459 | ||
477 | $linkFilter = new LinkFilter($this); | 460 | $linkFilter = new LinkFilter($this); |
478 | return $linkFilter->filter($type, $request, $casesensitive, $visibility); | 461 | return $linkFilter->filter($type, $request, $casesensitive, $visibility); |