videolist_item.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. /**
  3. * Videolist item renderer.
  4. *
  5. * @package ElggVideolist
  6. */
  7. $full = elgg_extract('full_view', $vars, FALSE);
  8. $entity = elgg_extract('entity', $vars, FALSE);
  9. /* @var ElggObject $entity */
  10. if (!$entity) {
  11. return TRUE;
  12. }
  13. $owner = $entity->getOwnerEntity();
  14. $container = $entity->getContainerEntity();
  15. $categories = elgg_view('output/categories', $vars);
  16. $excerpt = elgg_get_excerpt($entity->description);
  17. $body = elgg_view('output/longtext', array('value' => $entity->description));
  18. $owner_link = elgg_view('output/url', array(
  19. 'href' => "videolist/owner/$owner->username",
  20. 'text' => $owner->name,
  21. ));
  22. $author_text = elgg_echo('byline', array($owner_link));
  23. //$entity_icon = elgg_view_entity_icon($entity, 'medium');
  24. $owner_icon = elgg_view_entity_icon($owner, 'small');
  25. $tags = elgg_view('output/tags', array('tags' => $entity->tags));
  26. $date = elgg_view_friendly_time($entity->time_created);
  27. $comments_count = $entity->countComments();
  28. //only display if there are commments
  29. if ($comments_count != 0) {
  30. $text = elgg_echo("comments") . " ($comments_count)";
  31. $comments_link = elgg_view('output/url', array(
  32. 'href' => $entity->getURL() . '#videolist-item-comments',
  33. 'text' => $text,
  34. ));
  35. } else {
  36. $comments_link = '';
  37. }
  38. $metadata = elgg_view_menu('entity', array(
  39. 'entity' => $vars['entity'],
  40. 'handler' => 'videolist',
  41. 'sort_by' => 'priority',
  42. 'class' => 'elgg-menu-hz',
  43. ));
  44. $subtitle = "$author_text $date $categories $comments_link";
  45. // do not show the metadata and controls in widget view
  46. if (elgg_in_context('widgets')) {
  47. $metadata = '';
  48. $excerpt = '';
  49. }
  50. if ($full && !elgg_in_context('gallery')) {
  51. $content = elgg_view("videolist/watch", $vars);
  52. $content = "<div class=\"videolist-watch\">$content</div>";
  53. $params = array(
  54. 'entity' => $entity,
  55. 'title' => false,
  56. 'content' => $content,
  57. 'metadata' => $metadata,
  58. 'subtitle' => $subtitle,
  59. 'tags' => $tags,
  60. );
  61. $params = $params + $vars;
  62. $list_body = elgg_view('object/elements/summary', $params);
  63. $entity_info = elgg_view_image_block($owner_icon, $list_body);
  64. echo <<<HTML
  65. $entity_info
  66. $body
  67. HTML;
  68. } elseif (elgg_in_context('gallery')) {
  69. echo '<div class="videolist-gallery-item">';
  70. $content = elgg_view('output/url', array(
  71. 'text' => elgg_get_excerpt($entity->title, 25),
  72. 'href' => $entity->getURL(),
  73. ));
  74. $content .= "<p class='subtitle'>$owner_link $date</p>";
  75. echo elgg_view_image_block($entity_icon, $content);
  76. echo '</div>';
  77. } else {
  78. // brief view
  79. $params = array(
  80. 'entity' => $entity,
  81. 'metadata' => $metadata,
  82. 'subtitle' => $subtitle,
  83. 'tags' => $tags,
  84. 'content' => $excerpt,
  85. );
  86. $params = $params + $vars;
  87. $list_body = elgg_view('object/elements/summary', $params);
  88. echo elgg_view_image_block($entity_icon, $list_body);
  89. }