Oppaitime'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.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. * @todo Find a better way to pass the page (artist, collages, requests, torrents) to this function than extracting it from $Link
  29. */
  30. public static function render_comment($AuthorID, $PostID, $Body, $AddedTime, $EditedUserID, $EditedTime, $Link, $Unread = false, $Header = '', $Tools = true)
  31. {
  32. $UserInfo = Users::user_info($AuthorID);
  33. $Header = Users::format_username($AuthorID, true, true, true, true, true) . time_diff($AddedTime) . $Header; ?>
  34. <table class="forum_post box vertical_margin<?=(!Users::has_avatars_enabled() ? ' noavatar' : '') . ($Unread ? ' forum_unread' : '')?>" id="post<?=$PostID?>">
  35. <colgroup>
  36. <?php if (Users::has_avatars_enabled()) { ?>
  37. <col class="col_avatar" />
  38. <?php } ?>
  39. <col class="col_post_body" />
  40. </colgroup>
  41. <tr class="colhead_dark">
  42. <td colspan="<?=(Users::has_avatars_enabled() ? 2 : 1)?>">
  43. <div class="float_left"><a class="post_id" href="<?=$Link?>">#<?=$PostID?></a>
  44. <?=$Header?>
  45. <?php if ($Tools) { ?>
  46. - <a href="#quickpost" onclick="Quote('<?=$PostID?>','<?=$UserInfo['Username']?>', true);" class="brackets">Quote</a>
  47. <?php if ($AuthorID == G::$LoggedUser['ID'] || check_perms('site_moderate_forums')) { ?>
  48. - <a href="#post<?=$PostID?>" onclick="Edit_Form('<?=$PostID?>','');" class="brackets">Edit</a>
  49. <?php }
  50. if (check_perms('site_moderate_forums')) { ?>
  51. - <a href="#post<?=$PostID?>" onclick="Delete('<?=$PostID?>');" class="brackets">Delete</a>
  52. <?php } ?>
  53. </div>
  54. <div id="bar<?=$PostID?>" class="float_right">
  55. <a href="reports.php?action=report&amp;type=comment&amp;id=<?=$PostID?>" class="brackets">Report</a>
  56. <?php
  57. if (check_perms('users_warn') && $AuthorID != G::$LoggedUser['ID'] && G::$LoggedUser['Class'] >= $UserInfo['Class']) {
  58. ?>
  59. <form class="manage_form hidden" name="user" id="warn<?=$PostID?>" action="comments.php" method="post">
  60. <input type="hidden" name="action" value="warn" />
  61. <input type="hidden" name="postid" value="<?=$PostID?>" />
  62. </form>
  63. - <a href="#" onclick="$('#warn<?=$PostID?>').raw().submit(); return false;" class="brackets">Warn</a>
  64. <?php
  65. } ?>
  66. &nbsp;
  67. <a href="#">&uarr;</a>
  68. <?php } ?>
  69. </div>
  70. </td>
  71. </tr>
  72. <tr>
  73. <?php if (Users::has_avatars_enabled()) { ?>
  74. <td class="avatar" valign="top">
  75. <?=Users::show_avatar($UserInfo['Avatar'], $AuthorID, $UserInfo['Username'], G::$LoggedUser['DisableAvatars'])?>
  76. </td>
  77. <?php } ?>
  78. <td class="body" valign="top">
  79. <div id="content<?=$PostID?>">
  80. <?=Text::full_format($Body)?>
  81. <?php if ($EditedUserID) { ?>
  82. <br />
  83. <br />
  84. <div class="last_edited">
  85. <?php if (check_perms('site_admin_forums')) { ?>
  86. <a href="#content<?=$PostID?>" onclick="LoadEdit('<?=substr($Link, 0, strcspn($Link, '.'))?>', <?=$PostID?>, 1); return false;">&laquo;</a>
  87. <?php } ?>
  88. Last edited by
  89. <?=Users::format_username($EditedUserID, false, false, false) ?> <?=time_diff($EditedTime, 2, true, true)?>
  90. <?php } ?>
  91. </div>
  92. </div>
  93. </td>
  94. </tr>
  95. </table>
  96. <?php
  97. }
  98. }