create.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. * Batch river view
  4. *
  5. * @author Cash Costello
  6. * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
  7. *
  8. */
  9. $batch = $vars['item']->getObjectEntity();
  10. // Get images related to this batch
  11. $images = elgg_get_entities_from_relationship(array(
  12. 'relationship' => 'belongs_to_batch',
  13. 'relationship_guid' => $batch->getGUID(),
  14. 'inverse_relationship' => true,
  15. 'type' => 'object',
  16. 'subtype' => 'image',
  17. 'offset' => 0,
  18. ));
  19. $album = $batch->getContainerEntity();
  20. if (!$album) {
  21. // something went quite wrong - this batch has no associated album
  22. return true;
  23. }
  24. $album_link = elgg_view('output/url', array(
  25. 'href' => $album->getURL(),
  26. 'text' => $album->getTitle(),
  27. 'is_trusted' => true,
  28. ));
  29. $subject = $vars['item']->getSubjectEntity();
  30. $subject_link = elgg_view('output/url', array(
  31. 'href' => $subject->getURL(),
  32. 'text' => $subject->name,
  33. 'class' => 'elgg-river-subject',
  34. 'is_trusted' => true,
  35. ));
  36. if (count($images)) {
  37. $attachments = '<ul class="tidypics-river-list">';
  38. foreach($images as $image) {
  39. $attachments .= '<li class="tidypics-photo-item">';
  40. $attachments .= elgg_view_entity_icon($image, 'tiny');
  41. $attachments .= '</li>';
  42. }
  43. $attachments .= '</ul>';
  44. }
  45. if (count($images) == 1) {
  46. // View the comments of the image
  47. $vars['item']->object_guid = $images[0]->guid;
  48. $responses = elgg_view('river/elements/responses', $vars);
  49. if ($responses) {
  50. $responses = "<div class=\"elgg-river-responses\">$responses</div>";
  51. }
  52. $image_link = elgg_view('output/url', array(
  53. 'href' => $images[0]->getURL(),
  54. 'text' => $images[0]->getTitle(),
  55. 'is_trusted' => true,
  56. ));
  57. $summary = elgg_echo('image:river:created', array($subject_link, $image_link, $album_link));
  58. } else {
  59. // View the comments of the album
  60. $vars['item']->object_guid = $album->guid;
  61. $responses = elgg_view('river/elements/responses', $vars);
  62. if ($responses) {
  63. $responses = "<div class=\"elgg-river-responses\">$responses</div>";
  64. }
  65. $summary = elgg_echo('image:river:created:multiple', array($subject_link, count($images), $album_link));
  66. }
  67. echo elgg_view('river/elements/layout', array(
  68. 'item' => $vars['item'],
  69. 'attachments' => $attachments,
  70. 'summary' => $summary
  71. ));