mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2025-02-05 11:34:38 +00:00
init torrent categories feature #26
This commit is contained in:
parent
35babed517
commit
701b448cd6
3
.env
3
.env
@ -59,6 +59,9 @@ APP_LOCALE=en
|
||||
# Supported locales for interface and content filters
|
||||
APP_LOCALES=en|cs|nl|eo|fr|ja|ka|de|he|it|lv|pl|pt|ru|es|uk
|
||||
|
||||
# Content categories, lowercase, enabled by default for new users
|
||||
APP_CATEGORIES=movie|series|tv|animation|music|game|audiobook|podcast|book|archive|picture|software|other
|
||||
|
||||
# Items per page on pagination
|
||||
APP_PAGINATION=10
|
||||
|
||||
|
@ -11,6 +11,7 @@ parameters:
|
||||
app.trackers: '%env(APP_TRACKERS)%'
|
||||
app.crawlers: '%env(APP_CRAWLERS)%'
|
||||
app.locales: '%env(APP_LOCALES)%'
|
||||
app.categories: '%env(APP_CATEGORIES)%'
|
||||
app.themes: '%env(APP_THEMES)%'
|
||||
app.locale: '%env(APP_LOCALE)%'
|
||||
app.theme: '%env(APP_THEME)%'
|
||||
|
37
migrations/Version20231103235504.php
Normal file
37
migrations/Version20231103235504.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20231103235504 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('CREATE TABLE torrent_categories (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, torrent_id INTEGER NOT NULL, user_id INTEGER NOT NULL, added INTEGER NOT NULL, value CLOB NOT NULL --(DC2Type:simple_array)
|
||||
, approved BOOLEAN NOT NULL)');
|
||||
$this->addSql('ALTER TABLE user ADD COLUMN categories CLOB DEFAULT "other"');
|
||||
$this->addSql('ALTER TABLE torrent ADD COLUMN categories CLOB DEFAULT "other"');
|
||||
$this->addSql('UPDATE user SET categories = "movie,series,tv,animation,music,game,audiobook,podcast,book,archive,picture,software,other"');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('DROP TABLE torrent_categories');
|
||||
$this->addSql('ALTER TABLE user DROP COLUMN categories');
|
||||
$this->addSql('ALTER TABLE torrent DROP COLUMN categories');
|
||||
}
|
||||
}
|
@ -150,12 +150,13 @@ class TorrentController extends AbstractController
|
||||
'peers' => (int) $torrent->getPeers(),
|
||||
'leechers' => (int) $torrent->getLeechers(),
|
||||
],
|
||||
'keywords' => $torrent->getKeywords(),
|
||||
'locales' => $torrent->getLocales(),
|
||||
'sensitive' => $torrent->isSensitive(),
|
||||
'approved' => $torrent->isApproved(),
|
||||
'status' => $torrent->isStatus(),
|
||||
'download' =>
|
||||
'keywords' => $torrent->getKeywords(),
|
||||
'locales' => $torrent->getLocales(),
|
||||
'categories' => $torrent->getCategories(),
|
||||
'sensitive' => $torrent->isSensitive(),
|
||||
'approved' => $torrent->isApproved(),
|
||||
'status' => $torrent->isStatus(),
|
||||
'download' =>
|
||||
[
|
||||
'file' =>
|
||||
[
|
||||
@ -262,7 +263,8 @@ class TorrentController extends AbstractController
|
||||
$user->getId(),
|
||||
$query,
|
||||
$user->getLocales(),
|
||||
!$user->isModerator() && $user->isSensitive() ? false : null,
|
||||
$user->getCategories(),
|
||||
$user->isSensitive() ? false : null,
|
||||
!$user->isModerator() ? true : null,
|
||||
!$user->isModerator() ? true : null,
|
||||
);
|
||||
@ -272,7 +274,8 @@ class TorrentController extends AbstractController
|
||||
$user->getId(),
|
||||
$query,
|
||||
$user->getLocales(),
|
||||
!$user->isModerator() && $user->isSensitive() ? false : null,
|
||||
$user->getCategories(),
|
||||
$user->isSensitive() ? false : null,
|
||||
!$user->isModerator() ? true : null,
|
||||
!$user->isModerator() ? true : null,
|
||||
$this->getParameter('app.pagination'),
|
||||
@ -448,7 +451,8 @@ class TorrentController extends AbstractController
|
||||
$user->getId(),
|
||||
[],
|
||||
$user->getLocales(),
|
||||
!$user->isModerator() && $user->isSensitive() ? false : null,
|
||||
$user->getCategories(),
|
||||
$user->isSensitive() ? false : null,
|
||||
!$user->isModerator() ? true : null,
|
||||
!$user->isModerator() ? true : null,
|
||||
);
|
||||
@ -459,7 +463,8 @@ class TorrentController extends AbstractController
|
||||
$user->getId(),
|
||||
[],
|
||||
$user->getLocales(),
|
||||
!$user->isModerator() && $user->isSensitive() ? false : null,
|
||||
$user->getCategories(),
|
||||
$user->isSensitive() ? false : null,
|
||||
!$user->isModerator() ? true : null,
|
||||
!$user->isModerator() ? true : null,
|
||||
$this->getParameter('app.pagination'),
|
||||
@ -625,7 +630,8 @@ class TorrentController extends AbstractController
|
||||
$user->getId(),
|
||||
$query,
|
||||
$user->getLocales(),
|
||||
!$user->isModerator() && $user->isSensitive() ? false : null,
|
||||
$user->getCategories(),
|
||||
$user->isSensitive() ? false : null,
|
||||
!$user->isModerator() ? true : null,
|
||||
!$user->isModerator() ? true : null,
|
||||
);
|
||||
@ -636,7 +642,8 @@ class TorrentController extends AbstractController
|
||||
$user->getId(),
|
||||
$query,
|
||||
$user->getLocales(),
|
||||
!$user->isModerator() && $user->isSensitive() ? false : null,
|
||||
$user->getCategories(),
|
||||
$user->isSensitive() ? false : null,
|
||||
!$user->isModerator() ? true : null,
|
||||
!$user->isModerator() ? true : null,
|
||||
$this->getParameter('app.pagination'),
|
||||
@ -700,13 +707,14 @@ class TorrentController extends AbstractController
|
||||
);
|
||||
|
||||
// Init request
|
||||
$query = $request->get('query') ? explode(' ', urldecode($request->get('query'))) : [];
|
||||
$page = $request->get('page') ? (int) $request->get('page') : 1;
|
||||
$query = $request->get('query') ? explode(' ', urldecode($request->get('query'))) : [];
|
||||
$page = $request->get('page') ? (int) $request->get('page') : 1;
|
||||
|
||||
$locales = $request->get('locales') ? explode('|', $request->get('locales')) : explode('|', $this->getParameter('app.locales'));
|
||||
$sensitive = $request->get('sensitive') ? (bool) $request->get('sensitive') : null;
|
||||
$locales = $request->get('locales') ? explode('|', $request->get('locales')) : explode('|', $this->getParameter('app.locales'));
|
||||
$categories = $request->get('categories') ? explode('|', $request->get('categories')) : explode('|', $this->getParameter('app.categories'));
|
||||
$sensitive = $request->get('sensitive') ? (bool) $request->get('sensitive') : null;
|
||||
|
||||
$yggdrasil = $request->get('yggdrasil') ? (bool) $request->get('yggdrasil') : false;
|
||||
$yggdrasil = $request->get('yggdrasil') ? (bool) $request->get('yggdrasil') : false;
|
||||
|
||||
// Init trackers
|
||||
$trackers = explode('|', $this->getParameter('app.trackers'));
|
||||
@ -716,7 +724,8 @@ class TorrentController extends AbstractController
|
||||
$user->getId(),
|
||||
$query,
|
||||
$locales,
|
||||
!$user->isModerator() ? $sensitive : null,
|
||||
$categories,
|
||||
$sensitive,
|
||||
!$user->isModerator() ? true : null,
|
||||
!$user->isModerator() ? true : null,
|
||||
);
|
||||
@ -727,7 +736,8 @@ class TorrentController extends AbstractController
|
||||
$user->getId(),
|
||||
$query,
|
||||
$locales,
|
||||
!$user->isModerator() ? $sensitive : null,
|
||||
$categories,
|
||||
$sensitive,
|
||||
!$user->isModerator() ? true : null,
|
||||
!$user->isModerator() ? true : null,
|
||||
$this->getParameter('app.pagination'),
|
||||
@ -873,6 +883,14 @@ class TorrentController extends AbstractController
|
||||
'value' => $request->get('locales') ? $request->get('locales') : [$request->get('_locale')],
|
||||
]
|
||||
],
|
||||
'categories' =>
|
||||
[
|
||||
'error' => [],
|
||||
'attribute' =>
|
||||
[
|
||||
'value' => $request->get('categories') ? $request->get('categories') : [],
|
||||
]
|
||||
],
|
||||
'torrent' =>
|
||||
[
|
||||
'error' => [],
|
||||
@ -909,6 +927,25 @@ class TorrentController extends AbstractController
|
||||
$form['locales']['error'][] = $translator->trans('At least one locale required');
|
||||
}
|
||||
|
||||
/// Categories
|
||||
$categories = [];
|
||||
if ($request->get('categories'))
|
||||
{
|
||||
foreach ((array) $request->get('categories') as $locale)
|
||||
{
|
||||
if (in_array($locale, explode('|', $this->getParameter('app.categories'))))
|
||||
{
|
||||
$categories[] = $locale;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//// At least one valid locale required
|
||||
if (!$categories)
|
||||
{
|
||||
$form['categories']['error'][] = $translator->trans('At least one category required');
|
||||
}
|
||||
|
||||
/// Torrent
|
||||
if ($file = $request->files->get('torrent'))
|
||||
{
|
||||
@ -937,7 +974,7 @@ class TorrentController extends AbstractController
|
||||
}
|
||||
|
||||
// Request is valid
|
||||
if (empty($form['torrent']['error']) && empty($form['locales']['error']))
|
||||
if (empty($form['torrent']['error']) && empty($form['locales']['error']) && empty($form['categories']['error']))
|
||||
{
|
||||
// Save data
|
||||
$torrent = $torrentService->add(
|
||||
@ -956,6 +993,7 @@ class TorrentController extends AbstractController
|
||||
$user->getId(),
|
||||
time(),
|
||||
(array) $locales,
|
||||
(array) $categories,
|
||||
(bool) $request->get('sensitive'),
|
||||
$user->isApproved(),
|
||||
$user->isStatus()
|
||||
@ -983,8 +1021,9 @@ class TorrentController extends AbstractController
|
||||
return $this->render(
|
||||
'default/torrent/submit.html.twig',
|
||||
[
|
||||
'locales' => explode('|', $this->getParameter('app.locales')),
|
||||
'form' => $form,
|
||||
'locales' => explode('|', $this->getParameter('app.locales')),
|
||||
'categories' => explode('|', $this->getParameter('app.categories')),
|
||||
'form' => $form,
|
||||
]
|
||||
);
|
||||
}
|
||||
@ -1504,6 +1543,369 @@ class TorrentController extends AbstractController
|
||||
);
|
||||
}
|
||||
|
||||
// Torrent categories
|
||||
#[Route(
|
||||
'/{_locale}/torrent/{torrentId}/edit/categories/{torrentCategoriesId}',
|
||||
name: 'torrent_categories_edit',
|
||||
requirements:
|
||||
[
|
||||
'_locale' => '%app.locales%',
|
||||
'torrentId' => '\d+',
|
||||
'torrentCategoriesId' => '\d+',
|
||||
],
|
||||
defaults:
|
||||
[
|
||||
'torrentCategoriesId' => null,
|
||||
],
|
||||
methods:
|
||||
[
|
||||
'GET',
|
||||
'POST'
|
||||
]
|
||||
)]
|
||||
public function editCategories(
|
||||
Request $request,
|
||||
TranslatorInterface $translator,
|
||||
UserService $userService,
|
||||
TorrentService $torrentService,
|
||||
ActivityService $activityService
|
||||
): Response
|
||||
{
|
||||
// Init user
|
||||
$user = $this->initUser(
|
||||
$request,
|
||||
$userService,
|
||||
$activityService
|
||||
);
|
||||
|
||||
if (!$user->isStatus())
|
||||
{
|
||||
// @TODO
|
||||
throw new \Exception(
|
||||
$translator->trans('Access denied')
|
||||
);
|
||||
}
|
||||
|
||||
// Init torrent
|
||||
if (!$torrent = $torrentService->getTorrent($request->get('torrentId')))
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
// Init torrent categories
|
||||
$torrentCategoriesCurrent = [
|
||||
'userId' => null,
|
||||
'value' => []
|
||||
];
|
||||
|
||||
// Get from edition version requested
|
||||
if ($request->get('torrentCategoriesId'))
|
||||
{
|
||||
if ($torrentCategories = $torrentService->getTorrentCategories($request->get('torrentCategoriesId')))
|
||||
{
|
||||
$torrentCategoriesCurrent['userId'] = $torrentCategories->getUserId();
|
||||
|
||||
foreach ($torrentCategories->getValue() as $value)
|
||||
{
|
||||
$torrentCategoriesCurrent['value'][] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, get latest available
|
||||
else
|
||||
{
|
||||
if ($torrentCategories = $torrentService->findLastTorrentCategoriesByTorrentId($torrent->getId()))
|
||||
{
|
||||
$torrentCategoriesCurrent['userId'] = $torrentCategories->getUserId();
|
||||
|
||||
foreach ($torrentCategories->getValue() as $value)
|
||||
{
|
||||
$torrentCategoriesCurrent['value'][] = $value;
|
||||
}
|
||||
|
||||
// Update active categories
|
||||
$request->attributes->set('torrentCategoriesId', $torrentCategories->getId());
|
||||
}
|
||||
}
|
||||
|
||||
// Init edition history
|
||||
$editions = [];
|
||||
foreach ($torrentService->findTorrentCategoriesByTorrentId($torrent->getId()) as $torrentCategoriesEdition)
|
||||
{
|
||||
$editions[] =
|
||||
[
|
||||
'id' => $torrentCategoriesEdition->getId(),
|
||||
'added' => $torrentCategoriesEdition->getAdded(),
|
||||
'approved' => $torrentCategoriesEdition->isApproved(),
|
||||
'active' => $torrentCategoriesEdition->getId() == $request->get('torrentCategoriesId'),
|
||||
'user' =>
|
||||
[
|
||||
'id' => $torrentCategoriesEdition->getUserId(),
|
||||
'identicon' => $userService->identicon(
|
||||
$userService->getUser(
|
||||
$torrentCategoriesEdition->getUserId()
|
||||
)->getAddress()
|
||||
),
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
// Init form
|
||||
$form =
|
||||
[
|
||||
'categories' =>
|
||||
[
|
||||
'error' => [],
|
||||
'attribute' =>
|
||||
[
|
||||
'value' => $request->get('categories') ? $request->get('categories') : $torrentCategoriesCurrent['value'],
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
// Process request
|
||||
if ($request->isMethod('post'))
|
||||
{
|
||||
/// Categories
|
||||
$categories = [];
|
||||
if ($request->get('categories'))
|
||||
{
|
||||
foreach ((array) $request->get('categories') as $category)
|
||||
{
|
||||
if (in_array($category, explode('|', $this->getParameter('app.categories'))))
|
||||
{
|
||||
$categories[] = $category;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//// At least one valid category required
|
||||
if (!$categories)
|
||||
{
|
||||
$form['categories']['error'][] = $translator->trans('At least one category required');
|
||||
}
|
||||
|
||||
// Request is valid
|
||||
if (empty($form['categories']['error']))
|
||||
{
|
||||
// Save data
|
||||
$torrentCategories = $torrentService->addTorrentCategories(
|
||||
$torrent->getId(),
|
||||
$user->getId(),
|
||||
time(),
|
||||
$categories,
|
||||
$user->isApproved()
|
||||
);
|
||||
|
||||
// Register activity event
|
||||
/* @TODO
|
||||
$activityService->addEventTorrentCategoriesAdd(
|
||||
$user->getId(),
|
||||
$torrent->getId(),
|
||||
time(),
|
||||
$torrentCategories->getId()
|
||||
);
|
||||
*/
|
||||
|
||||
// Redirect to info page
|
||||
return $this->redirectToRoute(
|
||||
'torrent_info',
|
||||
[
|
||||
'_locale' => $request->get('_locale'),
|
||||
'torrentId' => $torrent->getId()
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Render form template
|
||||
return $this->render(
|
||||
'default/torrent/edit/categories.html.twig',
|
||||
[
|
||||
'torrentId' => $torrent->getId(),
|
||||
'categories' => explode('|', $this->getParameter('app.categories')),
|
||||
'editions' => $editions,
|
||||
'form' => $form,
|
||||
'session' =>
|
||||
[
|
||||
'moderator' => $user->isModerator(),
|
||||
'owner' => $torrentCategoriesCurrent['userId'] === $user->getId(),
|
||||
]
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[Route(
|
||||
'/{_locale}/torrent/{torrentId}/approve/categories/{torrentCategoriesId}',
|
||||
name: 'torrent_categories_approve',
|
||||
requirements:
|
||||
[
|
||||
'_locale' => '%app.locales%',
|
||||
'torrentId' => '\d+',
|
||||
'torrentCategoriesId' => '\d+',
|
||||
],
|
||||
methods:
|
||||
[
|
||||
'GET'
|
||||
]
|
||||
)]
|
||||
public function approveCategories(
|
||||
Request $request,
|
||||
TranslatorInterface $translator,
|
||||
UserService $userService,
|
||||
TorrentService $torrentService,
|
||||
ActivityService $activityService
|
||||
): Response
|
||||
{
|
||||
// Init user
|
||||
$user = $this->initUser(
|
||||
$request,
|
||||
$userService,
|
||||
$activityService
|
||||
);
|
||||
|
||||
// Init torrent
|
||||
if (!$torrent = $torrentService->getTorrent($request->get('torrentId')))
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
// Init torrent categories
|
||||
if (!$torrentCategories = $torrentService->getTorrentCategories($request->get('torrentCategoriesId')))
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
// Check permissions
|
||||
if (!$user->isModerator())
|
||||
{
|
||||
// @TODO
|
||||
throw new \Exception(
|
||||
$translator->trans('Access denied')
|
||||
);
|
||||
}
|
||||
|
||||
// Register activity event
|
||||
/* @TODO
|
||||
if (!$torrentCategories->isApproved())
|
||||
{
|
||||
$activityService->addEventTorrentCategoriesApproveAdd(
|
||||
$user->getId(),
|
||||
$torrent->getId(),
|
||||
time(),
|
||||
$torrentCategories->getId()
|
||||
);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$activityService->addEventTorrentCategoriesApproveDelete(
|
||||
$user->getId(),
|
||||
$torrent->getId(),
|
||||
time(),
|
||||
$torrentCategories->getId()
|
||||
);
|
||||
}
|
||||
*/
|
||||
|
||||
// Update approved
|
||||
$torrentService->toggleTorrentCategoriesApproved(
|
||||
$torrentCategories->getId()
|
||||
);
|
||||
|
||||
// Redirect back to form
|
||||
return $this->redirectToRoute(
|
||||
'torrent_categories_edit',
|
||||
[
|
||||
'_locale' => $request->get('_locale'),
|
||||
'torrentId' => $torrent->getId(),
|
||||
'torrentCategoriesId' => $torrentCategories->getId(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[Route(
|
||||
'/{_locale}/torrent/{torrentId}/delete/categories/{torrentCategoriesId}',
|
||||
name: 'torrent_categories_delete',
|
||||
requirements:
|
||||
[
|
||||
'_locale' => '%app.locales%',
|
||||
'torrentId' => '\d+',
|
||||
'torrentCategoriesId' => '\d+',
|
||||
],
|
||||
methods:
|
||||
[
|
||||
'GET'
|
||||
]
|
||||
)]
|
||||
public function deleteCategories(
|
||||
Request $request,
|
||||
TranslatorInterface $translator,
|
||||
UserService $userService,
|
||||
TorrentService $torrentService,
|
||||
ActivityService $activityService
|
||||
): Response
|
||||
{
|
||||
// Init user
|
||||
$user = $this->initUser(
|
||||
$request,
|
||||
$userService,
|
||||
$activityService
|
||||
);
|
||||
|
||||
// Init torrent
|
||||
if (!$torrent = $torrentService->getTorrent($request->get('torrentId')))
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
// Init torrent categories
|
||||
if (!$torrentCategories = $torrentService->getTorrentCategories($request->get('torrentCategoriesId')))
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
// Check permissions
|
||||
if (!($user->isModerator() || $user->getId() === $torrentCategories->getUserId()))
|
||||
{
|
||||
// @TODO
|
||||
throw new \Exception(
|
||||
$translator->trans('Access denied')
|
||||
);
|
||||
}
|
||||
|
||||
// Add activity event
|
||||
/* @TODO
|
||||
$activityService->addEventTorrentCategoriesDelete(
|
||||
$user->getId(),
|
||||
$torrent->getId(),
|
||||
time(),
|
||||
$torrentCategories->getId()
|
||||
);
|
||||
*/
|
||||
|
||||
// Update approved
|
||||
$torrentService->deleteTorrentCategories(
|
||||
$torrentCategories->getId()
|
||||
);
|
||||
|
||||
// Redirect back to form
|
||||
return $this->redirectToRoute(
|
||||
'torrent_categories_edit',
|
||||
[
|
||||
'_locale' => $request->get('_locale'),
|
||||
'torrentId' => $torrent->getId(),
|
||||
'torrentCategoriesId' => $torrentCategories->getId(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
// Torrent sensitive
|
||||
#[Route(
|
||||
'/{_locale}/torrent/{torrentId}/edit/sensitive/{torrentSensitiveId}',
|
||||
@ -2926,14 +3328,15 @@ class TorrentController extends AbstractController
|
||||
'locale' => $locale,
|
||||
'locales' => $locales,
|
||||
'torrents' => $torrentService->findTorrents(
|
||||
0, // no user session init, pass 0
|
||||
[], // without keywords filter
|
||||
$locales, // all system locales
|
||||
null, // all sensitive levels
|
||||
true, // approved only
|
||||
true, // enabled only
|
||||
1000, // @TODO limit
|
||||
0 // offset
|
||||
0, // no user session init, pass 0
|
||||
[], // without keywords filter
|
||||
$locales, // all system locales
|
||||
$categories, // all system locales
|
||||
null, // all sensitive levels
|
||||
true, // approved only
|
||||
true, // enabled only
|
||||
1000, // @TODO limit
|
||||
0 // offset
|
||||
)
|
||||
],
|
||||
$response
|
||||
|
@ -85,6 +85,23 @@ class UserController extends AbstractController
|
||||
);
|
||||
}
|
||||
|
||||
// Update categories
|
||||
if ($request->get('categories'))
|
||||
{
|
||||
$categories = [];
|
||||
foreach ((array) $request->get('categories') as $category)
|
||||
{
|
||||
if (in_array($category, explode('|', $this->getParameter('app.categories'))))
|
||||
{
|
||||
$categories[] = $category;
|
||||
}
|
||||
}
|
||||
|
||||
$user->setCategories(
|
||||
$categories
|
||||
);
|
||||
}
|
||||
|
||||
// Update theme
|
||||
if (in_array($request->get('theme'), explode('|', $this->getParameter('app.themes'))))
|
||||
{
|
||||
@ -139,19 +156,21 @@ class UserController extends AbstractController
|
||||
'default/user/settings.html.twig',
|
||||
[
|
||||
'user' => [
|
||||
'id' => $user->getId(),
|
||||
'sensitive' => $user->isSensitive(),
|
||||
'yggdrasil' => $user->isYggdrasil(),
|
||||
'posters' => $user->isPosters(),
|
||||
'locale' => $user->getLocale(),
|
||||
'locales' => $user->getLocales(),
|
||||
'events' => $user->getEvents(),
|
||||
'theme' => $user->getTheme(),
|
||||
'added' => $user->getAdded()
|
||||
'id' => $user->getId(),
|
||||
'sensitive' => $user->isSensitive(),
|
||||
'yggdrasil' => $user->isYggdrasil(),
|
||||
'posters' => $user->isPosters(),
|
||||
'locale' => $user->getLocale(),
|
||||
'locales' => $user->getLocales(),
|
||||
'categories' => $user->getCategories(),
|
||||
'events' => $user->getEvents(),
|
||||
'theme' => $user->getTheme(),
|
||||
'added' => $user->getAdded()
|
||||
],
|
||||
'locales' => explode('|', $this->getParameter('app.locales')),
|
||||
'themes' => explode('|', $this->getParameter('app.themes')),
|
||||
'events' => $activityService->getEventsTree()
|
||||
'locales' => explode('|', $this->getParameter('app.locales')),
|
||||
'categories' => explode('|', $this->getParameter('app.categories')),
|
||||
'themes' => explode('|', $this->getParameter('app.themes')),
|
||||
'events' => $activityService->getEventsTree()
|
||||
]
|
||||
);
|
||||
}
|
||||
@ -217,20 +236,21 @@ class UserController extends AbstractController
|
||||
'moderator' => $user->isModerator()
|
||||
],
|
||||
'user' => [
|
||||
'id' => $userTarget->getId(),
|
||||
'address' => $userTarget->getAddress(),
|
||||
'moderator' => $userTarget->isModerator(),
|
||||
'approved' => $userTarget->isApproved(),
|
||||
'status' => $userTarget->isStatus(),
|
||||
'posters' => $userTarget->isPosters(),
|
||||
'sensitive' => $userTarget->isSensitive(),
|
||||
'yggdrasil' => $userTarget->isYggdrasil(),
|
||||
'locale' => $userTarget->getLocale(),
|
||||
'locales' => $userTarget->getLocales(),
|
||||
'events' => $userTarget->getEvents(),
|
||||
'theme' => $userTarget->getTheme(),
|
||||
'added' => $userTarget->getAdded(),
|
||||
'identicon' => $userService->identicon(
|
||||
'id' => $userTarget->getId(),
|
||||
'address' => $userTarget->getAddress(),
|
||||
'moderator' => $userTarget->isModerator(),
|
||||
'approved' => $userTarget->isApproved(),
|
||||
'status' => $userTarget->isStatus(),
|
||||
'posters' => $userTarget->isPosters(),
|
||||
'sensitive' => $userTarget->isSensitive(),
|
||||
'yggdrasil' => $userTarget->isYggdrasil(),
|
||||
'locale' => $userTarget->getLocale(),
|
||||
'locales' => $userTarget->getLocales(),
|
||||
'categories' => $user->getCategories(),
|
||||
'events' => $userTarget->getEvents(),
|
||||
'theme' => $userTarget->getTheme(),
|
||||
'added' => $userTarget->getAdded(),
|
||||
'identicon' => $userService->identicon(
|
||||
$userTarget->getAddress(),
|
||||
48
|
||||
),
|
||||
@ -545,6 +565,11 @@ class UserController extends AbstractController
|
||||
true
|
||||
);
|
||||
|
||||
$torrentService->setTorrentCategoriesApprovedByUserId(
|
||||
$userTarget->getId(),
|
||||
true
|
||||
);
|
||||
|
||||
$torrentService->setTorrentSensitivesApprovedByUserId(
|
||||
$userTarget->getId(),
|
||||
true
|
||||
|
@ -54,6 +54,9 @@ class Torrent
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?int $torrentPosterId = null;
|
||||
|
||||
#[ORM\Column(type: Types::SIMPLE_ARRAY)]
|
||||
private ?array $categories = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
@ -221,4 +224,16 @@ class Torrent
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCategories(): ?array
|
||||
{
|
||||
return $this->categories;
|
||||
}
|
||||
|
||||
public function setCategories(?array $categories): static
|
||||
{
|
||||
$this->categories = $categories;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
103
src/Entity/TorrentCategories.php
Normal file
103
src/Entity/TorrentCategories.php
Normal file
@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\TorrentCategoriesRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: TorrentCategoriesRepository::class)]
|
||||
class TorrentCategories
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?int $torrentId = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?int $userId = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?int $added = null;
|
||||
|
||||
#[ORM\Column(type: Types::SIMPLE_ARRAY)]
|
||||
private array $value = [];
|
||||
|
||||
#[ORM\Column]
|
||||
private ?bool $approved = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId(string $id): static
|
||||
{
|
||||
$this->id = $id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTorrentId(): ?int
|
||||
{
|
||||
return $this->torrentId;
|
||||
}
|
||||
|
||||
public function setTorrentId(int $torrentId): static
|
||||
{
|
||||
$this->torrentId = $torrentId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUserId(): ?int
|
||||
{
|
||||
return $this->userId;
|
||||
}
|
||||
|
||||
public function setUserId(int $userId): static
|
||||
{
|
||||
$this->userId = $userId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAdded(): ?int
|
||||
{
|
||||
return $this->added;
|
||||
}
|
||||
|
||||
public function setAdded(int $added): static
|
||||
{
|
||||
$this->added = $added;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getValue(): array
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function setValue(array $value): static
|
||||
{
|
||||
$this->value = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isApproved(): ?bool
|
||||
{
|
||||
return $this->approved;
|
||||
}
|
||||
|
||||
public function setApproved(bool $approved): static
|
||||
{
|
||||
$this->approved = $approved;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
@ -50,6 +50,9 @@ class User
|
||||
#[ORM\Column]
|
||||
private ?bool $posters = null;
|
||||
|
||||
#[ORM\Column(type: Types::SIMPLE_ARRAY)]
|
||||
private ?array $categories = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
@ -205,4 +208,16 @@ class User
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCategories(): ?array
|
||||
{
|
||||
return $this->categories;
|
||||
}
|
||||
|
||||
public function setCategories(?array $categories): static
|
||||
{
|
||||
$this->categories = $categories;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
23
src/Repository/TorrentCategoriesRepository.php
Normal file
23
src/Repository/TorrentCategoriesRepository.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\TorrentCategories;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<TorrentCategories>
|
||||
*
|
||||
* @method TorrentCategories|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method TorrentCategories|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method TorrentCategories[] findAll()
|
||||
* @method TorrentCategories[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class TorrentCategoriesRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, TorrentCategories::class);
|
||||
}
|
||||
}
|
@ -24,7 +24,8 @@ class TorrentRepository extends ServiceEntityRepository
|
||||
public function findTorrentsTotal(
|
||||
int $userId,
|
||||
array $keywords,
|
||||
array $locales,
|
||||
?array $locales,
|
||||
?array $categories,
|
||||
?bool $sensitive = null,
|
||||
?bool $approved = null,
|
||||
?bool $status = null,
|
||||
@ -36,6 +37,7 @@ class TorrentRepository extends ServiceEntityRepository
|
||||
$userId,
|
||||
$keywords,
|
||||
$locales,
|
||||
$categories,
|
||||
$sensitive,
|
||||
$approved,
|
||||
$status,
|
||||
@ -47,7 +49,8 @@ class TorrentRepository extends ServiceEntityRepository
|
||||
public function findTorrents(
|
||||
int $userId,
|
||||
array $keywords,
|
||||
array $locales,
|
||||
?array $locales,
|
||||
?array $categories,
|
||||
?bool $sensitive = null,
|
||||
?bool $approved = null,
|
||||
?bool $status = null,
|
||||
@ -59,6 +62,7 @@ class TorrentRepository extends ServiceEntityRepository
|
||||
$userId,
|
||||
$keywords,
|
||||
$locales,
|
||||
$categories,
|
||||
$sensitive,
|
||||
$approved,
|
||||
$status,
|
||||
@ -70,17 +74,18 @@ class TorrentRepository extends ServiceEntityRepository
|
||||
}
|
||||
|
||||
private function getTorrentsQueryByFilter(
|
||||
int $userId,
|
||||
array $keywords,
|
||||
array $locales,
|
||||
?bool $sensitive = null,
|
||||
?bool $approved = null,
|
||||
?bool $status = null
|
||||
int $userId,
|
||||
?array $keywords,
|
||||
?array $locales,
|
||||
?array $categories,
|
||||
?bool $sensitive = null,
|
||||
?bool $approved = null,
|
||||
?bool $status = null
|
||||
): \Doctrine\ORM\QueryBuilder
|
||||
{
|
||||
$query = $this->createQueryBuilder('t');
|
||||
|
||||
if ($keywords)
|
||||
if (is_array($keywords))
|
||||
{
|
||||
foreach ($keywords as $i => $keyword)
|
||||
{
|
||||
@ -105,7 +110,7 @@ class TorrentRepository extends ServiceEntityRepository
|
||||
}
|
||||
}
|
||||
|
||||
if ($locales)
|
||||
if (is_array($locales))
|
||||
{
|
||||
$orLocales = $query->expr()->orX();
|
||||
|
||||
@ -121,6 +126,22 @@ class TorrentRepository extends ServiceEntityRepository
|
||||
$query->andWhere($orLocales);
|
||||
}
|
||||
|
||||
if (is_array($categories))
|
||||
{
|
||||
$orCategories = $query->expr()->orX();
|
||||
|
||||
foreach ($categories as $i => $category)
|
||||
{
|
||||
$orCategories->add("t.categories LIKE :category{$i}");
|
||||
$orCategories->add("t.userId = :userId");
|
||||
|
||||
$query->setParameter(":category{$i}", "%{$category}%");
|
||||
$query->setParameter('userId', $userId);
|
||||
}
|
||||
|
||||
$query->andWhere($orCategories);
|
||||
}
|
||||
|
||||
if (is_bool($sensitive))
|
||||
{
|
||||
$orSensitive = $query->expr()->orX();
|
||||
|
@ -4,6 +4,7 @@ namespace App\Service;
|
||||
|
||||
use App\Entity\Torrent;
|
||||
use App\Entity\TorrentLocales;
|
||||
use App\Entity\TorrentCategories;
|
||||
use App\Entity\TorrentSensitive;
|
||||
use App\Entity\TorrentPoster;
|
||||
use App\Entity\TorrentStar;
|
||||
@ -12,6 +13,7 @@ use App\Entity\TorrentDownloadMagnet;
|
||||
|
||||
use App\Repository\TorrentRepository;
|
||||
use App\Repository\TorrentLocalesRepository;
|
||||
use App\Repository\TorrentCategoriesRepository;
|
||||
use App\Repository\TorrentSensitiveRepository;
|
||||
use App\Repository\TorrentPosterRepository;
|
||||
use App\Repository\TorrentStarRepository;
|
||||
@ -381,6 +383,7 @@ class TorrentService
|
||||
int $userId,
|
||||
int $added,
|
||||
array $locales,
|
||||
array $categories,
|
||||
bool $sensitive,
|
||||
bool $approved,
|
||||
bool $status
|
||||
@ -403,6 +406,7 @@ class TorrentService
|
||||
$wordLengthMax
|
||||
),
|
||||
$locales,
|
||||
$categories,
|
||||
$sensitive,
|
||||
$approved,
|
||||
$status
|
||||
@ -424,6 +428,14 @@ class TorrentService
|
||||
$approved
|
||||
);
|
||||
|
||||
$this->addTorrentCategories(
|
||||
$torrent->getId(),
|
||||
$userId,
|
||||
$added,
|
||||
$categories,
|
||||
$approved
|
||||
);
|
||||
|
||||
$this->addTorrentSensitive(
|
||||
$torrent->getId(),
|
||||
$userId,
|
||||
@ -449,6 +461,7 @@ class TorrentService
|
||||
string $md5file,
|
||||
array $keywords,
|
||||
array $locales,
|
||||
array $categories,
|
||||
bool $sensitive,
|
||||
bool $approved,
|
||||
bool $status
|
||||
@ -461,6 +474,7 @@ class TorrentService
|
||||
$torrent->setMd5File($md5file);
|
||||
$torrent->setKeywords($keywords);
|
||||
$torrent->setLocales($locales);
|
||||
$torrent->setCategories($categories);
|
||||
$torrent->setSensitive($sensitive);
|
||||
$torrent->setApproved($approved);
|
||||
$torrent->setStatus($status);
|
||||
@ -534,7 +548,8 @@ class TorrentService
|
||||
public function findTorrents(
|
||||
int $userId,
|
||||
array $keywords,
|
||||
array $locales,
|
||||
?array $locales,
|
||||
?array $categories,
|
||||
?bool $sensitive,
|
||||
?bool $approved,
|
||||
?bool $status,
|
||||
@ -548,6 +563,7 @@ class TorrentService
|
||||
$userId,
|
||||
$keywords,
|
||||
$locales,
|
||||
$categories,
|
||||
$sensitive,
|
||||
$approved,
|
||||
$status,
|
||||
@ -559,7 +575,8 @@ class TorrentService
|
||||
public function findTorrentsTotal(
|
||||
int $userId,
|
||||
array $keywords,
|
||||
array $locales,
|
||||
?array $locales,
|
||||
?array $categories,
|
||||
?bool $sensitive,
|
||||
?bool $approved,
|
||||
?bool $status
|
||||
@ -571,6 +588,7 @@ class TorrentService
|
||||
$userId,
|
||||
$keywords,
|
||||
$locales,
|
||||
$categories,
|
||||
$sensitive,
|
||||
$approved,
|
||||
$status
|
||||
@ -642,6 +660,32 @@ class TorrentService
|
||||
}
|
||||
}
|
||||
|
||||
public function updateTorrentCategories(
|
||||
int $torrentId
|
||||
): void
|
||||
{
|
||||
if ($torrent = $this->getTorrent($torrentId))
|
||||
{
|
||||
if ($torrentCategories = $this->entityManagerInterface
|
||||
->getRepository(TorrentCategories::class)
|
||||
->findOneBy(
|
||||
[
|
||||
'torrentId' => $torrentId,
|
||||
'approved' => true,
|
||||
],
|
||||
[
|
||||
'id' => 'DESC'
|
||||
]
|
||||
))
|
||||
{
|
||||
$torrent->setCategories($torrentCategories->getValue());
|
||||
|
||||
$this->entityManagerInterface->persist($torrent);
|
||||
$this->entityManagerInterface->flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function updateTorrentScraped(
|
||||
int $torrentId,
|
||||
int $time
|
||||
@ -886,6 +930,133 @@ class TorrentService
|
||||
}
|
||||
}
|
||||
|
||||
// Torrent category
|
||||
public function getTorrentCategories(
|
||||
int $torrentCategoryId
|
||||
): ?TorrentCategories
|
||||
{
|
||||
return $this->entityManagerInterface
|
||||
->getRepository(TorrentCategories::class)
|
||||
->find($torrentCategoryId);
|
||||
}
|
||||
|
||||
public function findLastTorrentCategoriesByTorrentId(
|
||||
int $torrentId
|
||||
): ?TorrentCategories
|
||||
{
|
||||
return $this->entityManagerInterface
|
||||
->getRepository(TorrentCategories::class)
|
||||
->findOneBy(
|
||||
[
|
||||
'torrentId' => $torrentId
|
||||
],
|
||||
[
|
||||
'id' => 'DESC'
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function findTorrentCategoriesByTorrentId(int $torrentId): array
|
||||
{
|
||||
return $this->entityManagerInterface
|
||||
->getRepository(TorrentCategories::class)
|
||||
->findBy(
|
||||
[
|
||||
'torrentId' => $torrentId,
|
||||
],
|
||||
[
|
||||
'id' => 'DESC'
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function toggleTorrentCategoriesApproved(
|
||||
int $torrentCategoriesId
|
||||
): ?TorrentCategories
|
||||
{
|
||||
$torrentCategories = $this->getTorrentCategories($torrentCategoriesId);
|
||||
|
||||
$torrentCategories->setApproved(
|
||||
!$torrentCategories->isApproved() // toggle current value
|
||||
);
|
||||
|
||||
$this->entityManagerInterface->persist($torrentCategories);
|
||||
$this->entityManagerInterface->flush();
|
||||
|
||||
$this->updateTorrentCategories(
|
||||
$torrentCategories->getTorrentId()
|
||||
);
|
||||
|
||||
return $torrentCategories;
|
||||
}
|
||||
|
||||
public function deleteTorrentCategories(
|
||||
int $torrentCategoriesId
|
||||
): ?TorrentCategories
|
||||
{
|
||||
$torrentCategories = $this->getTorrentCategories($torrentCategoriesId);
|
||||
|
||||
$this->entityManagerInterface->remove($torrentCategories);
|
||||
$this->entityManagerInterface->flush();
|
||||
|
||||
$this->updateTorrentCategories(
|
||||
$torrentCategories->getTorrentId()
|
||||
);
|
||||
|
||||
return $torrentCategories;
|
||||
}
|
||||
|
||||
public function addTorrentCategories(
|
||||
int $torrentId,
|
||||
int $userId,
|
||||
int $added,
|
||||
array $value,
|
||||
bool $approved
|
||||
): ?TorrentCategories
|
||||
{
|
||||
$torrentCategories = new TorrentCategories();
|
||||
|
||||
$torrentCategories->setTorrentId($torrentId);
|
||||
$torrentCategories->setUserId($userId);
|
||||
$torrentCategories->setAdded($added);
|
||||
$torrentCategories->setValue($value);
|
||||
$torrentCategories->setApproved($approved);
|
||||
|
||||
$this->entityManagerInterface->persist($torrentCategories);
|
||||
$this->entityManagerInterface->flush();
|
||||
|
||||
$this->updateTorrentCategories(
|
||||
$torrentId
|
||||
);
|
||||
|
||||
return $torrentCategories;
|
||||
}
|
||||
|
||||
public function setTorrentCategoriesApprovedByUserId(
|
||||
int $userId,
|
||||
bool $value
|
||||
): void
|
||||
{
|
||||
foreach ($this->entityManagerInterface
|
||||
->getRepository(TorrentCategories::class)
|
||||
->findBy(
|
||||
[
|
||||
'userId' => $userId
|
||||
]) as $torrentCategories)
|
||||
{
|
||||
$torrentCategories->setApproved(
|
||||
$value
|
||||
);
|
||||
|
||||
$this->entityManagerInterface->persist($torrentCategories);
|
||||
$this->entityManagerInterface->flush();
|
||||
|
||||
$this->updateTorrentCategories(
|
||||
$torrentCategories->getTorrentId(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Torrent sensitive
|
||||
public function getTorrentSensitive(
|
||||
int $torrentSensitiveId
|
||||
|
109
templates/default/torrent/edit/categories.html.twig
Normal file
109
templates/default/torrent/edit/categories.html.twig
Normal file
@ -0,0 +1,109 @@
|
||||
{% extends 'default/layout.html.twig' %}
|
||||
{% block title %}{{'Edit categories'|trans }} - {{'Torrent'|trans }} #{{ torrentId }} - {{ name }}{% endblock %}
|
||||
{% block main_content %}
|
||||
<div class="padding-24-px margin-y-8-px border-radius-3-px background-color-night">
|
||||
<div class="margin-b-16-px padding-b-16-px border-bottom-default">
|
||||
<h1>
|
||||
{{'Edit categories for torrent' | trans }}
|
||||
<a href="{{ path('torrent_info', { torrentId : torrentId }) }}">#{{ torrentId }}</a>
|
||||
</h1>
|
||||
</div>
|
||||
<form name="categories" method="post" action="{{ path('torrent_categories_edit', { torrentId : torrentId }) }}">
|
||||
<div class="margin-y-16-px">
|
||||
<label for="categories">
|
||||
{{'Content category'|trans }}
|
||||
</label>
|
||||
<sub class="opacity-0 parent-hover-opacity-09" title="{{ 'This torrent have selected categories' | trans }}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" viewBox="0 0 16 16">
|
||||
<path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"/>
|
||||
</svg>
|
||||
</sub>
|
||||
{% for error in form.categories.error %}
|
||||
<div class="text-color-red margin-y-8-px">
|
||||
{{ error }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
<div class="margin-t-8-px margin-b-16-px">
|
||||
{% for category in categories | sort %}
|
||||
<div class="margin-t-8-px margin-b-4-px margin-r-8-px display-inline-block min-width-120-px">
|
||||
{% if category in form.categories.attribute.value %}
|
||||
<input type="checkbox" name="categories[]" id="{{ category }}" value="{{ category }}" checked="checked" />
|
||||
{% else %}
|
||||
<input type="checkbox" name="categories[]" id="{{ category }}" value="{{ category }}" />
|
||||
{% endif %}
|
||||
<label class="margin-l-4-px" for="{{ category }}">
|
||||
{{ category | u.title }}
|
||||
</label>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{#
|
||||
<option class="padding-x-8-px padding-y-8-px" value="other">
|
||||
{{'Other...'|trans }}
|
||||
</option>
|
||||
#}
|
||||
</div>
|
||||
<div class="margin-b-16-px border-bottom-default"></div>
|
||||
</div>
|
||||
<div class="text-right">
|
||||
<a class="margin-r-8-px" href="{{ path('torrent_info', { torrentId : torrentId }) }}">
|
||||
{{'cancel'|trans }}
|
||||
</a>
|
||||
<input class="button-green" type="submit" value="{{'Submit'|trans }}" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% for edition in editions %}
|
||||
<div class="padding-x-24-px padding-y-16-px margin-y-8-px border-radius-3-px {% if edition.active %}background-color-night-light{% else %}background-color-night{% endif %} ">
|
||||
{% if edition.active %}
|
||||
{{ edition.added | format_ago }}
|
||||
{% else %}
|
||||
<a href="{{ path('torrent_categories_edit', { torrentId : torrentId, torrentCategoriesId : edition.id }) }}">
|
||||
{{ edition.added | format_ago }}
|
||||
</a>
|
||||
{% endif %}
|
||||
{{ 'by'|trans }}
|
||||
<a href="{{ path('user_info', { userId : edition.user.id }) }}">
|
||||
<img class="border-radius-50 border-color-default vertical-align-middle" src="{{ edition.user.identicon }}" alt="{{'identicon'|trans }}" />
|
||||
</a>
|
||||
<div class="float-right">
|
||||
{% if session.moderator or session.owner %}
|
||||
<a class="margin-r-8-px text-color-red" href="{{ path('torrent_categories_delete', { torrentId : torrentId, torrentCategoriesId : edition.id }) }}" title="{{ 'Delete' | trans }}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x-circle" viewBox="0 0 16 16">
|
||||
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/>
|
||||
<path d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"/>
|
||||
</svg>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if edition.approved %}
|
||||
{% if session.moderator %}
|
||||
<a href="{{ path('torrent_categories_approve', { torrentId : torrentId, torrentCategoriesId : edition.id }) }}" title="{{ 'Disapprove' | trans }}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
|
||||
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zm-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z"/>
|
||||
</svg>
|
||||
</a>
|
||||
{% else %}
|
||||
<span title="{{ 'Approved' | trans }}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
|
||||
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zm-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z"/>
|
||||
</svg>
|
||||
</span>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if session.moderator %}
|
||||
<a href="{{ path('torrent_categories_approve', { torrentId : torrentId, torrentCategoriesId : edition.id }) }}" title="{{ 'Approve' | trans }}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-hourglass" viewBox="0 0 16 16">
|
||||
<path d="M2 1.5a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-1v1a4.5 4.5 0 0 1-2.557 4.06c-.29.139-.443.377-.443.59v.7c0 .213.154.451.443.59A4.5 4.5 0 0 1 12.5 13v1h1a.5.5 0 0 1 0 1h-11a.5.5 0 1 1 0-1h1v-1a4.5 4.5 0 0 1 2.557-4.06c.29-.139.443-.377.443-.59v-.7c0-.213-.154-.451-.443-.59A4.5 4.5 0 0 1 3.5 3V2h-1a.5.5 0 0 1-.5-.5zm2.5.5v1a3.5 3.5 0 0 0 1.989 3.158c.533.256 1.011.791 1.011 1.491v.702c0 .7-.478 1.235-1.011 1.491A3.5 3.5 0 0 0 4.5 13v1h7v-1a3.5 3.5 0 0 0-1.989-3.158C8.978 9.586 8.5 9.052 8.5 8.351v-.702c0-.7.478-1.235 1.011-1.491A3.5 3.5 0 0 0 11.5 3V2h-7z"/>
|
||||
</svg>
|
||||
</a>
|
||||
{% else %}
|
||||
<span title="{{ 'Waiting for approve' | trans }}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-hourglass" viewBox="0 0 16 16">
|
||||
<path d="M2 1.5a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-1v1a4.5 4.5 0 0 1-2.557 4.06c-.29.139-.443.377-.443.59v.7c0 .213.154.451.443.59A4.5 4.5 0 0 1 12.5 13v1h1a.5.5 0 0 1 0 1h-11a.5.5 0 1 1 0-1h1v-1a4.5 4.5 0 0 1 2.557-4.06c.29-.139.443-.377.443-.59v-.7c0-.213-.154-.451-.443-.59A4.5 4.5 0 0 1 3.5 3V2h-1a.5.5 0 0 1-.5-.5zm2.5.5v1a3.5 3.5 0 0 0 1.989 3.158c.533.256 1.011.791 1.011 1.491v.702c0 .7-.478 1.235-1.011 1.491A3.5 3.5 0 0 0 4.5 13v1h7v-1a3.5 3.5 0 0 0-1.989-3.158C8.978 9.586 8.5 9.052 8.5 8.351v-.702c0-.7.478-1.235 1.011-1.491A3.5 3.5 0 0 0 11.5 3V2h-7z"/>
|
||||
</svg>
|
||||
</span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
@ -24,7 +24,7 @@
|
||||
</div>
|
||||
{% endfor %}
|
||||
<div class="margin-t-8-px margin-b-16-px">
|
||||
{% for locale in locales %}
|
||||
{% for locale in locales | sort %}
|
||||
<div class="margin-t-8-px margin-b-4-px margin-r-8-px display-inline-block min-width-120-px">
|
||||
{% if locale in form.locales.attribute.value %}
|
||||
<input type="checkbox" name="locales[]" id="{{ locale }}" value="{{ locale }}" checked="checked" />
|
||||
|
@ -339,12 +339,28 @@
|
||||
<path d="M12.854.146a.5.5 0 0 0-.707 0L10.5 1.793 14.207 5.5l1.647-1.646a.5.5 0 0 0 0-.708l-3-3zm.646 6.061L9.793 2.5 3.293 9H3.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.207l6.5-6.5zm-7.468 7.468A.5.5 0 0 1 6 13.5V13h-.5a.5.5 0 0 1-.5-.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.5-.5V10h-.5a.499.499 0 0 1-.175-.032l-.179.178a.5.5 0 0 0-.11.168l-2 5a.5.5 0 0 0 .65.65l5-2a.5.5 0 0 0 .168-.11l.178-.178z"/>
|
||||
</svg>
|
||||
</a>
|
||||
{{ 'Locales' | trans }}
|
||||
{{ 'Locale' | trans }}
|
||||
<div class="padding-b-8-px border-bottom-default"></div>
|
||||
<div class="padding-t-16-px text-left">
|
||||
{% if torrent.locales %}
|
||||
<div class="padding-y-4-px">
|
||||
{% for i, locale in torrent.locales %}{% if i > 0 %},{% endif %} {{ locale|locale_name(locale)|u.title }}{% endfor %}
|
||||
{% for i, locale in torrent.locales | sort %}{% if i > 0 %},{% endif %} {{ locale | locale_name(locale) | u.title }}{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-right">
|
||||
<a class="margin-r-4-px{#opacity-0 parent-hover-opacity-09#}" href="{{ path('torrent_categories_edit', { torrentId : torrent.id }) }}" title="{{'Edit'|trans }}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" viewBox="0 0 16 16">
|
||||
<path d="M12.854.146a.5.5 0 0 0-.707 0L10.5 1.793 14.207 5.5l1.647-1.646a.5.5 0 0 0 0-.708l-3-3zm.646 6.061L9.793 2.5 3.293 9H3.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.207l6.5-6.5zm-7.468 7.468A.5.5 0 0 1 6 13.5V13h-.5a.5.5 0 0 1-.5-.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.5-.5V10h-.5a.499.499 0 0 1-.175-.032l-.179.178a.5.5 0 0 0-.11.168l-2 5a.5.5 0 0 0 .65.65l5-2a.5.5 0 0 0 .168-.11l.178-.178z"/>
|
||||
</svg>
|
||||
</a>
|
||||
{{ 'Category' | trans }}
|
||||
<div class="padding-b-8-px border-bottom-default"></div>
|
||||
<div class="padding-t-16-px text-left">
|
||||
{% if torrent.categories %}
|
||||
<div class="padding-y-4-px">
|
||||
{% for i, category in torrent.categories | sort %}{% if i > 0 %},{% endif %} {{ category | u.title }}{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
@ -31,7 +31,7 @@
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% for locale in locales %}
|
||||
{% for locale in locales | sort %}
|
||||
<div class="margin-t-8-px margin-b-4-px margin-r-8-px display-inline-block min-width-120-px">
|
||||
{% if locale in form.locales.attribute.value %}
|
||||
<input type="checkbox" name="locales[]" id="{{ locale }}" value="{{ locale }}" checked="checked" />
|
||||
@ -48,9 +48,42 @@
|
||||
#}
|
||||
</div>
|
||||
<div class="margin-b-16-px border-bottom-default"></div>
|
||||
<div class="margin-y-16-px">
|
||||
<div class="margin-b-8-px">
|
||||
<label for="categories">
|
||||
{{'Content category' | trans }}
|
||||
</label>
|
||||
<sub class="opacity-0 parent-hover-opacity-09" title="{{ 'This torrent have selected categories' | trans }}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" viewBox="0 0 16 16">
|
||||
<path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"/>
|
||||
</svg>
|
||||
</sub>
|
||||
{% for error in form.categories.error %}
|
||||
<div class="text-color-red margin-y-8-px">
|
||||
{{ error }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% for category in categories | sort %}
|
||||
<div class="margin-t-8-px margin-b-4-px margin-r-8-px display-inline-block min-width-120-px">
|
||||
{% if category in form.categories.attribute.value %}
|
||||
<input type="checkbox" name="categories[]" id="{{ category }}" value="{{ category }}" checked="checked" />
|
||||
{% else %}
|
||||
<input type="checkbox" name="categories[]" id="{{ category }}" value="{{ category }}" />
|
||||
{% endif %}
|
||||
<label class="margin-l-4-px" for="{{ category }}">
|
||||
{{ category | u.title }}
|
||||
</label>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{#
|
||||
{{'Other...'|trans }}
|
||||
#}
|
||||
</div>
|
||||
<div class="margin-b-16-px border-bottom-default"></div>
|
||||
<div>
|
||||
<input type="checkbox" name="sensitive" id="sensitive" value="true" {% if form.sensitive.attribute.value %}checked="checked"{% endif %} />
|
||||
<label for="sensitive">
|
||||
<label class="margin-l-4-px" for="sensitive">
|
||||
{{'Sensitive'|trans }}
|
||||
</label>
|
||||
<sub class="opacity-0 parent-hover-opacity-09" title="{{ 'Mark torrent content as sensitive' | trans }}">
|
||||
|
@ -172,7 +172,15 @@
|
||||
{{ 'Languages' | trans }}
|
||||
</td>
|
||||
<td class="width-80 line-height-20-px">
|
||||
{% for i, locale in user.locales %}{% if i > 0 %},{% endif %} {{ locale|locale_name(locale)|u.title }}{% endfor %}
|
||||
{% for i, locale in user.locales | sort %}{% if i > 0 %},{% endif %} {{ locale | locale_name(locale) | u.title }}{% endfor %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="width-20">
|
||||
{{ 'Categories' | trans }}
|
||||
</td>
|
||||
<td class="width-80 line-height-20-px">
|
||||
{% for i, category in user.categories | sort %}{% if i > 0 %},{% endif %} {{ category | u.title }}{% endfor %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -89,7 +89,7 @@
|
||||
<td class="padding-t-16-px padding-b-8-px">
|
||||
{% for locale in locales %}
|
||||
<div class="margin-t-4-px margin-b-8-px margin-r-8-px display-inline-block min-width-120-px">
|
||||
{% if locale in user.locales %}
|
||||
{% if locale in user.locales | sort %}
|
||||
<input name="locales[]" id="{{ locale }}" type="checkbox" value="{{ locale }}" checked="checked" />
|
||||
{% else %}
|
||||
<input name="locales[]" id="{{ locale }}" type="checkbox" value="{{ locale }}" />
|
||||
@ -102,10 +102,31 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="padding-y-12-px">
|
||||
<td class="padding-y-16-px">
|
||||
<div class="margin-t-4-px">
|
||||
{{ 'Categories' | trans }}
|
||||
</div>
|
||||
</td>
|
||||
<td class="padding-t-16-px padding-b-8-px border-top-default">
|
||||
{% for category in categories | sort %}
|
||||
<div class="margin-t-4-px margin-b-8-px margin-r-8-px display-inline-block min-width-120-px">
|
||||
{% if category in user.categories %}
|
||||
<input name="categories[]" id="{{ category }}" type="checkbox" value="{{ category }}" checked="checked" />
|
||||
{% else %}
|
||||
<input name="categories[]" id="{{ category }}" type="checkbox" value="{{ category }}" />
|
||||
{% endif %}
|
||||
<label class="margin-x-4-px" for="{{ category }}">
|
||||
{{ category | u.title | trans }}
|
||||
</label>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="padding-y-16-px">
|
||||
{{ 'Sensitive' | trans }}
|
||||
</td>
|
||||
<td class="padding-y-12-px border-top-default">
|
||||
<td class="padding-t-16-px padding-b-8-px border-top-default">
|
||||
<div class="margin-r-8-px">
|
||||
{% if user.sensitive %}
|
||||
<input name="sensitive" id="sensitive" type="checkbox" value="true" checked="checked" />
|
||||
|
@ -797,6 +797,38 @@
|
||||
<source>Bottom</source>
|
||||
<target>Bottom</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="uLHYlMa" resname="Categories">
|
||||
<source>Categories</source>
|
||||
<target>Categories</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="R2SmYMn" resname="At least one category required">
|
||||
<source>At least one category required</source>
|
||||
<target>At least one category required</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="QmNxufM" resname="Content category">
|
||||
<source>Content category</source>
|
||||
<target>Content category</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="zRrq72V" resname="This torrent have selected categories">
|
||||
<source>This torrent have selected categories</source>
|
||||
<target>This torrent have selected categories</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="o_ep6hc" resname="Edit categories">
|
||||
<source>Edit categories</source>
|
||||
<target>Edit categories</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2SVm4J_" resname="Edit categories for torrent">
|
||||
<source>Edit categories for torrent</source>
|
||||
<target>Edit categories for torrent</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="yj3GEvR" resname="Locale">
|
||||
<source>Locale</source>
|
||||
<target>Locale</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="KSwG8AR" resname="Category">
|
||||
<source>Category</source>
|
||||
<target>Category</target>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
||||
|
Loading…
x
Reference in New Issue
Block a user