BioTorrents.de’s version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

artist_collage.php 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. <?php
  2. #declare(strict_types=1);
  3. // todo: Cache this
  4. $DB->query("
  5. SELECT
  6. ca.ArtistID,
  7. ag.Name,
  8. aw.Image,
  9. ca.UserID
  10. FROM collages_artists AS ca
  11. JOIN artists_group AS ag ON ag.ArtistID = ca.ArtistID
  12. LEFT JOIN wiki_artists AS aw ON aw.RevisionID = ag.RevisionID
  13. WHERE ca.CollageID = '$CollageID'
  14. ORDER BY ca.Sort");
  15. $Artists = $DB->to_array('ArtistID', MYSQLI_ASSOC);
  16. // Loop through the result set, building up $Collage and $TorrentTable
  17. // Then we print them.
  18. $Collage = [];
  19. $ArtistTable = '';
  20. $NumGroups = count($Artists);
  21. $NumGroupsByUser = 0;
  22. $UserAdditions = [];
  23. foreach ($Artists as $Artist) {
  24. $UserID = $Artist['UserID'];
  25. if ($UserID === $LoggedUser['ID']) {
  26. $NumGroupsByUser++;
  27. }
  28. if (!isset($UserAdditions[$UserID])) {
  29. $UserAdditions[$UserID] = 0;
  30. }
  31. $UserAdditions[$UserID]++;
  32. ob_start(); ?>
  33. <tr>
  34. <td><a
  35. href="artist.php?id=<?=$Artist['ArtistID']?>"><?=$Artist['Name']?></a></td>
  36. </tr>
  37. <?php
  38. $ArtistTable .= ob_get_clean();
  39. ob_start(); ?>
  40. <li class="image_group_<?=$Artist['ArtistID']?>">
  41. <a
  42. href="artist.php?id=<?=$Artist['ArtistID']?>">
  43. <?php if ($Artist['Image']) { ?>
  44. <img class="tooltip"
  45. src="<?=ImageTools::process($Artist['Image'], 'thumb')?>"
  46. alt="<?=$Artist['Name']?>"
  47. title="<?=$Artist['Name']?>" width="118" />
  48. <?php } else { ?>
  49. <span style="width: 107px; padding: 5px;"><?=$Artist['Name']?></span>
  50. <?php } ?>
  51. </a>
  52. </li>
  53. <?php
  54. $Collage[] = ob_get_clean();
  55. }
  56. if (!check_perms('site_collages_delete') && ($Locked || ($MaxGroups > 0 && $NumGroups >= $MaxGroups) || ($MaxGroupsPerUser > 0 && $NumGroupsByUser >= $MaxGroupsPerUser))) {
  57. $PreventAdditions = true;
  58. }
  59. // Silly hack for people who are on the old setting
  60. $CollageCovers = (isset($LoggedUser['CollageCovers']) ? $LoggedUser['CollageCovers'] : 25 * (abs($LoggedUser['HideCollage'] - 1)));
  61. $CollagePages = [];
  62. // Pad it out
  63. if ($NumGroups > $CollageCovers) {
  64. for ($i = $NumGroups + 1; $i <= ceil($NumGroups / $CollageCovers) * $CollageCovers; $i++) {
  65. $Collage[] = '<li></li>';
  66. }
  67. }
  68. for ($i = 0; $i < $NumGroups / $CollageCovers; $i++) {
  69. $Groups = array_slice($Collage, $i * $CollageCovers, $CollageCovers);
  70. $CollagePage = '';
  71. foreach ($Groups as $Group) {
  72. $CollagePage .= $Group;
  73. }
  74. $CollagePages[] = $CollagePage;
  75. }
  76. View::show_header($Name, 'browse,collage,recommend');
  77. ?>
  78. <div>
  79. <div class="header">
  80. <h2><?=$Name?>
  81. </h2>
  82. <div class="linkbox">
  83. <a href="collages.php" class="brackets">List of collections</a>
  84. <?php if (check_perms('site_collages_create')) { ?>
  85. <a href="collages.php?action=new" class="brackets">New collage</a>
  86. <?php } ?>
  87. <br /><br />
  88. <?php if (check_perms('site_collages_subscribe')) { ?>
  89. <a href="#" id="subscribelink<?=$CollageID?>" class="brackets"
  90. onclick="CollageSubscribe(<?=$CollageID?>); return false;"><?=(in_array($CollageID, $CollageSubscriptions) ? 'Unsubscribe' : 'Subscribe')?></a>
  91. <?php
  92. }
  93. if (check_perms('site_collages_delete') || (check_perms('site_edit_wiki') && !$Locked)) {
  94. ?>
  95. <a href="collages.php?action=edit&amp;collageid=<?=$CollageID?>"
  96. class="brackets">Edit description</a>
  97. <?php
  98. } else { ?>
  99. <span class="brackets">Locked</span>
  100. <?php
  101. }
  102. if (Bookmarks::has_bookmarked('collage', $CollageID)) {
  103. ?>
  104. <a href="#" id="bookmarklink_collage_<?=$CollageID?>"
  105. class="brackets"
  106. onclick="Unbookmark('collage', <?=$CollageID?>, 'Bookmark'); return false;">Remove
  107. bookmark</a>
  108. <?php
  109. } else { ?>
  110. <a href="#" id="bookmarklink_collage_<?=$CollageID?>"
  111. class="brackets"
  112. onclick="Bookmark('collage', <?=$CollageID?>, 'Remove bookmark'); return false;">Bookmark</a>
  113. <?php
  114. }
  115. if (check_perms('site_collages_manage') && !$Locked) {
  116. ?>
  117. <a href="collages.php?action=manage_artists&amp;collageid=<?=$CollageID?>"
  118. class="brackets">Manage artists</a>
  119. <?php
  120. } ?>
  121. <a href="reports.php?action=report&amp;type=collage&amp;id=<?=$CollageID?>"
  122. class="brackets">Report collage</a>
  123. <?php if (check_perms('site_collages_delete') || $CreatorID === $LoggedUser['ID']) { ?>
  124. <a href="collages.php?action=delete&amp;collageid=<?=$CollageID?>&amp;auth=<?=$LoggedUser['AuthKey']?>"
  125. class="brackets" onclick="return confirm('Are you sure you want to delete this collage?');">Delete</a>
  126. <?php } ?>
  127. </div>
  128. </div>
  129. <div class="sidebar">
  130. <div class="box box_category">
  131. <div class="head"><strong>Category</strong></div>
  132. <div class="pad"><a
  133. href="collages.php?action=search&amp;cats[<?=(int)$CollageCategoryID?>]=1"><?=$CollageCats[(int)$CollageCategoryID]?></a></div>
  134. </div>
  135. <div class="box box_description">
  136. <div class="head"><strong>Description</strong></div>
  137. <div class="pad"><?=Text::full_format($Description)?>
  138. </div>
  139. </div>
  140. <div class="box box_info box_statistics_collage_torrents">
  141. <div class="head"><strong>Statistics</strong></div>
  142. <ul class="stats nobullet">
  143. <li>Artists: <?=number_format($NumGroups)?>
  144. </li>
  145. <li>Subscribers: <?=number_format((int)$Subscribers)?>
  146. </li>
  147. <li>Built by <?=number_format(count($UserAdditions))?>
  148. user<?=(count($UserAdditions) > 1 ? 's' : '')?>
  149. </li>
  150. <li>Last updated: <?=time_diff($Updated)?>
  151. </li>
  152. </ul>
  153. </div>
  154. <div class="box box_contributors">
  155. <div class="head"><strong>Top Contributors</strong></div>
  156. <div class="pad">
  157. <ol style="padding-left: 5px;">
  158. <?php
  159. arsort($UserAdditions);
  160. $i = 0;
  161. foreach ($UserAdditions as $UserID => $Additions) {
  162. $i++;
  163. if ($i > 5) {
  164. break;
  165. } ?>
  166. <li><?=Users::format_username($UserID, false, false, false)?>
  167. (<?=number_format($Additions)?>)</li>
  168. <?php
  169. }
  170. ?>
  171. </ol>
  172. </div>
  173. </div>
  174. <?php if (check_perms('site_collages_manage') && !isset($PreventAdditions)) { ?>
  175. <div class="box box_addartist">
  176. <div class="head"><strong>Add Artists</strong><span class="float_right"><a href="#"
  177. onclick="$('.add_artist_container').toggle_class('hidden'); this.innerHTML = (this.innerHTML === 'Batch add' ? 'Individual add' : 'Batch add'); return false;"
  178. class="brackets">Batch add</a></span></div>
  179. <div class="pad add_artist_container">
  180. <form class="add_form" name="artist" action="collages.php" method="post">
  181. <input type="hidden" name="action" value="add_artist" />
  182. <input type="hidden" name="auth"
  183. value="<?=$LoggedUser['AuthKey']?>" />
  184. <input type="hidden" name="collageid"
  185. value="<?=$CollageID?>" />
  186. <div>
  187. <input type="text" id="artist" size="20" name="url" <?php Users::has_autocomplete_enabled('other'); ?>
  188. />
  189. </div>
  190. <div class="submit_div">
  191. <input type="submit" value="Add" />
  192. </div>
  193. <span style="font-style: italic;">Enter the URL of an artist on the site.</span>
  194. </form>
  195. </div>
  196. <div class="pad hidden add_artist_container">
  197. <form class="add_form" name="artists" action="collages.php" method="post">
  198. <input type="hidden" name="action" value="add_artist_batch" />
  199. <input type="hidden" name="auth"
  200. value="<?=$LoggedUser['AuthKey']?>" />
  201. <input type="hidden" name="collageid"
  202. value="<?=$CollageID?>" />
  203. <div>
  204. <textarea name="urls" rows="5" cols="25" style="white-space: nowrap;"></textarea>
  205. </div>
  206. <div class="submit_div">
  207. <input type="submit" value="Add" />
  208. </div>
  209. <span style="font-style: italic;">Enter the URLs of artists on the site, one per line.</span>
  210. </form>
  211. </div>
  212. </div>
  213. <?php } ?>
  214. <h3>Comments</h3>
  215. <?php
  216. if ($CommentList === null) {
  217. $DB->query("
  218. SELECT
  219. c.ID,
  220. c.Body,
  221. c.AuthorID,
  222. um.Username,
  223. c.AddedTime
  224. FROM comments AS c
  225. LEFT JOIN users_main AS um ON um.ID = c.AuthorID
  226. WHERE c.Page = 'collages'
  227. AND c.PageID = $CollageID
  228. ORDER BY c.ID DESC
  229. LIMIT 15");
  230. $CommentList = $DB->to_array(false, MYSQLI_NUM);
  231. }
  232. foreach ($CommentList as $Comment) {
  233. list($CommentID, $Body, $UserID, $Username, $CommentTime) = $Comment; ?>
  234. <div class="box comment">
  235. <div class="head">
  236. <?=Users::format_username($UserID, false, false, false) ?>
  237. <?=time_diff($CommentTime) ?>
  238. <br />
  239. <a href="reports.php?action=report&amp;type=comment&amp;id=<?=$CommentID?>"
  240. class="brackets">Report</a>
  241. </div>
  242. <div class="pad"><?=Text::full_format($Body)?>
  243. </div>
  244. </div>
  245. <?php
  246. }
  247. ?>
  248. <div class="box pad">
  249. <a href="collages.php?action=comments&amp;collageid=<?=$CollageID?>"
  250. class="brackets">View all comments</a>
  251. </div>
  252. <?php
  253. if (!$LoggedUser['DisablePosting']) {
  254. ?>
  255. <div class="box box_addcomment">
  256. <div class="head"><strong>Comment</strong></div>
  257. <form class="send_form" name="comment" id="quickpostform" onsubmit="quickpostform.submit_button.disabled = true;"
  258. action="comments.php" method="post">
  259. <input type="hidden" name="action" value="take_post" />
  260. <input type="hidden" name="page" value="collages" />
  261. <input type="hidden" name="auth"
  262. value="<?=$LoggedUser['AuthKey']?>" />
  263. <input type="hidden" name="pageid" value="<?=$CollageID?>" />
  264. <div class="pad">
  265. <div>
  266. <textarea name="body" cols="24" rows="5"></textarea>
  267. </div>
  268. <div class="submit_div">
  269. <input type="submit" id="submit_button" value="Post" />
  270. </div>
  271. </div>
  272. </form>
  273. </div>
  274. <?php
  275. }
  276. ?>
  277. </div>
  278. <div class="main_column">
  279. <?php
  280. if ($CollageCovers !== 0) {
  281. ?>
  282. <div id="coverart" class="box">
  283. <div class="head" id="coverhead"><strong>Pictures</strong></div>
  284. <ul class="collage_images" id="collage_page0">
  285. <?php
  286. $Page1 = array_slice($Collage, 0, $CollageCovers);
  287. foreach ($Page1 as $Group) {
  288. echo $Group;
  289. } ?>
  290. </ul>
  291. </div>
  292. <?php if ($NumGroups > $CollageCovers) { ?>
  293. <div class="linkbox pager" style="clear: left;" id="pageslinksdiv">
  294. <span id="firstpage" class="invisible">
  295. <a href="#" class="pageslink" onclick="collageShow.page(0, this); return false;">
  296. <strong>&raquo;&nbsp;First</strong>
  297. </a> |
  298. </span>
  299. <span id="prevpage" class="invisible">
  300. <a href="#" class="pageslink" onclick="collageShow.prevPage(); return false;">
  301. <strong>&lsaquo; Prev</strong>
  302. </a> |
  303. </span>
  304. <?php for ($i = 0; $i < $NumGroups / $CollageCovers; $i++) { ?>
  305. <span id="pagelink<?=$i?>"
  306. class="<?=($i > 4 ? 'hidden' : '')?><?=($i === 0 ? 'selected' : '')?>">
  307. <a href="#" class="pageslink"
  308. onclick="collageShow.page(<?=$i?>, this); return false;">
  309. <strong><?=$CollageCovers * $i + 1?>-<?=min($NumGroups, $CollageCovers * ($i + 1))?></strong>
  310. </a>
  311. <?=(($i !== ceil($NumGroups / $CollageCovers) - 1) ? ' | ' : '')?>
  312. </span>
  313. <?php } ?>
  314. <span id="nextbar"
  315. class="<?=($NumGroups / $CollageCovers > 5) ? 'hidden' : ''?>">
  316. | </span>
  317. <span id="nextpage">
  318. <a href="#" class="pageslink" onclick="collageShow.nextPage(); return false;">
  319. <strong>Next &rsaquo;</strong>
  320. </a>
  321. </span>
  322. <span id="lastpage"
  323. class="<?=(ceil($NumGroups / $CollageCovers) === 2 ? 'invisible' : '')?>">
  324. |
  325. <a href="#" class="pageslink"
  326. onclick="collageShow.page(<?=ceil($NumGroups / $CollageCovers) - 1?>, this); return false;">
  327. <strong>Last &raquo;</strong>
  328. </a>
  329. </span>
  330. </div>
  331. <script type="text/javascript">
  332. //<![CDATA[
  333. collageShow.init( <?=json_encode($CollagePages)?> );
  334. //]]>
  335. </script>
  336. <?php
  337. }
  338. }
  339. ?>
  340. <div class="box">
  341. <table class="artist_table grouping cats" id="discog_table">
  342. <tr class="colhead_dark">
  343. <td><strong>Artists</strong></td>
  344. </tr>
  345. <?=$ArtistTable?>
  346. </table>
  347. </div>
  348. </div>
  349. </div>
  350. <?php
  351. View::show_footer();