postPageView.inc 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. $humanReadableTime = new HumanReadableTime();
  3. $allTopicNames = array();
  4. $session = new Session();
  5. $userId = $session->getValue('logged_in');
  6. ?>
  7. <?=$header?>
  8. <div id="contentContainer">
  9. <div id="content">
  10. <a href="?a=post&id=<?=$postData['post_id']?>&t=<?=$postData['topic_id']?>"><?=$postData['post_name']?></a>
  11. <div id="byline">submitted <?=$humanReadableTime->formatString($postData['timestamp'])?> by <a href="/?a=user&id=<?=$postData['user_id']?>"><?=$postData['user_display_name']?></a>
  12. in topic:<a href="?a=topic&id=<?=$postData['topic_id']?>"><?=$postData['topic_display_name']?></a>
  13. </div>
  14. <div id="postContents">
  15. <?=$postData['content']?>
  16. <?php include 'attachmentsView.inc'; ?>
  17. </div>
  18. <?php if ($userId) { ?>
  19. <div class="postActions">
  20. <?php if($userId == $postData['user_id']) {?>
  21. <a data-id="<?=$postData['post_id']?>" class="edit" href="?a=editpost&id=<?=$postData['post_id']?>&t=<?=$topicData['topic_id']?>">edit</a>
  22. <!--<a data-id="<?=$postData['post_id']?>" class="delete" href="javascript:;">delete</a> -->
  23. <?php } ?>
  24. </div>
  25. <?php }
  26. $parentCommentId = 0;
  27. include "addNewCommentView.inc"; ?>
  28. <div id="comments"><?=$commentView?></div>
  29. </div>
  30. </div>
  31. <?php include "topicSidebarView.inc"; ?>
  32. <script type="text/javascript">
  33. $(document).ready(function() {
  34. var toggleCommentInputWindow = function() {
  35. $('#comment'+$(this).data('id')+'.commentReply').toggle();
  36. };
  37. var openCommentReplyFunction = function() {};
  38. openCommentReplyFunction = function() {
  39. var replyContainer = $(this).parent();
  40. var parentCommentId = $(this).data('id');
  41. $.get('?a=commentreplies&id=' + parentCommentId, function(result) {
  42. replyContainer.html(result);
  43. $('.loadCommentReplies').unbind('click');
  44. $('.toggleCommentReply').unbind('click');
  45. $('.openCommentEdit').unbind('click');
  46. $('.loadCommentReplies').click(openCommentReplyFunction);
  47. $('.toggleCommentReply').click(toggleCommentInputWindow);
  48. $('.openCommentEdit').click(openCommentEdit);
  49. });
  50. };
  51. var openCommentEdit = function() {
  52. var commentId = $(this).data('id');
  53. //TODO: async call to server to get comment contents
  54. $('#comment'+commentId+ ' .editWindow').toggle();
  55. $('#comment'+commentId+ ' .contents').toggle();
  56. };
  57. $('.loadCommentReplies').click(openCommentReplyFunction);
  58. $('.toggleCommentReply').click(toggleCommentInputWindow);
  59. $('.openCommentEdit').click(openCommentEdit);
  60. });
  61. </script>
  62. </body>
  63. </html>