wordtag.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Image word tag river view
  4. */
  5. $tagger = $vars['item']->getSubjectEntity();
  6. $tagged_image = $vars['item']->getObjectEntity();
  7. $annotation = $vars['item']->getAnnotation();
  8. if (!$annotation) {
  9. return;
  10. }
  11. $image = get_entity($annotation->entity_guid);
  12. // viewer may not have permission to view image
  13. if (!$image) {
  14. return;
  15. }
  16. $attachments = elgg_view_entity_icon($image, 'tiny');
  17. $tagger_link = elgg_view('output/url', array(
  18. 'href' => $tagger->getURL(),
  19. 'text' => $tagger->name,
  20. 'class' => 'elgg-river-subject',
  21. 'is_trusted' => true,
  22. ));
  23. $image_link = elgg_view('output/url', array(
  24. 'href' => $image->getURL(),
  25. 'text' => $image->getTitle(),
  26. 'is_trusted' => true,
  27. ));
  28. $value = $annotation->value;
  29. $tag = unserialize($value);
  30. $tag_array = string_to_tag_array($tag->value);
  31. $message = elgg_view('output/tags', array('value' => $tag_array));
  32. if (count($tag_array) > 1) {
  33. $summary = elgg_echo('image:river:wordtagged', array($tagger_link, $image_link));
  34. } else {
  35. $summary = elgg_echo('image:river:wordtagged_single', array($tagger_link, $image_link));
  36. }
  37. echo elgg_view('river/elements/layout', array(
  38. 'item' => $vars['item'],
  39. 'attachments' => $attachments,
  40. 'message' => $message,
  41. 'summary' => $summary
  42. ));