groupforumtopic.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <?php
  2. /**
  3. * Forum topic entity view
  4. *
  5. * @package ElggGroups
  6. */
  7. $full = elgg_extract("full_view", $vars, FALSE);
  8. $topic = elgg_extract("entity", $vars, FALSE);
  9. if (!$topic) {
  10. return true;
  11. }
  12. $poster = $topic->getOwnerEntity();
  13. $group = $topic->getContainerEntity();
  14. $excerpt = elgg_get_excerpt($topic->description);
  15. $poster_icon = elgg_view_entity_icon($poster, "tiny");
  16. $poster_link = elgg_view("output/url", array(
  17. "href" => $poster->getURL(),
  18. "text" => $poster->name,
  19. "is_trusted" => true,
  20. ));
  21. $poster_text = elgg_echo("groups:started", array($poster_link));
  22. $container_text = "";
  23. if ($group instanceof ElggGroup) {
  24. if (!elgg_get_page_owner_guid() || (elgg_get_page_owner_guid() != $group->getGUID())) {
  25. $container_text = elgg_echo("groups:ingroup") . " " . elgg_view("output/url", array(
  26. "text" => $group->name,
  27. "href" => $group->getURL(),
  28. "is_trusted" => true
  29. ));
  30. }
  31. }
  32. $tags = elgg_view("output/tags", array("tags" => $topic->tags));
  33. $date = elgg_view_friendly_time($topic->time_created);
  34. $replies_link = "";
  35. $reply_text = "";
  36. $num_replies = elgg_get_entities(array(
  37. "type" => "object",
  38. "subtype" => "discussion_reply",
  39. "container_guid" => $topic->getGUID(),
  40. "count" => true,
  41. ));
  42. if ($num_replies != 0) {
  43. $last_reply = elgg_get_entities(array(
  44. 'type' => 'object',
  45. 'subtype' => 'discussion_reply',
  46. 'container_guid' => $topic->getGUID(),
  47. 'limit' => 1,
  48. ));
  49. $last_reply = $last_reply[0];
  50. $reply_poster = $last_reply->getOwnerEntity();
  51. $reply_time = elgg_view_friendly_time($last_reply->time_created);
  52. $reply_link = elgg_view("output/url", array(
  53. "text" => $reply_poster->name,
  54. "href" => $reply_poster->getURL(),
  55. "is_trusted" => true
  56. ));
  57. $reply_text = elgg_echo("groups:updated", array($reply_link, $reply_time));
  58. $replies_link = elgg_view("output/url", array(
  59. "href" => $topic->getURL() . "#group-replies",
  60. "text" => " " . elgg_echo("group:replies") . " ($num_replies)",
  61. "is_trusted" => true,
  62. ));
  63. }
  64. // do not show the metadata and controls in widget view
  65. $metadata = "";
  66. if (!elgg_in_context("widgets")) {
  67. $metadata = elgg_view_menu("entity", array(
  68. "entity" => $vars["entity"],
  69. "handler" => "discussion",
  70. "sort_by" => "priority",
  71. "class" => "elgg-menu-hz",
  72. ));
  73. }
  74. if ($full) {
  75. $title = "";
  76. if ($topic->status == "closed") {
  77. $title .= "<span title='" . htmlspecialchars(elgg_echo("groups:topicisclosed"), ENT_QUOTES, "UTF-8", false) . "'>" . elgg_view_icon("lock-closed") . "</span>";;
  78. }
  79. $title .= $topic->title;
  80. $subtitle = "$poster_text $date $replies_link";
  81. $params = array(
  82. "entity" => $topic,
  83. "metadata" => $metadata,
  84. "title" => $title,
  85. "subtitle" => $subtitle,
  86. "tags" => $tags,
  87. );
  88. $params = $params + $vars;
  89. $summary = elgg_view("object/elements/summary", $params);
  90. $body = elgg_view("output/longtext", array("value" => $topic->description));
  91. echo elgg_view("object/elements/full", array(
  92. "entity" => $topic,
  93. "icon" => $poster_icon,
  94. "summary" => $summary,
  95. "body" => $body
  96. ));
  97. } else {
  98. // brief view
  99. $title = "";
  100. if ($topic->status == "closed") {
  101. $title .= "<span title='" . htmlspecialchars(elgg_echo("groups:topicisclosed"), ENT_QUOTES, "UTF-8", false) . "'>" . elgg_view_icon("lock-closed") . "</span>";
  102. }
  103. $title .= elgg_view("output/url", array(
  104. "text" => $topic->title,
  105. "href" => $topic->getURL(),
  106. "is_trusted" => true
  107. ));
  108. $subtitle = "$poster_text $container_text $date $replies_link <span class='groups-latest-reply'>$reply_text</span>";
  109. $params = array(
  110. "entity" => $topic,
  111. "metadata" => $metadata,
  112. "title" => $title,
  113. "subtitle" => $subtitle,
  114. "tags" => $tags,
  115. "content" => $excerpt,
  116. );
  117. $params = $params + $vars;
  118. $list_body = elgg_view("object/elements/summary", $params);
  119. echo elgg_view_image_block($poster_icon, $list_body);
  120. }