aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/PageBuilder.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2017-12-16 12:36:59 +0100
committerArthurHoaro <arthur@hoa.ro>2017-12-16 14:32:56 +0100
commit9d4736a3e95332198896f97ecc8a83abb0cbe85b (patch)
treefc2487dbefd09953f21f8d10850c7689c87af224 /application/PageBuilder.php
parent877491b4ad0a6a9119e667901cef40cc56116901 (diff)
downloadShaarli-9d4736a3e95332198896f97ecc8a83abb0cbe85b.tar.gz
Shaarli-9d4736a3e95332198896f97ecc8a83abb0cbe85b.tar.zst
Shaarli-9d4736a3e95332198896f97ecc8a83abb0cbe85b.zip
Add a filter to only display public links
When the key filter is clicked once, it only displays private link. When it is clicked on again, it becomes red and only public links are displayed. Another click and all links are displayed. The current visibility status is shown in the search banner Fixes #1030
Diffstat (limited to 'application/PageBuilder.php')
-rw-r--r--application/PageBuilder.php24
1 files changed, 23 insertions, 1 deletions
diff --git a/application/PageBuilder.php b/application/PageBuilder.php
index 468f144b..0902d00d 100644
--- a/application/PageBuilder.php
+++ b/application/PageBuilder.php
@@ -83,7 +83,9 @@ class PageBuilder
83 ApplicationUtils::getVersionHash(SHAARLI_VERSION, $this->conf->get('credentials.salt')) 83 ApplicationUtils::getVersionHash(SHAARLI_VERSION, $this->conf->get('credentials.salt'))
84 ); 84 );
85 $this->tpl->assign('scripturl', index_url($_SERVER)); 85 $this->tpl->assign('scripturl', index_url($_SERVER));
86 $this->tpl->assign('privateonly', !empty($_SESSION['privateonly'])); // Show only private links? 86 $visibility = ! empty($_SESSION['visibility']) ? $_SESSION['visibility'] : '';
87 $this->tpl->assign('visibility', $visibility);
88 $this->tpl->assign('nextVisibility', $this->getNextVisibility($visibility));
87 $this->tpl->assign('untaggedonly', !empty($_SESSION['untaggedonly'])); 89 $this->tpl->assign('untaggedonly', !empty($_SESSION['untaggedonly']));
88 $this->tpl->assign('pagetitle', $this->conf->get('general.title', 'Shaarli')); 90 $this->tpl->assign('pagetitle', $this->conf->get('general.title', 'Shaarli'));
89 if ($this->conf->exists('general.header_link')) { 91 if ($this->conf->exists('general.header_link')) {
@@ -170,4 +172,24 @@ class PageBuilder
170 $this->tpl->assign('error_message', $message); 172 $this->tpl->assign('error_message', $message);
171 $this->renderPage('404'); 173 $this->renderPage('404');
172 } 174 }
175
176 /**
177 * Return the next visibility option:
178 * private -> public -> all
179 *
180 * @param string $current visibility value
181 *
182 * @return string next visibility value
183 */
184 protected function getNextVisibility($current)
185 {
186 switch ($current) {
187 case 'private':
188 return 'public';
189 case 'public':
190 return '';
191 default:
192 return 'private';
193 }
194 }
173} 195}