3 declare(strict_types
=1);
5 namespace Shaarli\Front\Controller\Visitor
;
7 use Shaarli\Front\Exception\ThumbnailsDisabledException
;
8 use Shaarli\Thumbnailer
;
10 use Slim\Http\Response
;
13 * Class PicturesWallController
15 * Slim controller used to render the pictures wall page.
16 * If thumbnails mode is set to NONE, we just render the template without any image.
18 class PictureWallController
extends ShaarliVisitorController
20 public function index(Request
$request, Response
$response): Response
22 if ($this->container
->conf
->get('thumbnails.mode', Thumbnailer
::MODE_NONE
) === Thumbnailer
::MODE_NONE
) {
23 throw new ThumbnailsDisabledException();
28 t('Picture wall') .' - '. $this->container
->conf
->get('general.title', 'Shaarli')
31 // Optionally filter the results:
32 $links = $this->container
->bookmarkService
->search($request->getQueryParams());
35 // Get only bookmarks which have a thumbnail.
36 // Note: we do not retrieve thumbnails here, the request is too heavy.
37 $formatter = $this->container
->formatterFactory
->getFormatter('raw');
38 foreach ($links as $key => $link) {
39 if (!empty($link->getThumbnail())) {
40 $linksToDisplay[] = $formatter->format($link);
44 $data = $this->executeHooks($linksToDisplay);
45 foreach ($data as $key => $value) {
46 $this->assignView($key, $value);
49 return $response->write($this->render('picwall'));
53 * @param mixed[] $linksToDisplay List of formatted bookmarks
55 * @return mixed[] Template data after active plugins render_picwall hook execution.
57 protected function executeHooks(array $linksToDisplay): array
60 'linksToDisplay' => $linksToDisplay,
62 $this->container
->pluginManager
->executeHooks(
65 ['loggedin' => $this->container
->loginManager
->isLoggedIn()]