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

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