function compare($X, $Y) {
return($Y['count'] - $X['count']);
}
// Build the data for the collage and the torrent list
// TODO: Cache this
$DB->query("
SELECT
ct.GroupID,
ct.UserID
FROM collages_torrents AS ct
JOIN torrents_group AS tg ON tg.ID = ct.GroupID
WHERE ct.CollageID = '$CollageID'
ORDER BY ct.Sort");
$GroupIDs = $DB->collect('GroupID');
$Contributors = $DB->to_pair('GroupID', 'UserID', false);
if (count($GroupIDs) > 0) {
$TorrentList = Torrents::get_groups($GroupIDs);
$UserVotes = Votes::get_user_votes($LoggedUser['ID']);
} else {
$TorrentList = array();
}
// Loop through the result set, building up $Collage and $TorrentTable
// Then we print them.
$Collage = array();
$TorrentTable = '';
$NumGroups = count($TorrentList);
$NumGroupsByUser = 0;
$TopArtists = array();
$UserAdditions = array();
$Number = 0;
foreach ($GroupIDs as $GroupID) {
if (!isset($TorrentList[$GroupID])) {
continue;
}
$Group = $TorrentList[$GroupID];
extract(Torrents::array_group($Group));
$UserID = $Contributors[$GroupID];
$TorrentTags = new Tags($TagList);
// Handle stats and stuff
$Number++;
if ($UserID == $LoggedUser['ID']) {
$NumGroupsByUser++;
}
if (!empty($ExtendedArtists[1])
|| !empty($ExtendedArtists[4])
|| !empty($ExtendedArtists[5])
|| !empty($ExtendedArtists[6])
) {
$CountArtists = array_merge((array)$ExtendedArtists[1], (array)$ExtendedArtists[4], (array)$ExtendedArtists[5], (array)$ExtendedArtists[6]);
} else {
$CountArtists = $GroupArtists;
}
if ($CountArtists) {
foreach ($CountArtists as $Artist) {
if (!isset($TopArtists[$Artist['id']])) {
$TopArtists[$Artist['id']] = array('name' => $Artist['name'], 'count' => 1);
} else {
$TopArtists[$Artist['id']]['count']++;
}
}
}
if (!isset($UserAdditions[$UserID])) {
$UserAdditions[$UserID] = 0;
}
$UserAdditions[$UserID]++;
$DisplayName = "$Number - ";
if (!empty($ExtendedArtists[1])
|| !empty($ExtendedArtists[4])
|| !empty($ExtendedArtists[5])
|| !empty($ExtendedArtists[6])
) {
unset($ExtendedArtists[2]);
unset($ExtendedArtists[3]);
$DisplayName .= Artists::display_artists($ExtendedArtists);
} elseif (count($GroupArtists) > 0) {
$DisplayName .= Artists::display_artists(array('1' => $GroupArtists));
}
$DisplayName .= "$GroupName";
if ($GroupYear > 0) {
$DisplayName = "$DisplayName [$GroupYear]";
}
if ($GroupVanityHouse) {
$DisplayName .= ' [VH]';
}
$SnatchedGroupClass = ($GroupFlags['IsSnatched'] ? ' snatched_group' : '');
$UserVote = isset($UserVotes[$GroupID]) ? $UserVotes[$GroupID]['Type'] : '';
// Start an output buffer, so we can store this output in $TorrentTable
ob_start();
if (count($Torrents) > 1 || $GroupCategoryID == 1) {
// Grouped torrents
$ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] == 1);
?>
|
|
=$DisplayName?>
if (Bookmarks::has_bookmarked('torrent', $GroupID)) { ?>
Remove bookmark
} else { ?>
Bookmark
}
Votes::vote_link($GroupID, $UserVote);
?>
=$TorrentTags->format()?>
|
$LastRemasterYear = '-';
$LastRemasterTitle = '';
$LastRemasterRecordLabel = '';
$LastRemasterCatalogueNumber = '';
$LastMedia = '';
$EditionID = 0;
unset($FirstUnknown);
foreach ($Torrents as $TorrentID => $Torrent) {
if ($Torrent['Remastered'] && !$Torrent['RemasterYear']) {
$FirstUnknown = !isset($FirstUnknown);
}
$SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : '';
if ($Torrent['RemasterTitle'] != $LastRemasterTitle
|| $Torrent['RemasterYear'] != $LastRemasterYear
|| $Torrent['RemasterRecordLabel'] != $LastRemasterRecordLabel
|| $Torrent['RemasterCatalogueNumber'] != $LastRemasterCatalogueNumber
|| $FirstUnknown
|| $Torrent['Media'] != $LastMedia
) {
$EditionID++;
?>
− =Torrents::edition_string($Torrent, $Group)?> |
}
$LastRemasterTitle = $Torrent['RemasterTitle'];
$LastRemasterYear = $Torrent['RemasterYear'];
$LastRemasterRecordLabel = $Torrent['RemasterRecordLabel'];
$LastRemasterCatalogueNumber = $Torrent['RemasterCatalogueNumber'];
$LastMedia = $Torrent['Media'];
?>
DL
if (Torrents::can_use_token($Torrent)) { ?>
| FL
} ?>
| RP
» =Torrents::torrent_info($Torrent)?>
|
=Format::get_size($Torrent['Size'])?> |
=number_format($Torrent['Snatched'])?> |
=number_format($Torrent['Seeders'])?> |
=number_format($Torrent['Leechers'])?> |
}
} else {
// Viewing a type that does not require grouping
list($TorrentID, $Torrent) = each($Torrents);
$DisplayName = "$GroupName";
if ($Torrent['IsSnatched']) {
$DisplayName .= ' ' . Format::torrent_label('Snatched!');
}
if ($Torrent['FreeTorrent'] == '1') {
$DisplayName .= ' ' . Format::torrent_label('Freeleech!');
} elseif ($Torrent['FreeTorrent'] == '2') {
$DisplayName .= ' ' . Format::torrent_label('Neutral Leech!');
} elseif ($Torrent['PersonalFL']) {
$DisplayName .= ' ' . Format::torrent_label('Personal Freeleech!');
}
$SnatchedTorrentClass = ($Torrent['IsSnatched'] ? ' snatched_torrent' : '');
?>
|
|
DL
if (Torrents::can_use_token($Torrent)) { ?>
| FL
} ?>
| RP
=$DisplayName?>
Votes::vote_link($GroupID, $UserVote); ?>
=$TorrentTags->format()?>
|
=Format::get_size($Torrent['Size'])?> |
=number_format($Torrent['Snatched'])?> |
=number_format($Torrent['Seeders'])?> |
=number_format($Torrent['Leechers'])?> |
}
$TorrentTable .= ob_get_clean();
// Album art
ob_start();
$DisplayName = '';
if (!empty($ExtendedArtists[1])
|| !empty($ExtendedArtists[4])
|| !empty($ExtendedArtists[5])
|| !empty($ExtendedArtists[6])
) {
unset($ExtendedArtists[2]);
unset($ExtendedArtists[3]);
$DisplayName .= Artists::display_artists($ExtendedArtists, false);
} elseif (count($GroupArtists) > 0) {
$DisplayName .= Artists::display_artists(array('1' => $GroupArtists), false);
}
$DisplayName .= $GroupName;
if ($GroupYear > 0) {
$DisplayName = "$DisplayName [$GroupYear]";
}
$Tags = display_str($TorrentTags->format());
$PlainTags = implode(', ', $TorrentTags->get_tags());
?>
if ($WikiImage) { ?>
" width="118" />
} else { ?>
=$DisplayName?>
} ?>
$Collage[] = ob_get_clean();
}
if ($CollageCategoryID === '0' && !check_perms('site_collages_delete')) {
if (!check_perms('site_collages_personal') || $CreatorID !== $LoggedUser['ID']) {
$PreventAdditions = true;
}
}
if (!check_perms('site_collages_delete')
&& (
$Locked
|| ($MaxGroups > 0 && $NumGroups >= $MaxGroups)
|| ($MaxGroupsPerUser > 0 && $NumGroupsByUser >= $MaxGroupsPerUser)
)
) {
$PreventAdditions = true;
}
// Silly hack for people who are on the old setting
$CollageCovers = isset($LoggedUser['CollageCovers']) ? $LoggedUser['CollageCovers'] : 25 * (abs($LoggedUser['HideCollage'] - 1));
$CollagePages = array();
// Pad it out
if ($NumGroups > $CollageCovers) {
for ($i = $NumGroups + 1; $i <= ceil($NumGroups / $CollageCovers) * $CollageCovers; $i++) {
$Collage[] = '';
}
}
for ($i = 0; $i < $NumGroups / $CollageCovers; $i++) {
$Groups = array_slice($Collage, $i * $CollageCovers, $CollageCovers);
$CollagePage = '';
foreach ($Groups as $Group) {
$CollagePage .= $Group;
}
$CollagePages[] = $CollagePage;
}
View::show_header($Name, 'browse,collage,bbcode,voting,recommend');
?>
/* Misc::display_recommend($CollageID, "collage"); */ ?>
if ($CollageCovers != 0) { ?>
Cover Art
$Page1 = array_slice($Collage, 0, $CollageCovers);
foreach ($Page1 as $Group) {
echo $Group;
}
?>
if ($NumGroups > $CollageCovers) { ?>
}
}
?>
|
|
Torrents |
Size |
|
|
|
=$TorrentTable?>
View::show_footer();
?>
Report