comment.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. /**
  3. * Elgg comment view
  4. *
  5. * @uses $vars['entity'] ElggComment
  6. * @uses $vars['full_view'] Display full view or brief view
  7. */
  8. $full_view = elgg_extract('full_view', $vars, true);
  9. $comment = $vars['entity'];
  10. $entity = get_entity($comment->container_guid);
  11. $commenter = get_user($comment->owner_guid);
  12. if (!$entity || !$commenter) {
  13. return true;
  14. }
  15. $moderating = false;
  16. if (!$comment->isEnabled() && $entity && $entity->canEdit()) {
  17. $moderating = true;
  18. }
  19. $friendlytime = elgg_view_friendly_time($comment->time_created);
  20. $commenter_icon = elgg_view_entity_icon($commenter, 'tiny');
  21. $commenter_link = "<a href=\"{$commenter->getURL()}\">$commenter->name</a>";
  22. $entity_title = $entity->title ? $entity->title : elgg_echo('untitled');
  23. $entity_link = "<a href=\"{$entity->getURL()}\">$entity_title</a>";
  24. $checkbox = elgg_view('input/checkbox', array(
  25. 'name' => 'guid',
  26. 'value' => $comment->guid,
  27. 'default' => false
  28. ));
  29. if ($full_view) {
  30. $anchor = "<a name=\"comment-{$comment->getGUID()}\"></a>";
  31. $menu = elgg_view_menu('entity', array(
  32. 'entity' => $comment,
  33. 'handler' => 'comment',
  34. 'sort_by' => 'priority',
  35. 'class' => 'elgg-menu-hz float-alt',
  36. ));
  37. $comment_text = elgg_view("output/longtext", array(
  38. 'value' => $comment->description,
  39. 'class' => 'elgg-inner',
  40. 'data-role' => 'comment-text',
  41. ));
  42. $body = <<<HTML
  43. $anchor
  44. <div class="mbn">
  45. $menu
  46. $commenter_link
  47. <span class="elgg-subtext">
  48. $friendlytime
  49. </span>
  50. $comment_text
  51. </div>
  52. HTML;
  53. if ($moderating) {
  54. $html = elgg_view_image_block($commenter_icon, $body);
  55. echo elgg_view_image_block($checkbox, $html, array(
  56. 'class' => 'moderated-comment'
  57. ));
  58. }
  59. else {
  60. echo elgg_view_image_block($commenter_icon, $body);
  61. }
  62. } else {
  63. // brief view
  64. $excerpt = elgg_get_excerpt($comment->description, 80);
  65. $posted = elgg_echo('generic_comment:on', array($commenter_link, $entity_link));
  66. $body = <<<HTML
  67. <span class="elgg-subtext">
  68. $posted ($friendlytime): $excerpt
  69. </span>
  70. HTML;
  71. if ($moderating) {
  72. echo elgg_view_image_block($commenter_icon, $body, array(
  73. 'class' => 'moderated-comment'
  74. ));
  75. }
  76. else {
  77. echo elgg_view_image_block($commenter_icon, $body);
  78. }
  79. }