mirror of
https://github.com/OPSnet/Gazelle.git
synced 2026-01-16 18:04:34 -05:00
bookmark objects not ids
This commit is contained in:
@@ -90,7 +90,7 @@ class Feed extends Base {
|
||||
public function bookmark(User $user, string $feedName): string {
|
||||
return $this->wrap(
|
||||
$this->channel(
|
||||
'Bookmarked torrent notifications',
|
||||
'Bookmarked Torrent Notifications',
|
||||
'RSS feed for bookmarked torrents'
|
||||
)
|
||||
. $this->retrieve($user, $feedName)
|
||||
|
||||
@@ -21,15 +21,15 @@ class Artist extends \Gazelle\Json {
|
||||
|
||||
public function payload(): array {
|
||||
$artist = $this->artist;
|
||||
$artistId = $artist->id();
|
||||
$artistId = $artist->id;
|
||||
$artist->loadArtistRole();
|
||||
$GroupIDs = $artist->groupIds();
|
||||
$tgroupIds = $artist->groupIds();
|
||||
|
||||
$JsonTorrents = [];
|
||||
$Tags = [];
|
||||
|
||||
foreach ($GroupIDs as $GroupID) {
|
||||
$tgroup = $this->tgMan->findById($GroupID);
|
||||
foreach ($tgroupIds as $tgroupId) {
|
||||
$tgroup = $this->tgMan->findById($tgroupId);
|
||||
if (is_null($tgroup)) {
|
||||
continue;
|
||||
}
|
||||
@@ -57,8 +57,8 @@ class Artist extends \Gazelle\Json {
|
||||
}
|
||||
|
||||
$InnerTorrents[] = [
|
||||
'id' => $torrent->id(),
|
||||
'groupId' => $GroupID,
|
||||
'id' => $torrent->id,
|
||||
'groupId' => $tgroupId,
|
||||
'media' => $torrent->media(),
|
||||
'format' => $torrent->format(),
|
||||
'encoding' => $torrent->encoding(),
|
||||
@@ -77,11 +77,11 @@ class Artist extends \Gazelle\Json {
|
||||
'seeders' => $torrent->seederTotal(),
|
||||
'snatched' => $torrent->snatchTotal(),
|
||||
'time' => $torrent->created(),
|
||||
'hasFile' => $torrent->id(), /* legacy wtf */
|
||||
'hasFile' => $torrent->id, /* legacy wtf */
|
||||
];
|
||||
}
|
||||
$JsonTorrents[] = [
|
||||
'groupId' => $GroupID,
|
||||
'groupId' => $tgroupId,
|
||||
'groupName' => $tgroup->name(),
|
||||
'groupYear' => $tgroup->year(),
|
||||
'groupRecordLabel' => $tgroup->recordLabel(),
|
||||
@@ -91,7 +91,7 @@ class Artist extends \Gazelle\Json {
|
||||
'releaseType' => (int)$tgroup->releaseType(),
|
||||
'wikiImage' => $tgroup->image(),
|
||||
'groupVanityHouse' => $tgroup->isShowcase(),
|
||||
'hasBookmarked' => $this->bookmark->isTorrentBookmarked($GroupID),
|
||||
'hasBookmarked' => $this->bookmark->isTGroupBookmarked($tgroup),
|
||||
'artists' => $artists,
|
||||
'extendedArtists' => $tgroup->artistRole()->legacyList(),
|
||||
'torrent' => $InnerTorrents,
|
||||
@@ -112,7 +112,7 @@ class Artist extends \Gazelle\Json {
|
||||
if (!$this->user->disableRequests()) {
|
||||
$requestList = array_map(
|
||||
fn ($r) => [
|
||||
'requestId' => $r->id(),
|
||||
'requestId' => $r->id,
|
||||
'categoryId' => $r->categoryId(),
|
||||
'title' => $r->title(),
|
||||
'year' => $r->year(),
|
||||
@@ -128,7 +128,7 @@ class Artist extends \Gazelle\Json {
|
||||
'id' => $artistId,
|
||||
'name' => $artist->name(),
|
||||
'notificationsEnabled' => $this->user->hasArtistNotification($artist->name()),
|
||||
'hasBookmarked' => $this->bookmark->isArtistBookmarked($artistId),
|
||||
'hasBookmarked' => $this->bookmark->isArtistBookmarked($artist),
|
||||
'image' => $artist->image(),
|
||||
'body' => \Text::full_format($artist->body()),
|
||||
'bodyBbcode' => $artist->body(),
|
||||
|
||||
@@ -40,7 +40,7 @@ class Collage extends \Gazelle\Json {
|
||||
$entryList = $this->collage->entryList();
|
||||
return array_merge(
|
||||
[
|
||||
'id' => $this->collage->id(),
|
||||
'id' => $this->collage->id,
|
||||
'name' => $this->collage->name(),
|
||||
'description' => \Text::full_format($this->collage->description()),
|
||||
'description_raw' => $this->collage->description(),
|
||||
@@ -51,7 +51,7 @@ class Collage extends \Gazelle\Json {
|
||||
'locked' => $this->collage->isLocked(),
|
||||
'maxGroups' => $this->collage->maxGroups(),
|
||||
'maxGroupsPerUser' => $this->collage->maxGroupsPerUser(),
|
||||
'hasBookmarked' => new \Gazelle\User\Bookmark($this->user)->isCollageBookmarked($this->collage->id()),
|
||||
'hasBookmarked' => new \Gazelle\User\Bookmark($this->user)->isCollageBookmarked($this->collage),
|
||||
'subscriberCount' => $this->collage->numSubscribers(),
|
||||
'torrentGroupIDList' => $entryList,
|
||||
'pages' => $this->collage->isArtist() ? 1 : ceil(count($entryList) / static::$ENTRIES_PER_PAGE),
|
||||
|
||||
@@ -20,7 +20,7 @@ class Request extends \Gazelle\Json {
|
||||
return [
|
||||
...$request->ajaxInfo(),
|
||||
'requestorName' => $user->username(),
|
||||
'isBookmarked' => $this->bookmark->isRequestBookmarked($request->id()),
|
||||
'isBookmarked' => $this->bookmark->isRequestBookmarked($request),
|
||||
'requestTax' => REQUEST_TAX,
|
||||
'canEdit' => $request->canEdit($this->viewer),
|
||||
'canVote' => $request->canVote($this->viewer),
|
||||
|
||||
@@ -18,7 +18,7 @@ class TGroup extends \Gazelle\Json {
|
||||
'wikiBBcode' => $tgroup->description(),
|
||||
'wikiImage' => $tgroup->image(),
|
||||
'proxyImage' => image_cache_encode($tgroup->image()),
|
||||
'id' => $tgroup->id(),
|
||||
'id' => $tgroup->id,
|
||||
'name' => $tgroup->name(),
|
||||
'year' => $tgroup->year(),
|
||||
'recordLabel' => $tgroup->recordLabel() ?? '',
|
||||
@@ -29,7 +29,7 @@ class TGroup extends \Gazelle\Json {
|
||||
'categoryName' => $tgroup->categoryName(),
|
||||
'time' => $tgroup->time(),
|
||||
'vanityHouse' => $tgroup->isShowcase(),
|
||||
'isBookmarked' => new \Gazelle\User\Bookmark($this->user)->isTorrentBookmarked($tgroup->id()),
|
||||
'isBookmarked' => new \Gazelle\User\Bookmark($this->user)->isTGroupBookmarked($tgroup),
|
||||
'tags' => array_values($tgroup->tagNameList()),
|
||||
'musicInfo' => $musicInfo,
|
||||
];
|
||||
|
||||
@@ -47,7 +47,7 @@ class TGroupList extends \Gazelle\Json {
|
||||
$prev = $current;
|
||||
|
||||
$groupList[] = [
|
||||
'torrentId' => $torrent->id(),
|
||||
'torrentId' => $torrent->id,
|
||||
'editionId' => $EditionID,
|
||||
'artists' => $tgroup->artistRole()->roleList()['main'],
|
||||
'remastered' => $torrent->isRemastered(),
|
||||
@@ -83,7 +83,7 @@ class TGroupList extends \Gazelle\Json {
|
||||
'artist' => $tgroup->artistName(),
|
||||
'cover' => $tgroup->image(),
|
||||
'tags' => array_values($tgroup->tagNameList()),
|
||||
'bookmarked' => $this->bookmark->isTorrentBookmarked($tgroup->id()),
|
||||
'bookmarked' => $this->bookmark->isTGroupBookmarked($tgroup),
|
||||
'vanityHouse' => $tgroup->isShowcase(),
|
||||
'groupYear' => $tgroup->year(),
|
||||
'releaseType' => $tgroup->releaseTypeName() ?? '',
|
||||
@@ -108,7 +108,7 @@ class TGroupList extends \Gazelle\Json {
|
||||
$list[] = [
|
||||
'groupId' => $tgroupId,
|
||||
'groupName' => $tgroup->name(),
|
||||
'torrentId' => $torrent->id(),
|
||||
'torrentId' => $torrent->id,
|
||||
'tags' => array_values($tgroup->tagNameList()),
|
||||
'category' => $tgroup->categoryName(),
|
||||
'fileCount' => $torrent->fileTotal(),
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
|
||||
namespace Gazelle\User;
|
||||
|
||||
use Gazelle\Artist;
|
||||
use Gazelle\Collage;
|
||||
use Gazelle\Request;
|
||||
use Gazelle\TGroup;
|
||||
|
||||
class Bookmark extends \Gazelle\BaseUser {
|
||||
final public const tableName = 'pm_conversations_users'; // not really
|
||||
|
||||
@@ -134,29 +139,29 @@ class Bookmark extends \Gazelle\BaseUser {
|
||||
/**
|
||||
* Check if an artist is bookmarked by a user
|
||||
*/
|
||||
public function isArtistBookmarked(int $artistId): bool {
|
||||
return in_array($artistId, $this->allBookmarks('artist'));
|
||||
public function isArtistBookmarked(Artist $artist): bool {
|
||||
return in_array($artist->id, $this->allBookmarks('artist'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a collage is bookmarked by a user
|
||||
*/
|
||||
public function isCollageBookmarked(int $collageId): bool {
|
||||
return in_array($collageId, $this->allBookmarks('collage'));
|
||||
public function isCollageBookmarked(Collage $collage): bool {
|
||||
return in_array($collage->id, $this->allBookmarks('collage'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a request is bookmarked by a user
|
||||
*/
|
||||
public function isRequestBookmarked(int $requestId): bool {
|
||||
return in_array($requestId, $this->allBookmarks('request'));
|
||||
public function isRequestBookmarked(Request $request): bool {
|
||||
return in_array($request, $this->allBookmarks('request'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an torrent is bookmarked by a user
|
||||
*/
|
||||
public function isTorrentBookmarked(int $tgroupId): bool {
|
||||
return in_array($tgroupId, $this->allBookmarks('torrent'));
|
||||
public function isTGroupBookmarked(TGroup $tgroup): bool {
|
||||
return in_array($tgroup->id, $this->allBookmarks('torrent'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,7 +186,9 @@ class Bookmark extends \Gazelle\BaseUser {
|
||||
return $bookmarkList;
|
||||
}
|
||||
|
||||
public function torrentArtistLeaderboard(\Gazelle\Manager\Artist $artistMan): array {
|
||||
public function tgroupArtistLeaderboard(
|
||||
\Gazelle\Manager\Artist $artistMan = new \Gazelle\Manager\Artist(),
|
||||
): array {
|
||||
self::$db->prepared_query("
|
||||
SELECT aa.ArtistID AS id,
|
||||
count(*) AS total
|
||||
@@ -206,7 +213,7 @@ class Bookmark extends \Gazelle\BaseUser {
|
||||
return $list;
|
||||
}
|
||||
|
||||
public function torrentArtistTotal(): int {
|
||||
public function tgroupArtistTotal(): int {
|
||||
return (int)self::$db->scalar("
|
||||
SELECT count(*) AS total
|
||||
FROM bookmarks_torrents b
|
||||
@@ -216,7 +223,7 @@ class Bookmark extends \Gazelle\BaseUser {
|
||||
);
|
||||
}
|
||||
|
||||
public function torrentTagLeaderboard(): array {
|
||||
public function tgroupTagLeaderboard(): array {
|
||||
self::$db->prepared_query("
|
||||
SELECT t.Name AS name,
|
||||
count(*) AS total
|
||||
@@ -261,7 +268,7 @@ class Bookmark extends \Gazelle\BaseUser {
|
||||
* Returns an array of torrent bookmarks
|
||||
* @return array containing [group_id, seq, added, torrent_id]
|
||||
*/
|
||||
public function torrentList(int $limit, int $offset): array {
|
||||
public function tgroupList(int $limit, int $offset): array {
|
||||
self::$db->prepared_query("
|
||||
SELECT b.GroupID AS tgroup_id,
|
||||
b.Sort AS seq,
|
||||
|
||||
@@ -17,7 +17,7 @@ if (is_null($artist)) {
|
||||
Error404::error();
|
||||
}
|
||||
$artist->loadArtistRole();
|
||||
$artistId = $artist->id();
|
||||
$artistId = $artist->id;
|
||||
|
||||
$bookmark = new User\Bookmark($Viewer);
|
||||
$collageMan = new Manager\Collage();
|
||||
@@ -39,7 +39,7 @@ if (count($artist->groupIds()) > 1000) {
|
||||
|
||||
echo $Twig->render('artist/header.twig', [
|
||||
'artist' => $artist,
|
||||
'is_bookmarked' => $bookmark->isArtistBookmarked($artist->id()),
|
||||
'is_bookmarked' => $bookmark->isArtistBookmarked($artist),
|
||||
'is_subscribed' => $isSubscribed,
|
||||
'revision_id' => $revisionId,
|
||||
'viewer' => $Viewer,
|
||||
@@ -247,7 +247,7 @@ if ($sections = $artist->sections()) {
|
||||
echo $Twig->render('bookmark/action.twig', [
|
||||
'class' => 'torrent',
|
||||
'id' => $groupId,
|
||||
'is_bookmarked' => $bookmark->isTorrentBookmarked($groupId),
|
||||
'is_bookmarked' => $bookmark->isTGroupBookmarked($tgroup),
|
||||
]);
|
||||
|
||||
if (!$Viewer->option('NoVoteLinks')) {
|
||||
|
||||
@@ -38,13 +38,13 @@ $collMan = new Manager\Collage()->setImageProxy(new Util\ImageProxy($Viewer));
|
||||
$paginator = new Util\Paginator(200, (int)($_GET['page'] ?? 1));
|
||||
$paginator->setTotal($bookmark->torrentTotal());
|
||||
|
||||
$bookmarkList = $bookmark->torrentList($paginator->limit(), $paginator->offset());
|
||||
$bookmarkList = $bookmark->tgroupList($paginator->limit(), $paginator->offset());
|
||||
$NumGroups = count($bookmarkList);
|
||||
$artistLeaderboard = $bookmark->torrentArtistLeaderboard(new Manager\Artist());
|
||||
$tagLeaderboard = $bookmark->torrentTagLeaderboard();
|
||||
$artistLeaderboard = $bookmark->tgroupArtistLeaderboard();
|
||||
$tagLeaderboard = $bookmark->tgroupTagLeaderboard();
|
||||
$CollageCovers = (int)($Viewer->option('CollageCovers') ?? 25);
|
||||
|
||||
View::show_header($user->username() . " › Bookmarked torrent groups", ['js' => 'browse,collage']);
|
||||
View::show_header($user->username() . " › Bookmarked Torrent Groups", ['js' => 'browse,collage']);
|
||||
?>
|
||||
<div class="thin">
|
||||
<div class="header">
|
||||
@@ -56,10 +56,10 @@ if ($ownProfile) {
|
||||
<a href="feeds.php?feed=<?= $feed
|
||||
?>&passkey=<?= $Viewer->announceKey()
|
||||
?>&auth=<?= $Viewer->rssAuth($feed)
|
||||
?>&name=<?= urlencode(SITE_NAME . ': Bookmarked Torrents')
|
||||
?>&name=<?= urlencode(SITE_NAME . ': Bookmarked Torrent Groups')
|
||||
?>"><img src="<?=STATIC_SERVER?>/common/symbols/rss.png" alt="RSS feed" /></a>
|
||||
<?php } ?>
|
||||
<?= $user->link() ?> › Bookmarked torrent groups
|
||||
<?= $user->link() ?> › Bookmarked Torrent Groups
|
||||
</h2>
|
||||
<div class="linkbox">
|
||||
<a href="bookmarks.php?type=torrents" class="brackets">Torrents</a>
|
||||
@@ -90,7 +90,7 @@ if (count($bookmarkList) === 0) { ?>
|
||||
<div class="head"><strong>Stats</strong></div>
|
||||
<ul class="stats nobullet">
|
||||
<li>Torrent groups: <?=$NumGroups?></li>
|
||||
<li>Artists: <?= $bookmark->torrentArtistTotal() ?></li>
|
||||
<li>Artists: <?= $bookmark->tgroupArtistTotal() ?></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="box box_artists">
|
||||
|
||||
@@ -5,16 +5,15 @@ declare(strict_types=1);
|
||||
namespace Gazelle;
|
||||
|
||||
$collageMan = new Manager\Collage();
|
||||
$Collage = $collageMan->findById((int)($_GET['id'] ?? 0));
|
||||
if (is_null($Collage)) {
|
||||
$collage = $collageMan->findById((int)($_GET['id'] ?? 0));
|
||||
if (is_null($collage)) {
|
||||
Error404::error();
|
||||
}
|
||||
|
||||
if ($Collage->isDeleted()) {
|
||||
header("Location: log.php?search=Collage+" . $Collage->id());
|
||||
if ($collage->isDeleted()) {
|
||||
header("Location: log.php?search=Collage+" . $collage->id);
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once $Collage->isArtist() ? 'collage_artists.php' : 'collage_torrent.php';
|
||||
require_once $collage->isArtist() ? 'collage_artists.php' : 'collage_torrent.php';
|
||||
|
||||
View::show_footer();
|
||||
|
||||
@@ -8,14 +8,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace Gazelle;
|
||||
|
||||
/** @var Collage $Collage required from collage.php */
|
||||
$Collage->setViewer($Viewer);
|
||||
$CollageID = $Collage->id();
|
||||
$CollageCovers = (int)($Viewer->option('CollageCovers') ?? 25) * (1 - (int)$Viewer->option('HideCollage'));
|
||||
$CollagePages = [];
|
||||
$NumGroups = $Collage->numEntries();
|
||||
$Artists = $Collage->artistList();
|
||||
$NumGroups = $Collage->numArtists();
|
||||
/** @var Collage $collage required from collage.php */
|
||||
$collage->setViewer($Viewer);
|
||||
$collageCovers = (int)($Viewer->option('CollageCovers') ?? 25) * (1 - (int)$Viewer->option('HideCollage'));
|
||||
$collagePages = [];
|
||||
$Artists = $collage->artistList();
|
||||
$NumGroups = $collage->numArtists();
|
||||
$NumGroupsByUser = 0;
|
||||
$Render = [];
|
||||
$ArtistTable = '';
|
||||
@@ -31,30 +29,30 @@ foreach ($Artists as $id => $Artist) {
|
||||
$Render[] = "<li class=\"image_group_$id\"><a href=\"artist.php?id=$id\">$image</a></li>";
|
||||
}
|
||||
|
||||
if ($CollageCovers) {
|
||||
if ($NumGroups > $CollageCovers) {
|
||||
if ($collageCovers) {
|
||||
if ($NumGroups > $collageCovers) {
|
||||
$Render = array_merge($Render,
|
||||
array_fill(0, $CollageCovers * (int)ceil($NumGroups / $CollageCovers) - $NumGroups, '<li></li>')
|
||||
array_fill(0, $collageCovers * (int)ceil($NumGroups / $collageCovers) - $NumGroups, '<li></li>')
|
||||
);
|
||||
}
|
||||
for ($i = 0; $i < $NumGroups / $CollageCovers; $i++) {
|
||||
$CollagePages[] = implode('', array_slice($Render, $i * $CollageCovers, $CollageCovers));
|
||||
for ($i = 0; $i < $NumGroups / $collageCovers; $i++) {
|
||||
$collagePages[] = implode('', array_slice($Render, $i * $collageCovers, $collageCovers));
|
||||
}
|
||||
}
|
||||
|
||||
echo $Twig->render('collage/header.twig', [
|
||||
'bookmarked' => new User\Bookmark($Viewer)->isCollageBookmarked($CollageID),
|
||||
'collage' => $Collage,
|
||||
'bookmarked' => new User\Bookmark($Viewer)->isCollageBookmarked($collage),
|
||||
'collage' => $collage,
|
||||
'object' => 'artist',
|
||||
'viewer' => $Viewer,
|
||||
]);
|
||||
|
||||
echo $Twig->render('collage/sidebar.twig', [
|
||||
'artists' => 0, // only makes sense for torrent collages
|
||||
'collage' => $Collage,
|
||||
'comments' => new Manager\Comment()->collageSummary($Collage),
|
||||
'contributors' => array_slice($Collage->contributors(), 0, 5, true),
|
||||
'entries' => $Collage->numArtists(),
|
||||
'collage' => $collage,
|
||||
'comments' => new Manager\Comment()->collageSummary($collage),
|
||||
'contributors' => array_slice($collage->contributors(), 0, 5, true),
|
||||
'entries' => $collage->numArtists(),
|
||||
'object' => 'artist',
|
||||
'object_name' => 'artist',
|
||||
'viewer' => $Viewer,
|
||||
@@ -62,32 +60,32 @@ echo $Twig->render('collage/sidebar.twig', [
|
||||
?>
|
||||
</div>
|
||||
<div class="main_column">
|
||||
<?php if ($CollageCovers != 0) { ?>
|
||||
<?php if ($collageCovers != 0) { ?>
|
||||
<div id="coverart" class="box">
|
||||
<div class="head" id="coverhead"><strong>Cover Art</strong></div>
|
||||
<ul class="collage_images" id="collage_page0">
|
||||
<?php
|
||||
$Page1 = array_slice($Render, 0, $CollageCovers);
|
||||
$Page1 = array_slice($Render, 0, $collageCovers);
|
||||
foreach ($Page1 as $Group) {
|
||||
echo $Group;
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php if ($NumGroups > $CollageCovers) { ?>
|
||||
<?php if ($NumGroups > $collageCovers) { ?>
|
||||
<div class="linkbox pager" style="clear: left;" id="pageslinksdiv">
|
||||
<span id="firstpage" class="invisible"><a href="#" class="pageslink" onclick="collageShow.page(0); return false;"><strong>« First</strong></a> | </span>
|
||||
<span id="prevpage" class="invisible"><a href="#" class="pageslink" onclick="collageShow.prevPage(); return false;"><strong>‹ Prev</strong></a> | </span>
|
||||
<?php
|
||||
for ($i = 0; $i < $NumGroups / $CollageCovers; $i++) { ?>
|
||||
<span id="pagelink<?=$i?>" class="<?=($i > 4 ? 'hidden' : '')?><?=($i == 0 ? 'selected' : '')?>"><a href="#" class="pageslink" onclick="collageShow.page(<?=$i?>, this); return false;"><strong><?=$CollageCovers * $i + 1?>-<?=min($NumGroups, $CollageCovers * ($i + 1))?></strong></a><?=(($i != ceil($NumGroups / $CollageCovers) - 1) ? ' | ' : '')?></span>
|
||||
for ($i = 0; $i < $NumGroups / $collageCovers; $i++) { ?>
|
||||
<span id="pagelink<?=$i?>" class="<?=($i > 4 ? 'hidden' : '')?><?=($i == 0 ? 'selected' : '')?>"><a href="#" class="pageslink" onclick="collageShow.page(<?=$i?>, this); return false;"><strong><?=$collageCovers * $i + 1?>-<?=min($NumGroups, $collageCovers * ($i + 1))?></strong></a><?=(($i != ceil($NumGroups / $collageCovers) - 1) ? ' | ' : '')?></span>
|
||||
<?php } ?>
|
||||
<span id="nextbar" class="<?=($NumGroups / $CollageCovers > 5) ? 'hidden' : ''?>"> | </span>
|
||||
<span id="nextbar" class="<?=($NumGroups / $collageCovers > 5) ? 'hidden' : ''?>"> | </span>
|
||||
<span id="nextpage"><a href="#" class="pageslink" onclick="collageShow.nextPage(); return false;"><strong>Next</strong></a> ›</span>
|
||||
<span id="lastpage" class="<?=(ceil($NumGroups / $CollageCovers) == 2 ? 'invisible' : '')?>"> | <a href="#" class="pageslink" onclick="collageShow.page(<?=ceil($NumGroups / $CollageCovers) - 1?>); return false;"><strong>Last »</strong></a></span>
|
||||
<span id="lastpage" class="<?=(ceil($NumGroups / $collageCovers) == 2 ? 'invisible' : '')?>"> | <a href="#" class="pageslink" onclick="collageShow.page(<?=ceil($NumGroups / $collageCovers) - 1?>); return false;"><strong>Last »</strong></a></span>
|
||||
</div>
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
collageShow.init(<?=json_encode($CollagePages)?>);
|
||||
collageShow.init(<?=json_encode($collagePages)?>);
|
||||
//]]></script>
|
||||
<?php
|
||||
}
|
||||
|
||||
@@ -15,34 +15,33 @@ $collMan = new Manager\Collage()->setImageProxy(new \Gazelle\Util\ImagePro
|
||||
$urlStem = new User\Stylesheet($Viewer)->imagePath();
|
||||
$vote = new User\Vote($Viewer);
|
||||
|
||||
/** @var Collage $Collage required from collage.php */
|
||||
/** @var Collage $collage required from collage.php */
|
||||
|
||||
$Collage->setViewer($Viewer);
|
||||
$CollageID = $Collage->id();
|
||||
$CollageCovers = (int)($Viewer->option('CollageCovers') ?? 25) * (1 - (int)$Viewer->option('HideCollage'));
|
||||
$CollagePages = [];
|
||||
$NumGroups = $Collage->numEntries();
|
||||
$collage->setViewer($Viewer);
|
||||
$collageCovers = (int)($Viewer->option('CollageCovers') ?? 25) * (1 - (int)$Viewer->option('HideCollage'));
|
||||
$collagePages = [];
|
||||
$NumGroups = $collage->numEntries();
|
||||
$snatcher = $Viewer->snatch();
|
||||
$entryList = $Collage->entryList();
|
||||
$entryList = $collage->entryList();
|
||||
$groupsClosed = (bool)$Viewer->option('TorrentGrouping');
|
||||
|
||||
echo $Twig->render('collage/header.twig', [
|
||||
'bookmarked' => $bookmark->isCollageBookmarked($CollageID),
|
||||
'collage' => $Collage,
|
||||
'bookmarked' => $bookmark->isCollageBookmarked($collage),
|
||||
'collage' => $collage,
|
||||
'object' => 'torrent',
|
||||
'viewer' => $Viewer,
|
||||
]);
|
||||
|
||||
echo$Twig->render('collage/sidebar.twig', [
|
||||
'artists' => $Collage->numArtists(),
|
||||
'collage' => $Collage,
|
||||
'comments' => new Manager\Comment()->collageSummary($Collage),
|
||||
'contributors' => array_slice($Collage->contributors(), 0, 5, true),
|
||||
'entries' => $Collage->numEntries(),
|
||||
'artists' => $collage->numArtists(),
|
||||
'collage' => $collage,
|
||||
'comments' => new Manager\Comment()->collageSummary($collage),
|
||||
'contributors' => array_slice($collage->contributors(), 0, 5, true),
|
||||
'entries' => $collage->numEntries(),
|
||||
'object' => 'torrent',
|
||||
'object_name' => 'torrent group',
|
||||
'top_artists' => $Collage->topArtists(10),
|
||||
'top_tags' => $Collage->topTags(5),
|
||||
'top_artists' => $collage->topArtists(10),
|
||||
'top_tags' => $collage->topTags(5),
|
||||
'viewer' => $Viewer,
|
||||
]);
|
||||
|
||||
@@ -66,7 +65,7 @@ if ($Viewer->permitted('zip_downloader')) {
|
||||
<form class="download_form" name="zip" action="collages.php" method="post">
|
||||
<input type="hidden" name="action" value="download" />
|
||||
<input type="hidden" name="auth" value="<?=$Viewer->auth()?>" />
|
||||
<input type="hidden" name="collageid" value="<?=$CollageID?>" />
|
||||
<input type="hidden" name="collageid" value="<?= $collage->id ?>" />
|
||||
<ul id="list" class="nobullet">
|
||||
<?php foreach ($ZIPList as $ListItem) { ?>
|
||||
<li id="list<?=$ListItem?>">
|
||||
@@ -116,13 +115,13 @@ echo ' selected="selected"'; } ?>>Prefer Bonus Tracks</option>
|
||||
<?php } /* zip collector */ ?>
|
||||
</div>
|
||||
<div class="main_column">
|
||||
<?php if ($CollageCovers != 0) { ?>
|
||||
<?php if ($collageCovers != 0) { ?>
|
||||
<div id="coverart" class="box">
|
||||
<div class="head" id="coverhead"><strong>Cover Art</strong></div>
|
||||
<ul class="collage_images" id="collage_page0">
|
||||
<?php
|
||||
$Idx = 0;
|
||||
$limit = min($NumGroups, $CollageCovers);
|
||||
$limit = min($NumGroups, $collageCovers);
|
||||
foreach ($entryList as $tgroupId) {
|
||||
$tgroup = $tgMan->findById($tgroupId);
|
||||
if ($tgroup) {
|
||||
@@ -136,22 +135,22 @@ echo ' selected="selected"'; } ?>>Prefer Bonus Tracks</option>
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php if ($NumGroups > $CollageCovers) { ?>
|
||||
<?php if ($NumGroups > $collageCovers) { ?>
|
||||
<div class="linkbox pager" style="clear: left;" id="pageslinksdiv">
|
||||
<span id="firstpage" class="invisible"><a href="#" class="pageslink" onclick="collageShow.page(0); return false;"><strong>« First</strong></a> | </span>
|
||||
<span id="prevpage" class="invisible"><a href="#" class="pageslink" onclick="collageShow.prevPage(); return false;"><strong>‹ Prev</strong></a> | </span>
|
||||
<?php for ($i = 0; $i < $NumGroups / $CollageCovers; $i++) { ?>
|
||||
<span id="pagelink<?=$i?>" class="<?=(($i > 4) ? 'hidden' : '')?><?=(($i == 0) ? 'selected' : '')?>"><a href="#" class="pageslink" onclick="collageShow.page(<?=$i?>, this); return false;"><strong><?=$CollageCovers * $i + 1?>-<?=min($NumGroups, $CollageCovers * ($i + 1))?></strong></a><?=(($i != ceil($NumGroups / $CollageCovers) - 1) ? ' | ' : '')?></span>
|
||||
<?php for ($i = 0; $i < $NumGroups / $collageCovers; $i++) { ?>
|
||||
<span id="pagelink<?=$i?>" class="<?=(($i > 4) ? 'hidden' : '')?><?=(($i == 0) ? 'selected' : '')?>"><a href="#" class="pageslink" onclick="collageShow.page(<?=$i?>, this); return false;"><strong><?=$collageCovers * $i + 1?>-<?=min($NumGroups, $collageCovers * ($i + 1))?></strong></a><?=(($i != ceil($NumGroups / $collageCovers) - 1) ? ' | ' : '')?></span>
|
||||
<?php } ?>
|
||||
<span id="nextbar" class="<?=($NumGroups / $CollageCovers > 5) ? 'hidden' : ''?>"> | </span>
|
||||
<span id="nextbar" class="<?=($NumGroups / $collageCovers > 5) ? 'hidden' : ''?>"> | </span>
|
||||
<span id="nextpage"><a href="#" class="pageslink" onclick="collageShow.nextPage(); return false;"><strong>Next</strong></a> ›</span>
|
||||
<span id="lastpage" class="<?=(ceil($NumGroups / $CollageCovers) == 2 ? 'invisible' : '')?>"> | <a href="#" class="pageslink" onclick="collageShow.page(<?=ceil($NumGroups / $CollageCovers) - 1?>); return false;"><strong>Last »</strong></a></span>
|
||||
<span id="lastpage" class="<?=(ceil($NumGroups / $collageCovers) == 2 ? 'invisible' : '')?>"> | <a href="#" class="pageslink" onclick="collageShow.page(<?=ceil($NumGroups / $collageCovers) - 1?>); return false;"><strong>Last »</strong></a></span>
|
||||
</div>
|
||||
<?php
|
||||
for ($i = 0; $i < $NumGroups / $CollageCovers; $i++) {
|
||||
$chunk = array_slice($entryList, $i * $CollageCovers, $CollageCovers);
|
||||
for ($i = 0; $i < $NumGroups / $collageCovers; $i++) {
|
||||
$chunk = array_slice($entryList, $i * $collageCovers, $collageCovers);
|
||||
if (!empty($chunk)) {
|
||||
$CollagePages[] = implode('',
|
||||
$collagePages[] = implode('',
|
||||
array_map(
|
||||
function ($id) use ($collMan, $tgMan) {
|
||||
$tgroup = $tgMan->findById($id);
|
||||
@@ -161,17 +160,17 @@ echo ' selected="selected"'; } ?>>Prefer Bonus Tracks</option>
|
||||
);
|
||||
}
|
||||
}
|
||||
if ($NumGroups > $CollageCovers) {
|
||||
for ($i = $NumGroups + 1; $i <= ceil($NumGroups / $CollageCovers) * $CollageCovers; $i++) {
|
||||
$CollagePages[count($CollagePages) - 1] .= '<li></li>';
|
||||
if ($NumGroups > $collageCovers) {
|
||||
for ($i = $NumGroups + 1; $i <= ceil($NumGroups / $collageCovers) * $collageCovers; $i++) {
|
||||
$collagePages[count($collagePages) - 1] .= '<li></li>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
collageShow.init(<?=json_encode($CollagePages)?>);
|
||||
collageShow.init(<?=json_encode($collagePages)?>);
|
||||
//]]></script>
|
||||
<?php
|
||||
unset($CollagePages);
|
||||
unset($collagePages);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -226,7 +225,7 @@ foreach ($entryList as $tgroupId) {
|
||||
echo $Twig->render('bookmark/action.twig', [
|
||||
'class' => 'torrent',
|
||||
'id' => $tgroupId,
|
||||
'is_bookmarked' => $bookmark->isTorrentBookmarked($tgroupId),
|
||||
'is_bookmarked' => $bookmark->isTGroupBookmarked($tgroup),
|
||||
]);
|
||||
if (!$Viewer->option('NoVoteLinks') && $Viewer->permitted('site_album_votes')) {
|
||||
?>
|
||||
|
||||
@@ -11,7 +11,7 @@ if (is_null($request)) {
|
||||
Error404::error();
|
||||
}
|
||||
|
||||
$commentPage = new Comment\Request($request->id(), (int)($_GET['page'] ?? 0), (int)($_GET['postid'] ?? 0));
|
||||
$commentPage = new Comment\Request($request->id, (int)($_GET['page'] ?? 0), (int)($_GET['postid'] ?? 0));
|
||||
$commentPage->load()->handleSubscription($Viewer);
|
||||
|
||||
$paginator = new Util\Paginator(TORRENT_COMMENTS_PER_PAGE, $commentPage->pageNum());
|
||||
@@ -35,8 +35,8 @@ echo $Twig->render('request/detail.twig', [
|
||||
'unit_GiB' => isset($unitGiB),
|
||||
'comment_page' => $commentPage,
|
||||
'filler' => $userMan->findById($request->fillerId()),
|
||||
'is_bookmarked' => new User\Bookmark($Viewer)->isRequestBookmarked($request->id()),
|
||||
'is_subscribed' => new User\Subscription($Viewer)->isSubscribedComments('requests', $request->id()),
|
||||
'is_bookmarked' => new User\Bookmark($Viewer)->isRequestBookmarked($request),
|
||||
'is_subscribed' => new User\Subscription($Viewer)->isSubscribedComments('requests', $request->id),
|
||||
'paginator' => $paginator,
|
||||
'reply' => new Util\Textarea('quickpost', '', 90, 8)->setPreviewManual(true),
|
||||
'request' => $request,
|
||||
|
||||
@@ -218,7 +218,7 @@ foreach ($context as $c) {
|
||||
continue;
|
||||
}
|
||||
$tgroup = $torrent->group();
|
||||
$isBookmarked = $bookmark->isTorrentBookmarked($tgroup->id());
|
||||
$isBookmarked = $bookmark->isTGroupBookmarked($tgroup);
|
||||
?>
|
||||
<tr class="torrent row<?=$index % 2 ? 'a' : 'b'?> <?=($isBookmarked ? ' bookmarked' : '')
|
||||
. ($snatcher->showSnatch($torrent) ? ' snatched_torrent' : '')?>">
|
||||
|
||||
@@ -184,7 +184,7 @@ echo ' [' . $tgroup->year() . ']'; } ?></strong>
|
||||
<?= $Twig->render('bookmark/action.twig', [
|
||||
'class' => 'torrent',
|
||||
'id' => $tgroupId,
|
||||
'is_bookmarked' => $bookmark->isTorrentBookmarked($tgroupId),
|
||||
'is_bookmarked' => $bookmark->isTGroupBookmarked($tgroup),
|
||||
]) ?><br />
|
||||
<span style="white-space: nowrap;">
|
||||
<span class="favoritecount_small tooltip" title="<?=$upVotes . ($upVotes == 1 ? ' upvote' : ' upvotes')?>"><span id="upvotes"><?=number_format($upVotes)?></span> <span class="vote_album_up">▲</span></span>
|
||||
|
||||
@@ -165,7 +165,7 @@ foreach ($Results as $Key => $GroupID) {
|
||||
if ($GroupResults && (count($torrentList) > 1 || $tgroup->categoryGrouped())) {
|
||||
?>
|
||||
<tr class="group groupid_<?=$GroupID?>_header<?=$SnatchedGroupClass?>">
|
||||
<?= $Twig->render('tgroup/collapse-tgroup.twig', [ 'closed' => $groupsClosed, 'id' => $tgroup->id() ]) ?>
|
||||
<?= $Twig->render('tgroup/collapse-tgroup.twig', ['closed' => $groupsClosed, 'id' => $tgroup->id]) ?>
|
||||
<td class="center cats_col">
|
||||
<div title="<?= $tgroup->primaryTag() ?>" class="tooltip <?= $tgroup->categoryCss() ?> <?= $tgroup->primaryTagCss() ?>">
|
||||
</div>
|
||||
@@ -181,8 +181,8 @@ foreach ($Results as $Key => $GroupID) {
|
||||
<span style="float: right">
|
||||
<?= $Twig->render('bookmark/action.twig', [
|
||||
'class' => 'torrent',
|
||||
'id' => $tgroup->id(),
|
||||
'is_bookmarked' => $bookmark->isTorrentBookmarked($tgroup->id()),
|
||||
'id' => $tgroup->id,
|
||||
'is_bookmarked' => $bookmark->isTGroupBookmarked($tgroup),
|
||||
]) ?>
|
||||
</span>
|
||||
<br />
|
||||
@@ -203,9 +203,9 @@ foreach ($Results as $Key => $GroupID) {
|
||||
<td class="td_leechers number_column m_td_right"><?=number_format($tgroup->stats()->leechTotal())?></td>
|
||||
</tr>
|
||||
<?php
|
||||
$prev = '';
|
||||
$EditionID = 0;
|
||||
$UnknownCounter = 0;
|
||||
$prev = '';
|
||||
$EditionID = 0;
|
||||
$UnknownCounter = 0;
|
||||
$prevPrimaryTotal = null;
|
||||
|
||||
foreach ($torrentList as $torrentId) {
|
||||
@@ -222,7 +222,7 @@ foreach ($Results as $Key => $GroupID) {
|
||||
$EditionID++;
|
||||
|
||||
?>
|
||||
<tr class="group_torrent groupid_<?=$tgroup->id()?> edition<?=$SnatchedGroupClass . ($groupsClosed ? ' hidden' : '')?>">
|
||||
<tr class="group_torrent groupid_<?=$tgroup->id?> edition<?=$SnatchedGroupClass . ($groupsClosed ? ' hidden' : '')?>">
|
||||
<td colspan="<?= $Viewer->ordinal()->value('file-count-display') ? 9 : 8 ?>" class="edition_info">
|
||||
<?= $Twig->render('torrent/edition-header.twig', [
|
||||
'edition_id' => $EditionID,
|
||||
@@ -236,7 +236,7 @@ foreach ($Results as $Key => $GroupID) {
|
||||
$prev = $current;
|
||||
$SnatchedTorrentClass = $snatcher->showSnatch($torrent) ? ' snatched_torrent' : '';
|
||||
?>
|
||||
<tr class="group_torrent groupid_<?=$tgroup->id()?> edition_<?=$EditionID?><?=$SnatchedTorrentClass . $SnatchedGroupClass . ($groupsClosed ? ' hidden' : '')?>">
|
||||
<tr class="group_torrent groupid_<?=$tgroup->id?> edition_<?=$EditionID?><?=$SnatchedTorrentClass . $SnatchedGroupClass . ($groupsClosed ? ' hidden' : '')?>">
|
||||
<td class="td_info" colspan="3">
|
||||
<?= $Twig->render('torrent/action-v2.twig', [
|
||||
'pl' => true,
|
||||
|
||||
@@ -18,7 +18,7 @@ $tgroup = $tgMan->findById((int)($_GET['id'] ?? 0));
|
||||
if (is_null($tgroup)) {
|
||||
Error404::error();
|
||||
}
|
||||
$tgroupId = $tgroup->id();
|
||||
$tgroupId = $tgroup->id;
|
||||
$RevisionID = (int)($_GET['revisionid'] ?? 0);
|
||||
|
||||
// Comments (must be loaded before View::show_header so that subscriptions and quote notifications are handled properly)
|
||||
@@ -59,7 +59,7 @@ $section = [
|
||||
];
|
||||
|
||||
echo $Twig->render('torrent/detail-header.twig', [
|
||||
'is_bookmarked' => new User\Bookmark($Viewer)->isTorrentBookmarked($tgroup->id()),
|
||||
'is_bookmarked' => new User\Bookmark($Viewer)->isTGroupBookmarked($tgroup),
|
||||
'is_subscribed' => $isSubscribed,
|
||||
'revision_id' => $RevisionID,
|
||||
'tgroup' => $tgroup,
|
||||
@@ -138,7 +138,7 @@ if ($musicRelease) {
|
||||
echo $Twig->render('tgroup/stats.twig', [
|
||||
'collage_list' => $collageMan->addToCollageDefault($tgroup, $Viewer),
|
||||
'featured' => new Manager\FeaturedAlbum()->findById($tgroupId),
|
||||
'tag_undo' => $Cache->get_value("deleted_tags_{$tgroupId}_{$Viewer->id()}"),
|
||||
'tag_undo' => $Cache->get_value("deleted_tags_{$tgroupId}_{$Viewer->id}"),
|
||||
'tgroup' => $tgroup,
|
||||
'viewer' => $Viewer,
|
||||
'vote' => $vote,
|
||||
|
||||
@@ -21,7 +21,7 @@ if ($Viewer->permitted('users_mod') && (int)($_GET['userid'] ?? 0)) {
|
||||
$user = $Viewer;
|
||||
}
|
||||
$UserID = $user->id;
|
||||
$ownProfile = $UserID === $Viewer->id();
|
||||
$ownProfile = $UserID === $Viewer->id;
|
||||
|
||||
$imgTag = '<img loading="lazy" src="' . new User\Stylesheet($Viewer)->imagePath()
|
||||
. '%s.png" class="tooltip" alt="%s" title="%s"/>';
|
||||
@@ -113,7 +113,7 @@ View::show_header(($ownProfile ? 'My' : $user->username() . "'s") . ' notificati
|
||||
<?php
|
||||
foreach ($filter['result'] as $result) {
|
||||
$torrent = $result['torrent'];
|
||||
$torrentId = $torrent->id();
|
||||
$torrentId = $torrent->id;
|
||||
$tgroup = $torrent->group();
|
||||
$match = $tgroup->artistRole()?->matchName($filter['filter']->artistList());
|
||||
?>
|
||||
@@ -150,8 +150,8 @@ View::show_header(($ownProfile ? 'My' : $user->username() . "'s") . ' notificati
|
||||
}
|
||||
echo $Twig->render('bookmark/action.twig', [
|
||||
'class' => 'torrent',
|
||||
'id' => $tgroup->id(),
|
||||
'is_bookmarked' => $bookmark->isTorrentBookmarked($tgroup->id()),
|
||||
'id' => $tgroup->id,
|
||||
'is_bookmarked' => $bookmark->isTGroupBookmarked($tgroup),
|
||||
]);
|
||||
?>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{{ header(user.username ~ ' › Bookmarked artists', {'js': 'browse'}) }}
|
||||
{{ header(user.username ~ ' › Bookmarked Artists', {'js': 'browse'}) }}
|
||||
<div class="thin">
|
||||
<div class="header">
|
||||
<h2>{{ user.id|user_url }} › Bookmarked artists</h2>
|
||||
<h2>{{ user.id|user_url }} › Bookmarked Artists</h2>
|
||||
<div class="linkbox">
|
||||
<a href="bookmarks.php?type=torrents" class="brackets">Torrents</a>
|
||||
<a href="bookmarks.php?type=artists" class="brackets">Artists</a>
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
{% from 'macro/form.twig' import autocomplete, checked, selected %}
|
||||
{% set is_bookmark = search.isBookmarkView %}
|
||||
{% if is_bookmark %}
|
||||
{{ header('Bookmarked collages', {'js': 'collage'}) }}
|
||||
{{ header('Bookmarked Collages', {'js': 'collage'}) }}
|
||||
{% else %}
|
||||
{{ header('Browse collages', {'js': 'collage'}) }}
|
||||
{{ header('Browse Collages', {'js': 'collage'}) }}
|
||||
{% endif %}
|
||||
|
||||
<div class="thin">
|
||||
<div class="header">
|
||||
{% if is_bookmark %}
|
||||
<h2>{{ search.userLink|raw }} › Bookmarked collages</h2>
|
||||
<h2>{{ search.userLink|raw }} › Bookmarked Collages</h2>
|
||||
{% else %}
|
||||
{% if search.userLink %}
|
||||
<h2>{{ search.userLink|raw }} › {% if search.isContributor %}Collage contributions{% else %}Collages{% endif %}</h2>
|
||||
@@ -105,7 +105,7 @@
|
||||
{% if viewer.permitted('site_collages_subscribe') %}
|
||||
<a href="userhistory.php?action=subscribed_collages" class="brackets">Subscribed collages</a>
|
||||
{% endif %}
|
||||
<a href="bookmarks.php?type=collages" class="brackets">Bookmarked collages</a>
|
||||
<a href="bookmarks.php?type=collages" class="brackets">Bookmarked Collages</a>
|
||||
<a href="random.php?action=collage" class="brackets">Random collage</a>
|
||||
{% if viewer.permitted('site_collages_recover') %}
|
||||
<a href="collages.php?action=recover" class="brackets">Recover collage</a>
|
||||
|
||||
@@ -51,7 +51,7 @@ Requests
|
||||
{% if viewer.permitted('site_vote') %}
|
||||
<a href="requests.php?type=voted" class="brackets">Requests I've voted on</a>
|
||||
{% endif %}
|
||||
<a href="bookmarks.php?type=requests" class="brackets">Bookmarked requests</a>
|
||||
<a href="bookmarks.php?type=requests" class="brackets">Bookmarked Requests</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if not search.isBookmarkView %}
|
||||
|
||||
@@ -273,8 +273,8 @@ class ArtistTest extends TestCase {
|
||||
'artist-merge-n',
|
||||
);
|
||||
$this->assertNull($manager->findById($old->id), 'art-merge-no-old');
|
||||
$this->assertTrue($userBk->isArtistBookmarked($new->id), 'art-merge-user-bookmarked-new');
|
||||
$this->assertTrue($extraBk->isArtistBookmarked($new->id), 'art-merge-extra-bookmarked-new');
|
||||
$this->assertTrue($userBk->isArtistBookmarked($new), 'art-merge-user-bookmarked-new');
|
||||
$this->assertTrue($extraBk->isArtistBookmarked($new), 'art-merge-extra-bookmarked-new');
|
||||
$this->assertCount(1, $extraBk->artistList(), 'art-merge-extra-bookmarked-list');
|
||||
|
||||
// FIXME: flushed collage objects cannot be refreshed
|
||||
|
||||
@@ -115,6 +115,34 @@ class TGroupTest extends TestCase {
|
||||
$this->assertEquals(2, $this->userList['user']->stats()->uploadTotal(), 'tgroup-user-stats-upload');
|
||||
$this->assertEquals(1, $this->userList['user']->stats()->uniqueGroupTotal(), 'tgroup-user-stats-unique');
|
||||
$this->assertEquals(1, $this->userList['admin']->stats()->uploadTotal(), 'tgroup-user-admin-upload');
|
||||
|
||||
$bookmarker = new User\Bookmark($this->userList['user']);
|
||||
$bookmarker->create('torrent', $this->tgroup->id);
|
||||
$page = $bookmarker->tgroupList(2, 0);
|
||||
$this->assertCount(1, $page, 'bookmark-tgroup-page-total');
|
||||
$this->assertEquals(
|
||||
$this->tgroup->id,
|
||||
$page[0]['tgroup_id'],
|
||||
'bookmark-tgroup-page-item'
|
||||
);
|
||||
// no tags, but verify the SQL works
|
||||
$this->assertCount(
|
||||
0,
|
||||
$bookmarker->tgroupTagLeaderboard(),
|
||||
'bookmark-tag-leaderboard',
|
||||
);
|
||||
$this->assertEquals(
|
||||
1,
|
||||
$bookmarker->removeObject('torrent', $this->tgroup->id),
|
||||
'tgroup-bookmark-user-remove',
|
||||
);
|
||||
|
||||
$bookmarker->create('torrent', $this->tgroup->id);
|
||||
$this->assertEquals(
|
||||
1,
|
||||
$bookmarker->remove(),
|
||||
'tgroup-bookmark-user-all-remove',
|
||||
);
|
||||
}
|
||||
|
||||
public function testTGroupArtist(): void {
|
||||
@@ -435,11 +463,6 @@ class TGroupTest extends TestCase {
|
||||
'tgroup-merge-general'
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
new User\Bookmark($admin)->isTorrentBookmarked($this->tgroup->id),
|
||||
'tgroup-merge-bookmark'
|
||||
);
|
||||
|
||||
// create new vote objects to pick up the state change
|
||||
unset($adminVote);
|
||||
unset($userVote);
|
||||
@@ -529,11 +552,49 @@ class TGroupTest extends TestCase {
|
||||
|
||||
// test increment
|
||||
$total = $stats->bookmarkTotal();
|
||||
$bookmark = new User\Bookmark($this->userList['user']);
|
||||
$bookmark->create('torrent', $this->tgroup->id);
|
||||
$bookmarker = new User\Bookmark($this->userList['user']);
|
||||
$bookmarker->create('torrent', $this->tgroup->id);
|
||||
|
||||
new Stats\TGroups()->refresh();
|
||||
$stats->flush();
|
||||
$this->assertEquals($total + 1, $stats->bookmarkTotal(), 'tgroup-stats-update-bookmark');
|
||||
|
||||
$this->assertTrue(
|
||||
$bookmarker->isTGroupBookmarked($this->tgroup),
|
||||
'tgroup-merge-bookmark',
|
||||
);
|
||||
$list = $bookmarker->tgroupBookmarkList();
|
||||
$this->assertCount(1, $list, 'tgroup-bookmark-user-total');
|
||||
$this->assertEquals(
|
||||
$this->tgroup->id,
|
||||
$list[0]['tgroup_id'],
|
||||
'tgroup-bookmark-user-id',
|
||||
);
|
||||
$this->assertEquals(
|
||||
3,
|
||||
$bookmarker->torrentTotal(),
|
||||
'tgroup-bookmark-tgroup-total',
|
||||
);
|
||||
// artists have not been assigned, but this tests the SQL
|
||||
$this->assertEquals(
|
||||
[],
|
||||
$bookmarker->tgroupArtistLeaderboard(),
|
||||
'tgroup-bookmark-leaderboard',
|
||||
);
|
||||
$this->assertEquals(
|
||||
0,
|
||||
$bookmarker->tgroupArtistTotal(),
|
||||
'tgroup-bookmark-artist-total',
|
||||
);
|
||||
|
||||
Helper::generateTorrentSnatch(
|
||||
new Torrent($this->tgroup->torrentIdList()[0]),
|
||||
$bookmarker->user()
|
||||
);
|
||||
$this->assertEquals(
|
||||
1,
|
||||
$bookmarker->removeSnatched(),
|
||||
'tgroup-bookmark-remove-snatched',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user