From 3a14f29b38b48192ac364fe5ec87c845fd33b63a Mon Sep 17 00:00:00 2001
From: ghost
Date: Wed, 18 Oct 2023 22:25:49 +0300
Subject: [PATCH] add search results RSS feed support
---
src/Controller/TorrentController.php | 12 +++++++----
templates/default/torrent/list.html.twig | 27 +++++++++++++++++-------
translations/messages+intl-icu.cs.xlf | 4 ++++
translations/messages+intl-icu.de.xlf | 4 ++++
translations/messages+intl-icu.en.xlf | 4 ++++
translations/messages+intl-icu.eo.xlf | 4 ++++
translations/messages+intl-icu.es.xlf | 4 ++++
translations/messages+intl-icu.fr.xlf | 4 ++++
translations/messages+intl-icu.he.xlf | 4 ++++
translations/messages+intl-icu.it.xlf | 4 ++++
translations/messages+intl-icu.ka.xlf | 4 ++++
translations/messages+intl-icu.lv.xlf | 4 ++++
translations/messages+intl-icu.pl.xlf | 4 ++++
translations/messages+intl-icu.pt.xlf | 4 ++++
translations/messages+intl-icu.ru.xlf | 4 ++++
translations/messages+intl-icu.uk.xlf | 6 +++++-
16 files changed, 84 insertions(+), 13 deletions(-)
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 %}
-
{{ 'Recent uploads' | trans }}
-
-
-
-
-
+ {% if query %}
+
{{ 'Search results' | trans }}
+
+
+
+
+
+ {% else %}
+
{{ 'Recent uploads' | trans }}
+
+
+
+
+
+ {% endif %}
{% if torrents %}
{% for torrent in torrents %}
diff --git a/translations/messages+intl-icu.cs.xlf b/translations/messages+intl-icu.cs.xlf
index e31d182..33c94c0 100644
--- a/translations/messages+intl-icu.cs.xlf
+++ b/translations/messages+intl-icu.cs.xlf
@@ -717,6 +717,10 @@
seconds ago
+
+
+ Search results
+
- Файл не знайдений
+ Файл не знайдено
@@ -717,6 +717,10 @@
секунд тому
+
+
+ Результати пошуку
+