poll.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /**
  3. * Elgg poll individual post view
  4. *
  5. * @uses $vars['entity'] Optionally, the poll post to view
  6. */
  7. if (isset($vars['entity'])) {
  8. $full = $vars['full_view'];
  9. $poll = $vars['entity'];
  10. $owner = $poll->getOwnerEntity();
  11. $container = $poll->getContainerEntity();
  12. $categories = elgg_view('output/categories', $vars);
  13. $owner_icon = elgg_view_entity_icon($owner, 'tiny');
  14. $owner_link = elgg_view('output/url', array(
  15. 'href' => "polls/owner/$owner->username",
  16. 'text' => $owner->name,
  17. 'is_trusted' => true,
  18. ));
  19. $author_text = elgg_echo('byline', array($owner_link));
  20. $tags = elgg_view('output/tags', array('tags' => $poll->tags));
  21. $date = elgg_view_friendly_time($poll->time_created);
  22. // TODO: support comments off
  23. // The "on" status changes for comments, so best to check for !Off
  24. if ($poll->comments_on != 'Off') {
  25. $comments_count = $poll->countComments();
  26. //only display if there are commments
  27. if ($comments_count != 0) {
  28. $text = elgg_echo("comments") . " ($comments_count)";
  29. $comments_link = elgg_view('output/url', array(
  30. 'href' => $poll->getURL() . '#poll-comments',
  31. 'text' => $text,
  32. 'is_trusted' => true,
  33. ));
  34. } else {
  35. $comments_link = '';
  36. }
  37. } else {
  38. $comments_link = '';
  39. }
  40. // do not show the metadata and controls in widget view
  41. if (elgg_in_context('widgets')) {
  42. $metadata = '';
  43. } else {
  44. $metadata = elgg_view_menu('entity', array(
  45. 'entity' => $poll,
  46. 'handler' => 'polls',
  47. 'sort_by' => 'priority',
  48. 'class' => 'elgg-menu-hz',
  49. ));
  50. }
  51. $subtitle = "$author_text $date $comments_link $categories";
  52. if ($full) {
  53. $params = array(
  54. 'entity' => $poll,
  55. 'title' => false,
  56. 'metadata' => $metadata,
  57. 'subtitle' => $subtitle,
  58. 'tags' => $tags,
  59. );
  60. $params = $params + $vars;
  61. $summary = elgg_view('object/elements/summary', $params);
  62. echo elgg_view('object/elements/full', array(
  63. 'summary' => $summary,
  64. 'icon' => $owner_icon,
  65. ));
  66. echo elgg_view('polls/body',$vars);
  67. } else {
  68. // brief view
  69. $params = array(
  70. 'entity' => $poll,
  71. 'metadata' => $metadata,
  72. 'subtitle' => $subtitle,
  73. 'tags' => $tags
  74. );
  75. $params = $params + $vars;
  76. $list_body = elgg_view('object/elements/summary', $params);
  77. echo elgg_view_image_block($owner_icon, $list_body);
  78. }
  79. }