diff --git a/migrations/Version20231030225418.php b/migrations/Version20231030225418.php new file mode 100644 index 0000000..e43e71d --- /dev/null +++ b/migrations/Version20231030225418.php @@ -0,0 +1,31 @@ +addSql('ALTER TABLE torrent_poster ADD COLUMN position BOOLEAN NOT NULL DEFAULT "center"'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE torrent_poster DROP COLUMN position'); + } +} diff --git a/public/asset/default/css/framework.css b/public/asset/default/css/framework.css index 1c31c9c..0ca71e6 100644 --- a/public/asset/default/css/framework.css +++ b/public/asset/default/css/framework.css @@ -510,10 +510,6 @@ a:visited.background-color-hover-night-light:hover { /* responsive rules */ -.height-148-px { - height: 148px; -} - .width-100 { width: 100%; } diff --git a/src/Controller/TorrentController.php b/src/Controller/TorrentController.php index d4bb509..7511ff8 100644 --- a/src/Controller/TorrentController.php +++ b/src/Controller/TorrentController.php @@ -109,12 +109,19 @@ class TorrentController extends AbstractController // Poster if ($user->isPosters() && $torrent->getTorrentPosterId()) { - $poster = $request->getScheme() . '://' . - $request->getHttpHost() . - $request->getBasePath() . - $torrentService->getImageUriByTorrentPosterId( - $torrent->getTorrentPosterId() - ); + $torrentPoster = $torrentService->getTorrentPoster( + $torrent->getTorrentPosterId() + ); + + $poster = [ + 'position' => $torrentPoster->getPosition(), + 'url' => $request->getScheme() . '://' . + $request->getHttpHost() . + $request->getBasePath() . + $torrentService->getImageUriByTorrentPosterId( + $torrentPoster->getId() + ) + ]; } else @@ -304,12 +311,19 @@ class TorrentController extends AbstractController // Poster if ($user->isPosters() && $torrent->getTorrentPosterId()) { - $poster = $request->getScheme() . '://' . - $request->getHttpHost() . - $request->getBasePath() . - $torrentService->getImageUriByTorrentPosterId( - $torrent->getTorrentPosterId() - ); + $torrentPoster = $torrentService->getTorrentPoster( + $torrent->getTorrentPosterId() + ); + + $poster = [ + 'position' => $torrentPoster->getPosition(), + 'url' => $request->getScheme() . '://' . + $request->getHttpHost() . + $request->getBasePath() . + $torrentService->getImageUriByTorrentPosterId( + $torrentPoster->getId() + ) + ]; } else @@ -484,12 +498,19 @@ class TorrentController extends AbstractController // Poster if ($user->isPosters() && $torrent->getTorrentPosterId()) { - $poster = $request->getScheme() . '://' . - $request->getHttpHost() . - $request->getBasePath() . - $torrentService->getImageUriByTorrentPosterId( - $torrent->getTorrentPosterId() - ); + $torrentPoster = $torrentService->getTorrentPoster( + $torrent->getTorrentPosterId() + ); + + $poster = [ + 'position' => $torrentPoster->getPosition(), + 'url' => $request->getScheme() . '://' . + $request->getHttpHost() . + $request->getBasePath() . + $torrentService->getImageUriByTorrentPosterId( + $torrentPoster->getId() + ) + ]; } else @@ -1905,6 +1926,16 @@ class TorrentController extends AbstractController } } + // Init position + $position = in_array( + $request->get('position'), + [ + 'center', + 'top', + 'bottom' + ] + ) ? $request->get('position') : 'center'; + // Init edition history $editions = []; foreach ($torrentService->findTorrentPosterByTorrentId($torrent->getId()) as $torrentPosterEdition) @@ -1913,6 +1944,7 @@ class TorrentController extends AbstractController [ 'id' => $torrentPosterEdition->getId(), 'added' => $torrentPosterEdition->getAdded(), + 'position' => $torrentPosterEdition->getPosition(), 'approved' => $torrentPosterEdition->isApproved(), 'active' => $torrentPosterEdition->getId() == $torrentPosterCurrent['id'], 'user' => @@ -1940,13 +1972,28 @@ class TorrentController extends AbstractController 'poster' => [ 'error' => [] + ], + 'position' => + [ + 'error' => [], + 'attribute' => + [ + 'value' => $position + ] ] ]; // Process request if ($request->isMethod('post')) { - if ($file = $request->files->get('poster')) + if ($request->get('id') && $torrentService->getTorrentPoster($request->get('id'))) + { + $filename = $torrentService->getStorageFilepathByTorrentPosterId( + $request->get('id') + ); + } + + else if ($file = $request->files->get('poster')) { //// Validate poster file if (filesize($file->getPathName()) > $this->getParameter('app.torrent.poster.size.max')) @@ -1959,11 +2006,15 @@ class TorrentController extends AbstractController { $form['poster']['error'][] = $translator->trans('Image file not supported'); } + + $filename = $file->getPathName(); } else { $form['poster']['error'][] = $translator->trans('Poster file required'); + + $filename = false; } // Request is valid @@ -1971,7 +2022,8 @@ class TorrentController extends AbstractController { // Save data $torrentPoster = $torrentService->addTorrentPoster( - $file->getPathName(), + $filename, + $position, $torrent->getId(), $user->getId(), time(), diff --git a/src/Entity/TorrentPoster.php b/src/Entity/TorrentPoster.php index 495fae3..b25c481 100644 --- a/src/Entity/TorrentPoster.php +++ b/src/Entity/TorrentPoster.php @@ -28,6 +28,9 @@ class TorrentPoster #[ORM\Column(length: 32)] private ?string $md5file = null; + #[ORM\Column(length: 255)] + private ?string $position = null; + public function getId(): ?int { return $this->id; @@ -99,4 +102,16 @@ class TorrentPoster return $this; } + + public function getPosition(): ?string + { + return $this->position; + } + + public function setPosition(string $position): static + { + $this->position = $position; + + return $this; + } } diff --git a/src/Service/TorrentService.php b/src/Service/TorrentService.php index 1e52555..0a5b3bf 100644 --- a/src/Service/TorrentService.php +++ b/src/Service/TorrentService.php @@ -1126,6 +1126,7 @@ class TorrentService public function addTorrentPoster( string $filename, + string $position, int $torrentId, int $userId, int $added, @@ -1139,6 +1140,7 @@ class TorrentService $torrentPoster->setUserId($userId); $torrentPoster->setAdded($added); $torrentPoster->setApproved($approved); + $torrentPoster->setPosition($position); $torrentPoster->setMd5file( md5_file($filename) ); diff --git a/templates/default/torrent/edit/poster.html.twig b/templates/default/torrent/edit/poster.html.twig index a987a22..e4ed5e9 100644 --- a/templates/default/torrent/edit/poster.html.twig +++ b/templates/default/torrent/edit/poster.html.twig @@ -17,18 +17,32 @@ {% endfor %} +
+ + + + + + +
- {{'cancel' | trans }} + {{ 'cancel' | trans }}
{% for edition in editions %} -
+
{% if edition.active %} {{ edition.added | format_ago }} {% else %} @@ -79,6 +93,29 @@ {% endif %} {% endif %}
+ {% if edition.active %} +
+ +
+ + + + + + +
+
+
+ +
+
+ {% endif %}
{% endfor %} {% endblock %} diff --git a/templates/default/torrent/info.html.twig b/templates/default/torrent/info.html.twig index 1004759..3488f23 100644 --- a/templates/default/torrent/info.html.twig +++ b/templates/default/torrent/info.html.twig @@ -30,7 +30,7 @@ {% endblock %} {% block main_content %}
+ {% if torrent.poster %}style="background-image:url('{{ torrent.poster.url }}');background-position:{{ torrent.poster.position }}"{% endif %}>

{{ file.name }} {#{{ 'Torrent' | trans }} #{{ torrent.id }}#} diff --git a/templates/default/torrent/list.html.twig b/templates/default/torrent/list.html.twig index 404f3eb..a84e6a8 100644 --- a/templates/default/torrent/list.html.twig +++ b/templates/default/torrent/list.html.twig @@ -25,7 +25,7 @@ {% if torrents %} {% for torrent in torrents %}
+ {% if torrent.poster %}style="background-image:url('{{ torrent.poster.url }}');background-position:{{ torrent.poster.position }}"{% endif %}>

diff --git a/translations/messages+intl-icu.cs.xlf b/translations/messages+intl-icu.cs.xlf index 0e6b880..49c610a 100644 --- a/translations/messages+intl-icu.cs.xlf +++ b/translations/messages+intl-icu.cs.xlf @@ -785,6 +785,18 @@ Torrent posters Torrent posters + + Center + Center + + + Top + Top + + + Bottom + Bottom + diff --git a/translations/messages+intl-icu.de.xlf b/translations/messages+intl-icu.de.xlf index e054970..1baf706 100644 --- a/translations/messages+intl-icu.de.xlf +++ b/translations/messages+intl-icu.de.xlf @@ -785,6 +785,18 @@ Torrent posters Torrent posters + + Center + Center + + + Top + Top + + + Bottom + Bottom + diff --git a/translations/messages+intl-icu.en.xlf b/translations/messages+intl-icu.en.xlf index 40887c2..345cd14 100644 --- a/translations/messages+intl-icu.en.xlf +++ b/translations/messages+intl-icu.en.xlf @@ -785,6 +785,18 @@ Torrent posters Torrent posters + + Center + Center + + + Top + Top + + + Bottom + Bottom + diff --git a/translations/messages+intl-icu.eo.xlf b/translations/messages+intl-icu.eo.xlf index 5588b10..73c15c1 100644 --- a/translations/messages+intl-icu.eo.xlf +++ b/translations/messages+intl-icu.eo.xlf @@ -785,6 +785,18 @@ Torrent posters Torrent posters + + Center + Center + + + Top + Top + + + Bottom + Bottom + diff --git a/translations/messages+intl-icu.es.xlf b/translations/messages+intl-icu.es.xlf index a671f50..d759331 100644 --- a/translations/messages+intl-icu.es.xlf +++ b/translations/messages+intl-icu.es.xlf @@ -785,6 +785,18 @@ Torrent posters Torrent posters + + Center + Center + + + Top + Top + + + Bottom + Bottom + diff --git a/translations/messages+intl-icu.fr.xlf b/translations/messages+intl-icu.fr.xlf index 15523b2..f2a251f 100644 --- a/translations/messages+intl-icu.fr.xlf +++ b/translations/messages+intl-icu.fr.xlf @@ -785,6 +785,18 @@ Torrent posters Torrent posters + + Center + Center + + + Top + Top + + + Bottom + Bottom + diff --git a/translations/messages+intl-icu.he.xlf b/translations/messages+intl-icu.he.xlf index 94c676e..39a42e3 100644 --- a/translations/messages+intl-icu.he.xlf +++ b/translations/messages+intl-icu.he.xlf @@ -785,6 +785,18 @@ Torrent posters Torrent posters + + Center + Center + + + Top + Top + + + Bottom + Bottom + diff --git a/translations/messages+intl-icu.it.xlf b/translations/messages+intl-icu.it.xlf index 3bdedf9..6c16e22 100644 --- a/translations/messages+intl-icu.it.xlf +++ b/translations/messages+intl-icu.it.xlf @@ -785,6 +785,18 @@ Torrent posters Torrent posters + + Center + Center + + + Top + Top + + + Bottom + Bottom + diff --git a/translations/messages+intl-icu.ka.xlf b/translations/messages+intl-icu.ka.xlf index fae2e18..8c5f53e 100644 --- a/translations/messages+intl-icu.ka.xlf +++ b/translations/messages+intl-icu.ka.xlf @@ -785,6 +785,18 @@ Torrent posters Torrent posters + + Center + Center + + + Top + Top + + + Bottom + Bottom + diff --git a/translations/messages+intl-icu.lv.xlf b/translations/messages+intl-icu.lv.xlf index 258d87a..1bfc3af 100644 --- a/translations/messages+intl-icu.lv.xlf +++ b/translations/messages+intl-icu.lv.xlf @@ -785,6 +785,18 @@ Torrent posters Torrent posters + + Center + Center + + + Top + Top + + + Bottom + Bottom + diff --git a/translations/messages+intl-icu.nl.xlf b/translations/messages+intl-icu.nl.xlf index 61fc25e..7eb6e86 100644 --- a/translations/messages+intl-icu.nl.xlf +++ b/translations/messages+intl-icu.nl.xlf @@ -785,6 +785,18 @@ Torrent posters Torrent posters + + Center + Center + + + Top + Top + + + Bottom + Bottom + diff --git a/translations/messages+intl-icu.pl.xlf b/translations/messages+intl-icu.pl.xlf index 62c2af8..fc015e5 100644 --- a/translations/messages+intl-icu.pl.xlf +++ b/translations/messages+intl-icu.pl.xlf @@ -785,6 +785,18 @@ Torrent posters Torrent posters + + Center + Center + + + Top + Top + + + Bottom + Bottom + diff --git a/translations/messages+intl-icu.pt.xlf b/translations/messages+intl-icu.pt.xlf index aff889c..356f38d 100644 --- a/translations/messages+intl-icu.pt.xlf +++ b/translations/messages+intl-icu.pt.xlf @@ -785,6 +785,18 @@ Torrent posters Torrent posters + + Center + Center + + + Top + Top + + + Bottom + Bottom + diff --git a/translations/messages+intl-icu.ru.xlf b/translations/messages+intl-icu.ru.xlf index 7024d07..6861445 100644 --- a/translations/messages+intl-icu.ru.xlf +++ b/translations/messages+intl-icu.ru.xlf @@ -785,6 +785,18 @@ Torrent posters Постеры торрентов + + Center + Центр + + + Top + Верх + + + Bottom + Низ + diff --git a/translations/messages+intl-icu.uk.xlf b/translations/messages+intl-icu.uk.xlf index dc81dee..59dc5d8 100644 --- a/translations/messages+intl-icu.uk.xlf +++ b/translations/messages+intl-icu.uk.xlf @@ -785,6 +785,18 @@ Torrent posters Постери торентів + + Center + Центр + + + Top + Верх + + + Bottom + Низ +