aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/front
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-07-24 12:48:53 +0200
committerArthurHoaro <arthur@hoa.ro>2020-07-24 12:48:53 +0200
commit204035bd3c91b9a5c39fcb6fc470e108b032dbd9 (patch)
treeb3b3c01bd162da4d0672a7fd3b598d8c4580c980 /application/front
parent87ae3c4f08431e02869376cb57add257747910d1 (diff)
downloadShaarli-204035bd3c91b9a5c39fcb6fc470e108b032dbd9.tar.gz
Shaarli-204035bd3c91b9a5c39fcb6fc470e108b032dbd9.tar.zst
Shaarli-204035bd3c91b9a5c39fcb6fc470e108b032dbd9.zip
Fix: visitor are allowed to chose nb of links per page
Diffstat (limited to 'application/front')
-rw-r--r--application/front/controller/admin/SessionFilterController.php20
-rw-r--r--application/front/controller/visitor/PublicSessionFilterController.php33
2 files changed, 34 insertions, 19 deletions
diff --git a/application/front/controller/admin/SessionFilterController.php b/application/front/controller/admin/SessionFilterController.php
index 69a16ec3..081c0ba0 100644
--- a/application/front/controller/admin/SessionFilterController.php
+++ b/application/front/controller/admin/SessionFilterController.php
@@ -12,29 +12,11 @@ use Slim\Http\Response;
12/** 12/**
13 * Class SessionFilterController 13 * Class SessionFilterController
14 * 14 *
15 * Slim controller used to handle filters stored in the user session, such as visibility, links per page, etc. 15 * Slim controller used to handle filters stored in the user session, such as visibility, etc.
16 */ 16 */
17class SessionFilterController extends ShaarliAdminController 17class SessionFilterController extends ShaarliAdminController
18{ 18{
19 /** 19 /**
20 * GET /links-per-page: set the number of bookmarks to display per page in homepage
21 */
22 public function linksPerPage(Request $request, Response $response): Response
23 {
24 $linksPerPage = $request->getParam('nb') ?? null;
25 if (null === $linksPerPage || false === is_numeric($linksPerPage)) {
26 $linksPerPage = $this->container->conf->get('general.links_per_page', 20);
27 }
28
29 $this->container->sessionManager->setSessionParameter(
30 SessionManager::KEY_LINKS_PER_PAGE,
31 abs(intval($linksPerPage))
32 );
33
34 return $this->redirectFromReferer($request, $response, ['linksperpage'], ['nb']);
35 }
36
37 /**
38 * GET /visibility: allows to display only public or only private bookmarks in linklist 20 * GET /visibility: allows to display only public or only private bookmarks in linklist
39 */ 21 */
40 public function visibility(Request $request, Response $response, array $args): Response 22 public function visibility(Request $request, Response $response, array $args): Response
diff --git a/application/front/controller/visitor/PublicSessionFilterController.php b/application/front/controller/visitor/PublicSessionFilterController.php
new file mode 100644
index 00000000..35da0c5f
--- /dev/null
+++ b/application/front/controller/visitor/PublicSessionFilterController.php
@@ -0,0 +1,33 @@
1<?php
2
3declare(strict_types=1);
4
5namespace Shaarli\Front\Controller\Visitor;
6
7use Shaarli\Security\SessionManager;
8use Slim\Http\Request;
9use Slim\Http\Response;
10
11/**
12 * Slim controller used to handle filters stored in the visitor session, links per page, etc.
13 */
14class PublicSessionFilterController extends ShaarliVisitorController
15{
16 /**
17 * GET /links-per-page: set the number of bookmarks to display per page in homepage
18 */
19 public function linksPerPage(Request $request, Response $response): Response
20 {
21 $linksPerPage = $request->getParam('nb') ?? null;
22 if (null === $linksPerPage || false === is_numeric($linksPerPage)) {
23 $linksPerPage = $this->container->conf->get('general.links_per_page', 20);
24 }
25
26 $this->container->sessionManager->setSessionParameter(
27 SessionManager::KEY_LINKS_PER_PAGE,
28 abs(intval($linksPerPage))
29 );
30
31 return $this->redirectFromReferer($request, $response, ['linksperpage'], ['nb']);
32 }
33}