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.

commentsview.class.php 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?
  2. class CommentsView {
  3. /**
  4. * Render a thread of comments
  5. * @param array $Thread An array as returned by Comments::load
  6. * @param int $LastRead PostID of the last read post
  7. * @param string $Baselink Link to the site these comments are on
  8. */
  9. public static function render_comments($Thread, $LastRead, $Baselink) {
  10. foreach ($Thread as $Post) {
  11. list($PostID, $AuthorID, $AddedTime, $CommentBody, $EditedUserID, $EditedTime, $EditedUsername) = array_values($Post);
  12. self::render_comment($AuthorID, $PostID, $CommentBody, $AddedTime, $EditedUserID, $EditedTime, $Baselink . "&amp;postid=$PostID#post$PostID", ($PostID > $LastRead));
  13. }
  14. }
  15. /**
  16. * Render one comment
  17. * @param int $AuthorID
  18. * @param int $PostID
  19. * @param string $Body
  20. * @param string $AddedTime
  21. * @param int $EditedUserID
  22. * @param string $EditedTime
  23. * @param string $Link The link to the post elsewhere on the site
  24. * @param string $Header The header used in the post
  25. * @param bool $Tools Whether or not to show [Edit], [Report] etc.
  26. *
  27. * todo: Find a better way to pass the page (artist, collages, requests, torrents) to this function than extracting it from $Link
  28. */
  29. static function render_comment($AuthorID, $PostID, $Body, $AddedTime, $EditedUserID, $EditedTime, $Link, $Unread = false, $Header = '', $Tools = true) {
  30. $UserInfo = Users::user_info($AuthorID);
  31. $Header = Users::format_username($AuthorID, true, true, true, true, true) . time_diff($AddedTime) . $Header;
  32. ?>
  33. <table class="forum_post box vertical_margin<?=(!Users::has_avatars_enabled() ? ' noavatar' : '') . ($Unread ? ' forum_unread' : '')?>" id="post<?=$PostID?>">
  34. <colgroup>
  35. <? if (Users::has_avatars_enabled()) { ?>
  36. <col class="col_avatar" />
  37. <? } ?>
  38. <col class="col_post_body" />
  39. </colgroup>
  40. <tr class="colhead_dark">
  41. <td colspan="<?=(Users::has_avatars_enabled() ? 2 : 1)?>">
  42. <div class="float_left"><a class="post_id" href="<?=$Link?>">#<?=$PostID?></a>
  43. <?=$Header?>
  44. <? if ($Tools) { ?>
  45. - <a href="#quickpost" onclick="Quote('<?=$PostID?>','<?=$UserInfo['Username']?>', true);" class="brackets">Quote</a>
  46. <? if ($AuthorID == G::$LoggedUser['ID'] || check_perms('site_moderate_forums')) { ?>
  47. - <a href="#post<?=$PostID?>" onclick="Edit_Form('<?=$PostID?>','');" class="brackets">Edit</a>
  48. <? }
  49. if (check_perms('site_moderate_forums')) { ?>
  50. - <a href="#post<?=$PostID?>" onclick="Delete('<?=$PostID?>');" class="brackets">Delete</a>
  51. <? } ?>
  52. </div>
  53. <div id="bar<?=$PostID?>" class="float_right">
  54. <a href="reports.php?action=report&amp;type=comment&amp;id=<?=$PostID?>" class="brackets">Report</a>
  55. <?
  56. if (check_perms('users_warn') && $AuthorID != G::$LoggedUser['ID'] && G::$LoggedUser['Class'] >= $UserInfo['Class']) {
  57. ?>
  58. <form class="manage_form hidden" name="user" id="warn<?=$PostID?>" action="comments.php" method="post">
  59. <input type="hidden" name="action" value="warn" />
  60. <input type="hidden" name="postid" value="<?=$PostID?>" />
  61. </form>
  62. - <a href="#" onclick="$('#warn<?=$PostID?>').raw().submit(); return false;" class="brackets">Warn</a>
  63. <? } ?>
  64. &nbsp;
  65. <a href="#">&uarr;</a>
  66. <? } ?>
  67. </div>
  68. </td>
  69. </tr>
  70. <tr>
  71. <? if (Users::has_avatars_enabled()) { ?>
  72. <td class="avatar" valign="top">
  73. <?=Users::show_avatar($UserInfo['Avatar'], $AuthorID, $UserInfo['Username'], G::$LoggedUser['DisableAvatars'])?>
  74. </td>
  75. <? } ?>
  76. <td class="body" valign="top">
  77. <div id="content<?=$PostID?>">
  78. <?=Text::full_format($Body)?>
  79. <? if ($EditedUserID) { ?>
  80. <br />
  81. <br />
  82. <div class="last_edited">
  83. <? if (check_perms('site_admin_forums')) { ?>
  84. <a href="#content<?=$PostID?>" onclick="LoadEdit('<?=substr($Link, 0, strcspn($Link, '.'))?>', <?=$PostID?>, 1); return false;">&laquo;</a>
  85. <? } ?>
  86. Last edited by
  87. <?=Users::format_username($EditedUserID, false, false, false) ?> <?=time_diff($EditedTime, 2, true, true)?>
  88. <? } ?>
  89. </div>
  90. </div>
  91. </td>
  92. </tr>
  93. </table>
  94. <? }
  95. }