comment.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. $friendlytime = elgg_view_friendly_time($comment->time_created);
  16. $commenter_icon = elgg_view_entity_icon($commenter, 'tiny');
  17. $commenter_link = "<a href=\"{$commenter->getURL()}\">$commenter->name</a>";
  18. $entity_title = $entity->title ? $entity->title : elgg_echo('untitled');
  19. $entity_link = "<a href=\"{$entity->getURL()}\">$entity_title</a>";
  20. if ($full_view) {
  21. $anchor = "<a name=\"comment-{$comment->getGUID()}\"></a>";
  22. $menu = elgg_view_menu('entity', array(
  23. 'entity' => $comment,
  24. 'handler' => 'comment',
  25. 'sort_by' => 'priority',
  26. 'class' => 'elgg-menu-hz float-alt',
  27. ));
  28. if (elgg_in_context('activity')) {
  29. $comment_text = '<div class="elgg-output elgg-inner" data-role="comment-text">';
  30. $comment_text .= elgg_view('output/text', array(
  31. 'value' => elgg_get_excerpt($comment->description),
  32. ));
  33. $comment_text .= '</div>';
  34. } else {
  35. $comment_text = elgg_view('output/longtext', array(
  36. 'value' => $comment->description,
  37. 'class' => 'elgg-inner',
  38. 'data-role' => 'comment-text',
  39. ));
  40. }
  41. $body = <<<HTML
  42. $anchor
  43. <div class="mbn">
  44. $menu
  45. $commenter_link
  46. <span class="elgg-subtext">
  47. $friendlytime
  48. </span>
  49. $comment_text
  50. </div>
  51. HTML;
  52. echo elgg_view_image_block($commenter_icon, $body);
  53. } else {
  54. // brief view
  55. $excerpt = elgg_get_excerpt($comment->description, 80);
  56. $posted = elgg_echo('generic_comment:on', array($commenter_link, $entity_link));
  57. $body = <<<HTML
  58. <span class="elgg-subtext">
  59. $posted ($friendlytime): $excerpt
  60. </span>
  61. HTML;
  62. echo elgg_view_image_block($commenter_icon, $body);
  63. }