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.4KB

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