diff --git a/app/Feed.php b/app/Feed.php index f85416e8c..e3a44b0b9 100644 --- a/app/Feed.php +++ b/app/Feed.php @@ -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) diff --git a/app/Json/Artist.php b/app/Json/Artist.php index 77b9eed56..ad744dcf4 100644 --- a/app/Json/Artist.php +++ b/app/Json/Artist.php @@ -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(), diff --git a/app/Json/Collage.php b/app/Json/Collage.php index 5758ffe36..98006142e 100644 --- a/app/Json/Collage.php +++ b/app/Json/Collage.php @@ -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), diff --git a/app/Json/Request.php b/app/Json/Request.php index a39a6552b..7e0d27649 100644 --- a/app/Json/Request.php +++ b/app/Json/Request.php @@ -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), diff --git a/app/Json/TGroup.php b/app/Json/TGroup.php index 6a84156df..ff0fac79f 100644 --- a/app/Json/TGroup.php +++ b/app/Json/TGroup.php @@ -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, ]; diff --git a/app/Json/TGroupList.php b/app/Json/TGroupList.php index c3a80e709..bc96c2192 100644 --- a/app/Json/TGroupList.php +++ b/app/Json/TGroupList.php @@ -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(), diff --git a/app/User/Bookmark.php b/app/User/Bookmark.php index f027e092e..c9e26bdd6 100644 --- a/app/User/Bookmark.php +++ b/app/User/Bookmark.php @@ -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, diff --git a/sections/artist/artist.php b/sections/artist/artist.php index 3f0141401..2794e19fd 100644 --- a/sections/artist/artist.php +++ b/sections/artist/artist.php @@ -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')) { diff --git a/sections/bookmarks/torrents.php b/sections/bookmarks/torrents.php index 0d6045b76..0b7d4b0bd 100644 --- a/sections/bookmarks/torrents.php +++ b/sections/bookmarks/torrents.php @@ -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']); ?>
- = $user->link() ?> › Bookmarked torrent groups
+ = $user->link() ?> › Bookmarked Torrent Groups