aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2017-04-01 12:17:37 +0200
committerArthurHoaro <arthur@hoa.ro>2017-05-25 15:51:12 +0200
commit7d86f40bdb2135655b5b4fe8cbcc1ac102114f86 (patch)
treec70ac4ad89a4fc84b8e52114aca7d9755cc92086 /index.php
parentb64d83cd2b60b6851741787f8ce2ae2c93092841 (diff)
downloadShaarli-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 'index.php')
-rw-r--r--index.php18
1 files changed, 15 insertions, 3 deletions
diff --git a/index.php b/index.php
index 5c21c2f6..c96d0136 100644
--- a/index.php
+++ b/index.php
@@ -1609,7 +1609,15 @@ function renderPage($conf, $pluginManager, $LINKSDB)
1609function buildLinkList($PAGE,$LINKSDB, $conf, $pluginManager) 1609function buildLinkList($PAGE,$LINKSDB, $conf, $pluginManager)
1610{ 1610{
1611 // Used in templates 1611 // Used in templates
1612 $searchtags = !empty($_GET['searchtags']) ? escape(normalize_spaces($_GET['searchtags'])) : ''; 1612 if (isset($_GET['searchtags'])) {
1613 if (! empty($_GET['searchtags'])) {
1614 $searchtags = escape(normalize_spaces($_GET['searchtags']));
1615 } else {
1616 $searchtags = false;
1617 }
1618 } else {
1619 $searchtags = '';
1620 }
1613 $searchterm = !empty($_GET['searchterm']) ? escape(normalize_spaces($_GET['searchterm'])) : ''; 1621 $searchterm = !empty($_GET['searchterm']) ? escape(normalize_spaces($_GET['searchterm'])) : '';
1614 1622
1615 // Smallhash filter 1623 // Smallhash filter
@@ -1624,7 +1632,11 @@ function buildLinkList($PAGE,$LINKSDB, $conf, $pluginManager)
1624 } else { 1632 } else {
1625 // Filter links according search parameters. 1633 // Filter links according search parameters.
1626 $visibility = ! empty($_SESSION['privateonly']) ? 'private' : 'all'; 1634 $visibility = ! empty($_SESSION['privateonly']) ? 'private' : 'all';
1627 $linksToDisplay = $LINKSDB->filterSearch($_GET, false, $visibility); 1635 $request = [
1636 'searchtags' => $searchtags,
1637 'searchterm' => $searchterm,
1638 ];
1639 $linksToDisplay = $LINKSDB->filterSearch($request, false, $visibility);
1628 } 1640 }
1629 1641
1630 // ---- Handle paging. 1642 // ---- Handle paging.
@@ -1671,7 +1683,7 @@ function buildLinkList($PAGE,$LINKSDB, $conf, $pluginManager)
1671 } 1683 }
1672 1684
1673 // Compute paging navigation 1685 // Compute paging navigation
1674 $searchtagsUrl = empty($searchtags) ? '' : '&searchtags=' . urlencode($searchtags); 1686 $searchtagsUrl = $searchtags === '' ? '' : '&searchtags=' . urlencode($searchtags);
1675 $searchtermUrl = empty($searchterm) ? '' : '&searchterm=' . urlencode($searchterm); 1687 $searchtermUrl = empty($searchterm) ? '' : '&searchterm=' . urlencode($searchterm);
1676 $previous_page_url = ''; 1688 $previous_page_url = '';
1677 if ($i != count($keys)) { 1689 if ($i != count($keys)) {