diff --git a/src/Controller/TorrentController.php b/src/Controller/TorrentController.php index 1884749..3d4ac71 100644 --- a/src/Controller/TorrentController.php +++ b/src/Controller/TorrentController.php @@ -517,7 +517,7 @@ class TorrentController extends AbstractController } return $this->render('default/torrent/list.html.twig', [ - 'torrents' => $torrents, + 'torrents' => $torrents, 'pagination' => [ 'page' => $page, @@ -552,9 +552,13 @@ class TorrentController extends AbstractController $activityService ); + // Init request + $query = $request->get('query') ? explode(' ', urldecode($request->get('query'))) : []; + $page = $request->get('page') ? (int) $request->get('page') : 1; + // Get total torrents $total = $torrentService->findTorrentsTotal( - [], + $query, $user->getLocales(), !$user->isModerator() && $user->isSensitive() ? false : null, // hide on sensitive mode enabled or show all !$user->isModerator() ? true : null // show approved content only for regular users @@ -563,12 +567,12 @@ class TorrentController extends AbstractController // Create torrents list $torrents = []; foreach ($torrentService->findTorrents( - [], + $query, $user->getLocales(), !$user->isModerator() && $user->isSensitive() ? false : null, // hide on sensitive mode enabled or show all !$user->isModerator() ? true : null, // show approved content only for regular users $this->getParameter('app.pagination'), - 0 + ($page - 1) * $this->getParameter('app.pagination') ) as $torrent) { // Read file diff --git a/templates/default/torrent/list.html.twig b/templates/default/torrent/list.html.twig index 613b959..4d8c6ea 100644 --- a/templates/default/torrent/list.html.twig +++ b/templates/default/torrent/list.html.twig @@ -2,14 +2,25 @@ {% block title %}{% if query %}{{ query }} - {{ 'Search' | trans }} - {% endif %}{{ name }}{% endblock %} {% block main_content %}