X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=index.php;h=9025df58f03202aaad35c32c58160ebe902e30d9;hb=43ad7c8e825057747ccf02049050b323878952a7;hp=891a2ece77b08fb435764ae022da569dc88ee03f;hpb=3b67b22225c54b28c5ea8b118710ef450016fb86;p=github%2Fshaarli%2FShaarli.git diff --git a/index.php b/index.php index 891a2ece..9025df58 100644 --- a/index.php +++ b/index.php @@ -287,6 +287,7 @@ function logout() { unset($_SESSION['ip']); unset($_SESSION['username']); unset($_SESSION['privateonly']); + unset($_SESSION['untaggedonly']); } setcookie('shaarli_staySignedIn', FALSE, 0, WEB_PATH); } @@ -806,6 +807,9 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history) $tagList = array(); foreach($tags as $key => $value) { + if (in_array($key, $filteringTags)) { + continue; + } // Tag font size scaling: // default 15 and 30 logarithm bases affect scaling, // 22 and 6 are arbitrary font sizes for max and min sizes. @@ -830,12 +834,17 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history) exit; } - // -------- Tag cloud + // -------- Tag list if ($targetPage == Router::$PAGE_TAGLIST) { $visibility = ! empty($_SESSION['privateonly']) ? 'private' : 'all'; $filteringTags = isset($_GET['searchtags']) ? explode(' ', $_GET['searchtags']) : []; $tags = $LINKSDB->linksCountPerTag($filteringTags, $visibility); + foreach ($filteringTags as $tag) { + if (array_key_exists($tag, $tags)) { + unset($tags[$tag]); + } + } if (! empty($_GET['sort']) && $_GET['sort'] === 'alpha') { alphabetical_sort($tags, false, true); @@ -1010,6 +1019,19 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history) exit; } + // -------- User wants to see only untagged links (toggle) + if (isset($_GET['untaggedonly'])) { + $_SESSION['untaggedonly'] = !$_SESSION['untaggedonly']; + + if (! empty($_SERVER['HTTP_REFERER'])) { + $location = generateLocation($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'], array('untaggedonly')); + } else { + $location = '?'; + } + header('Location: '. $location); + exit; + } + // -------- Handle other actions allowed for non-logged in users: if (!isLoggedIn()) { @@ -1621,7 +1643,7 @@ function buildLinkList($PAGE,$LINKSDB, $conf, $pluginManager) 'searchtags' => $searchtags, 'searchterm' => $searchterm, ]; - $linksToDisplay = $LINKSDB->filterSearch($request, false, $visibility); + $linksToDisplay = $LINKSDB->filterSearch($request, false, $visibility, !empty($_SESSION['untaggedonly'])); } // ---- Handle paging.