aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/LinkFilter.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2017-05-25 15:54:20 +0200
committerGitHub <noreply@github.com>2017-05-25 15:54:20 +0200
commit3e395a6bc63cba16b0772a382f6cbac0ce4ab906 (patch)
tree220eaf3400aeeea821b7e150855a1d44f1b5bfe9 /application/LinkFilter.php
parentb2e2aa42e288e0becaa95bf9cc3be679743fc98e (diff)
parent7d86f40bdb2135655b5b4fe8cbcc1ac102114f86 (diff)
downloadShaarli-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/LinkFilter.php')
-rw-r--r--application/LinkFilter.php30
1 files changed, 30 insertions, 0 deletions
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
253 { 253 {
254 // Implode if array for clean up. 254 // Implode if array for clean up.
255 $tags = is_array($tags) ? trim(implode(' ', $tags)) : $tags; 255 $tags = is_array($tags) ? trim(implode(' ', $tags)) : $tags;
256 if ($tags === false) {
257 return $this->filterUntagged($visibility);
258 }
256 if (empty($tags)) { 259 if (empty($tags)) {
257 return $this->noFilter($visibility); 260 return $this->noFilter($visibility);
258 } 261 }
@@ -296,6 +299,33 @@ class LinkFilter
296 } 299 }
297 300
298 /** 301 /**
302 * Return only links without any tag.
303 *
304 * @param string $visibility return only all/private/public links.
305 *
306 * @return array filtered links.
307 */
308 public function filterUntagged($visibility)
309 {
310 $filtered = [];
311 foreach ($this->links as $key => $link) {
312 if ($visibility !== 'all') {
313 if (! $link['private'] && $visibility === 'private') {
314 continue;
315 } else if ($link['private'] && $visibility === 'public') {
316 continue;
317 }
318 }
319
320 if (empty(trim($link['tags']))) {
321 $filtered[$key] = $link;
322 }
323 }
324
325 return $filtered;
326 }
327
328 /**
299 * Returns the list of articles for a given day, chronologically sorted 329 * Returns the list of articles for a given day, chronologically sorted
300 * 330 *
301 * Day must be in the form 'YYYYMMDD' (e.g. '20120125'), e.g. 331 * Day must be in the form 'YYYYMMDD' (e.g. '20120125'), e.g.