3 declare(strict_types
=1);
5 namespace Shaarli\Front\Controller
;
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 * @package Front\Controller
20 class PictureWallController
extends ShaarliController
22 public function index(Request
$request, Response
$response): Response
24 if ($this->container
->conf
->get('thumbnails.mode', Thumbnailer
::MODE_NONE
) === Thumbnailer
::MODE_NONE
) {
25 throw new ThumbnailsDisabledException();
30 t('Picture wall') .' - '. $this->container
->conf
->get('general.title', 'Shaarli')
33 // Optionally filter the results:
34 $links = $this->container
->bookmarkService
->search($request->getQueryParams());
37 // Get only bookmarks which have a thumbnail.
38 // Note: we do not retrieve thumbnails here, the request is too heavy.
39 $formatter = $this->container
->formatterFactory
->getFormatter('raw');
40 foreach ($links as $key => $link) {
41 if (!empty($link->getThumbnail())) {
42 $linksToDisplay[] = $formatter->format($link);
46 $data = $this->executeHooks($linksToDisplay);
47 foreach ($data as $key => $value) {
48 $this->assignView($key, $value);
51 return $response->write($this->render('picwall'));
55 * @param mixed[] $linksToDisplay List of formatted bookmarks
57 * @return mixed[] Template data after active plugins render_picwall hook execution.
59 protected function executeHooks(array $linksToDisplay): array
62 'linksToDisplay' => $linksToDisplay,
64 $this->container
->pluginManager
->executeHooks(
67 ['loggedin' => $this->container
->loginManager
->isLoggedIn()]