From 997d9db562e04e8b64899fcb0690b147b9ccd91d Mon Sep 17 00:00:00 2001 From: ghost Date: Mon, 9 Oct 2023 15:28:02 +0300 Subject: [PATCH] add torrent contributors info #11 --- src/Controller/TorrentController.php | 34 ++++++++++++++++++++++-- templates/default/torrent/info.html.twig | 11 ++++---- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/src/Controller/TorrentController.php b/src/Controller/TorrentController.php index cd89acd..cf3c04f 100644 --- a/src/Controller/TorrentController.php +++ b/src/Controller/TorrentController.php @@ -51,13 +51,41 @@ class TorrentController extends AbstractController throw $this->createNotFoundException(); } + // Get contributors + $contributors = []; + + $contributors[$torrent->getUserId()] = $userService->identicon( + $userService->get( + $torrent->getUserId() + )->getAddress() + ); + + if ($torrentLocales = $torrentService->findLastTorrentLocalesByTorrentId($torrent->getId())) + { + $contributors[$torrentLocales->getUserId()] = $userService->identicon( + $userService->get( + $torrentLocales->getUserId() + )->getAddress() + ); + } + + if ($torrentSensitive = $torrentService->findLastTorrentSensitiveByTorrentId($torrent->getId())) + { + $contributors[$torrentSensitive->getUserId()] = $userService->identicon( + $userService->get( + $torrentSensitive->getUserId() + )->getAddress() + ); + } + // Render template return $this->render('default/torrent/info.html.twig', [ 'torrent' => [ 'id' => $torrent->getId(), 'added' => $torrent->getAdded(), - 'user' => + /* + 'user' => [ 'id' => $torrent->getUserId(), 'identicon' => $userService->identicon( @@ -66,6 +94,7 @@ class TorrentController extends AbstractController )->getAddress() ), ], + */ 'scrape' => [ 'seeders' => (int) $torrent->getSeeders(), @@ -107,7 +136,8 @@ class TorrentController extends AbstractController $torrent->getId() ) ], - 'pages' => [] + 'pages' => [], + 'contributors' => $contributors ], 'file' => [ diff --git a/templates/default/torrent/info.html.twig b/templates/default/torrent/info.html.twig index f9b4161..1ad9b3c 100644 --- a/templates/default/torrent/info.html.twig +++ b/templates/default/torrent/info.html.twig @@ -179,12 +179,14 @@ {% endif %} - {{ 'Publisher'|trans }} + {{ 'Contributors'|trans }} - - {{'identicon'|trans }} - + {% for id, identicon in torrent.contributors %} + + {{'identicon'|trans }} + + {% endfor %} @@ -236,7 +238,6 @@ {% endif %} - {% endfor %}