tag.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * Photo tag view
  4. *
  5. * @uses $vars['tag'] Tag object
  6. *
  7. * @author Cash Costello
  8. * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
  9. */
  10. $coords = json_decode('{' . $vars['tag']->coords . '}');
  11. $attributes = elgg_format_attributes(array(
  12. 'class' => 'tidypics-tag',
  13. 'data-x1' => $coords->x1,
  14. 'data-y1' => $coords->y1,
  15. 'data-width' => $coords->width,
  16. 'data-height' => $coords->height,
  17. ));
  18. if ($vars['tag']->type == 'user') {
  19. $user = get_entity($vars['tag']->value);
  20. $label = elgg_view('output/url', array(
  21. 'text' => $user->name,
  22. 'href' => $user->getURL(),
  23. ));
  24. } else {
  25. $label = $vars['tag']->value;
  26. }
  27. $delete = '';
  28. $annotation = elgg_get_annotation_from_id($vars['tag']->annotation_id);
  29. if ($annotation->canEdit()) {
  30. $url = elgg_http_add_url_query_elements('action/photos/image/untag', array(
  31. 'annotation_id' => $vars['tag']->annotation_id
  32. ));
  33. $delete = elgg_view('output/confirmlink', array(
  34. 'href' => $url,
  35. 'text' => elgg_view_icon('delete', 'float mas'),
  36. 'confirm' => elgg_echo('tidypics:phototagging:delete:confirm')
  37. ));
  38. }
  39. echo <<<HTML
  40. <div class="tidypics-tag-wrapper">
  41. <div $attributes>$delete</div>
  42. <div class="elgg-module-popup tidypics-tag-label">$label</div>
  43. </div>
  44. HTML;