aboutsummaryrefslogtreecommitdiffhomepage
path: root/application
diff options
context:
space:
mode:
authorVirtualTam <virtualtam+github@flibidi.net>2017-08-03 16:27:59 +0200
committerGitHub <noreply@github.com>2017-08-03 16:27:59 +0200
commitf09e1e318e0b1c72aa659c20b715be508009175f (patch)
tree68d84f2583d5aa799128e3ec418e20eda4ba2c5f /application
parentf5568f87b1a23b36f8d3623aacfbb810d1d60dc0 (diff)
parentf210d94f716acd86fd22c9651f591a778490e8a9 (diff)
downloadShaarli-f09e1e318e0b1c72aa659c20b715be508009175f.tar.gz
Shaarli-f09e1e318e0b1c72aa659c20b715be508009175f.tar.zst
Shaarli-f09e1e318e0b1c72aa659c20b715be508009175f.zip
Merge pull request #889 from Lucas-C/master
Using only one form in linklist.html - fix #885
Diffstat (limited to 'application')
-rw-r--r--application/LinkDB.php7
-rw-r--r--application/LinkFilter.php41
-rw-r--r--application/PageBuilder.php1
3 files changed, 30 insertions, 19 deletions
diff --git a/application/LinkDB.php b/application/LinkDB.php
index 8ca0fab3..9e3efd6b 100644
--- a/application/LinkDB.php
+++ b/application/LinkDB.php
@@ -417,21 +417,22 @@ You use the community supported version of the original Shaarli project, by Seba
417 * - searchterm: term search 417 * - searchterm: term search
418 * @param bool $casesensitive Optional: Perform case sensitive filter 418 * @param bool $casesensitive Optional: Perform case sensitive filter
419 * @param string $visibility return only all/private/public links 419 * @param string $visibility return only all/private/public links
420 * @param string $untaggedonly return only untagged links
420 * 421 *
421 * @return array filtered links, all links if no suitable filter was provided. 422 * @return array filtered links, all links if no suitable filter was provided.
422 */ 423 */
423 public function filterSearch($filterRequest = array(), $casesensitive = false, $visibility = 'all') 424 public function filterSearch($filterRequest = array(), $casesensitive = false, $visibility = 'all', $untaggedonly = false)
424 { 425 {
425 // Filter link database according to parameters. 426 // Filter link database according to parameters.
426 $searchtags = isset($filterRequest['searchtags']) ? escape($filterRequest['searchtags']) : ''; 427 $searchtags = isset($filterRequest['searchtags']) ? escape($filterRequest['searchtags']) : '';
427 $searchterm = isset($filterRequest['searchterm']) ? escape($filterRequest['searchterm']) : ''; 428 $searchterm = isset($filterRequest['searchterm']) ? escape($filterRequest['searchterm']) : '';
428 429
429 // Search tags + fullsearch - blank string parameter will return all links. 430 // Search tags + fullsearch - blank string parameter will return all links.
430 $type = LinkFilter::$FILTER_TAG | LinkFilter::$FILTER_TEXT; 431 $type = LinkFilter::$FILTER_TAG | LinkFilter::$FILTER_TEXT; // == "vuotext"
431 $request = [$searchtags, $searchterm]; 432 $request = [$searchtags, $searchterm];
432 433
433 $linkFilter = new LinkFilter($this); 434 $linkFilter = new LinkFilter($this);
434 return $linkFilter->filter($type, $request, $casesensitive, $visibility); 435 return $linkFilter->filter($type, $request, $casesensitive, $visibility, $untaggedonly);
435 } 436 }
436 437
437 /** 438 /**
diff --git a/application/LinkFilter.php b/application/LinkFilter.php
index 0e887d38..95519528 100644
--- a/application/LinkFilter.php
+++ b/application/LinkFilter.php
@@ -52,10 +52,11 @@ class LinkFilter
52 * @param mixed $request Filter content. 52 * @param mixed $request Filter content.
53 * @param bool $casesensitive Optional: Perform case sensitive filter if true. 53 * @param bool $casesensitive Optional: Perform case sensitive filter if true.
54 * @param string $visibility Optional: return only all/private/public links 54 * @param string $visibility Optional: return only all/private/public links
55 * @param string $untaggedonly Optional: return only untagged links. Applies only if $type includes FILTER_TAG
55 * 56 *
56 * @return array filtered link list. 57 * @return array filtered link list.
57 */ 58 */
58 public function filter($type, $request, $casesensitive = false, $visibility = 'all') 59 public function filter($type, $request, $casesensitive = false, $visibility = 'all', $untaggedonly = false)
59 { 60 {
60 if (! in_array($visibility, ['all', 'public', 'private'])) { 61 if (! in_array($visibility, ['all', 'public', 'private'])) {
61 $visibility = 'all'; 62 $visibility = 'all';
@@ -64,23 +65,34 @@ class LinkFilter
64 switch($type) { 65 switch($type) {
65 case self::$FILTER_HASH: 66 case self::$FILTER_HASH:
66 return $this->filterSmallHash($request); 67 return $this->filterSmallHash($request);
67 case self::$FILTER_TAG | self::$FILTER_TEXT: 68 case self::$FILTER_TAG | self::$FILTER_TEXT: // == "vuotext"
68 if (!empty($request)) { 69 $noRequest = empty($request) || (empty($request[0]) && empty($request[1]));
69 $filtered = $this->links; 70 if ($noRequest) {
70 if (isset($request[0])) { 71 if ($untaggedonly) {
71 $filtered = $this->filterTags($request[0], $casesensitive, $visibility); 72 return $this->filterUntagged($visibility);
72 }
73 if (isset($request[1])) {
74 $lf = new LinkFilter($filtered);
75 $filtered = $lf->filterFulltext($request[1], $visibility);
76 } 73 }
77 return $filtered; 74 return $this->noFilter($visibility);
78 } 75 }
79 return $this->noFilter($visibility); 76 if ($untaggedonly) {
77 $filtered = $this->filterUntagged($visibility);
78 } else {
79 $filtered = $this->links;
80 }
81 if (!empty($request[0])) {
82 $filtered = (new LinkFilter($filtered))->filterTags($request[0], $casesensitive, $visibility);
83 }
84 if (!empty($request[1])) {
85 $filtered = (new LinkFilter($filtered))->filterFulltext($request[1], $visibility);
86 }
87 return $filtered;
80 case self::$FILTER_TEXT: 88 case self::$FILTER_TEXT:
81 return $this->filterFulltext($request, $visibility); 89 return $this->filterFulltext($request, $visibility);
82 case self::$FILTER_TAG: 90 case self::$FILTER_TAG:
83 return $this->filterTags($request, $casesensitive, $visibility); 91 if ($untaggedonly) {
92 return $this->filterUntagged($visibility);
93 } else {
94 return $this->filterTags($request, $casesensitive, $visibility);
95 }
84 case self::$FILTER_DAY: 96 case self::$FILTER_DAY:
85 return $this->filterDay($request); 97 return $this->filterDay($request);
86 default: 98 default:
@@ -253,9 +265,6 @@ class LinkFilter
253 { 265 {
254 // Implode if array for clean up. 266 // Implode if array for clean up.
255 $tags = is_array($tags) ? trim(implode(' ', $tags)) : $tags; 267 $tags = is_array($tags) ? trim(implode(' ', $tags)) : $tags;
256 if ($tags === false) {
257 return $this->filterUntagged($visibility);
258 }
259 if (empty($tags)) { 268 if (empty($tags)) {
260 return $this->noFilter($visibility); 269 return $this->noFilter($visibility);
261 } 270 }
diff --git a/application/PageBuilder.php b/application/PageBuilder.php
index c86621a2..7a42400d 100644
--- a/application/PageBuilder.php
+++ b/application/PageBuilder.php
@@ -78,6 +78,7 @@ class PageBuilder
78 $this->tpl->assign('version', shaarli_version); 78 $this->tpl->assign('version', shaarli_version);
79 $this->tpl->assign('scripturl', index_url($_SERVER)); 79 $this->tpl->assign('scripturl', index_url($_SERVER));
80 $this->tpl->assign('privateonly', !empty($_SESSION['privateonly'])); // Show only private links? 80 $this->tpl->assign('privateonly', !empty($_SESSION['privateonly'])); // Show only private links?
81 $this->tpl->assign('untaggedonly', !empty($_SESSION['untaggedonly']));
81 $this->tpl->assign('pagetitle', $this->conf->get('general.title', 'Shaarli')); 82 $this->tpl->assign('pagetitle', $this->conf->get('general.title', 'Shaarli'));
82 if ($this->conf->exists('general.header_link')) { 83 if ($this->conf->exists('general.header_link')) {
83 $this->tpl->assign('titleLink', $this->conf->get('general.header_link')); 84 $this->tpl->assign('titleLink', $this->conf->get('general.header_link'));