X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=application%2FLinkFilter.php;h=0e887d3805a2fa7ef2024f5da2d6b155dc4a870e;hb=7d86f40bdb2135655b5b4fe8cbcc1ac102114f86;hp=81832a4b428f4bc650d3049b8e0ced2a850c1cdc;hpb=b64d83cd2b60b6851741787f8ce2ae2c93092841;p=github%2Fshaarli%2FShaarli.git diff --git a/application/LinkFilter.php b/application/LinkFilter.php index 81832a4b..0e887d38 100644 --- a/application/LinkFilter.php +++ b/application/LinkFilter.php @@ -253,6 +253,9 @@ class LinkFilter { // Implode if array for clean up. $tags = is_array($tags) ? trim(implode(' ', $tags)) : $tags; + if ($tags === false) { + return $this->filterUntagged($visibility); + } if (empty($tags)) { return $this->noFilter($visibility); } @@ -295,6 +298,33 @@ class LinkFilter return $filtered; } + /** + * Return only links without any tag. + * + * @param string $visibility return only all/private/public links. + * + * @return array filtered links. + */ + public function filterUntagged($visibility) + { + $filtered = []; + foreach ($this->links as $key => $link) { + if ($visibility !== 'all') { + if (! $link['private'] && $visibility === 'private') { + continue; + } else if ($link['private'] && $visibility === 'public') { + continue; + } + } + + if (empty(trim($link['tags']))) { + $filtered[$key] = $link; + } + } + + return $filtered; + } + /** * Returns the list of articles for a given day, chronologically sorted *