]>
Commit | Line | Data |
---|---|---|
204035bd A |
1 | <?php |
2 | ||
3 | declare(strict_types=1); | |
4 | ||
5 | namespace Shaarli\Front\Controller\Visitor; | |
6 | ||
7 | use Shaarli\Security\SessionManager; | |
8 | use Slim\Http\Request; | |
9 | use Slim\Http\Response; | |
10 | ||
11 | /** | |
12 | * Slim controller used to handle filters stored in the visitor session, links per page, etc. | |
13 | */ | |
14 | class 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 | } | |
bedbb845 A |
33 | |
34 | /** | |
35 | * GET /untagged-only: allows to display only bookmarks without any tag | |
36 | */ | |
37 | public function untaggedOnly(Request $request, Response $response): Response | |
38 | { | |
39 | $this->container->sessionManager->setSessionParameter( | |
40 | SessionManager::KEY_UNTAGGED_ONLY, | |
41 | empty($this->container->sessionManager->getSessionParameter(SessionManager::KEY_UNTAGGED_ONLY)) | |
42 | ); | |
43 | ||
44 | return $this->redirectFromReferer($request, $response, ['untaggedonly', 'untagged-only']); | |
45 | } | |
204035bd | 46 | } |