view.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. /**
  3. * View an image
  4. *
  5. * @author Cash Costello
  6. * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
  7. */
  8. group_gatekeeper();
  9. // get the photo entity
  10. $photo_guid = (int) get_input('guid');
  11. $photo = get_entity($photo_guid);
  12. if (!$photo) {
  13. register_error(elgg_echo('noaccess'));
  14. $_SESSION['last_forward_from'] = current_page_url();
  15. forward('');
  16. }
  17. $album = $photo->getContainerEntity();
  18. $album_container = $album->getContainerEntity();
  19. if (!$album_container) {
  20. register_error(elgg_echo('noaccess'));
  21. $_SESSION['last_forward_from'] = current_page_url();
  22. forward('');
  23. }
  24. $photo->addView();
  25. if (elgg_get_plugin_setting('tagging', 'tidypics')) {
  26. elgg_load_js('tidypics:tagging');
  27. elgg_load_js('jquery.imgareaselect');
  28. }
  29. // set page owner based on owner of photo album
  30. if ($album) {
  31. elgg_set_page_owner_guid($album->getContainerGUID());
  32. }
  33. $owner = elgg_get_page_owner_entity();
  34. // set up breadcrumbs
  35. elgg_push_breadcrumb(elgg_echo('photos'), 'photos/siteimagesall');
  36. elgg_push_breadcrumb(elgg_echo('tidypics:albums'), 'photos/all');
  37. if (elgg_instanceof($owner, 'group')) {
  38. elgg_push_breadcrumb($owner->name, "photos/group/$owner->guid/all");
  39. } else {
  40. elgg_push_breadcrumb($owner->name, "photos/owner/$owner->username");
  41. }
  42. elgg_push_breadcrumb($album->getTitle(), $album->getURL());
  43. elgg_push_breadcrumb($photo->getTitle());
  44. if (elgg_is_logged_in()) {
  45. if (elgg_instanceof($owner, 'group')) {
  46. $logged_in_guid = $owner->guid;
  47. } else {
  48. $logged_in_guid = elgg_get_logged_in_user_guid();
  49. }
  50. elgg_register_menu_item('title', array('name' => 'addphotos',
  51. 'href' => "ajax/view/photos/selectalbum/?owner_guid=" . $logged_in_guid,
  52. 'text' => elgg_echo("photos:addphotos"),
  53. 'link_class' => 'elgg-button elgg-button-action elgg-lightbox'));
  54. }
  55. if (elgg_get_plugin_setting('download_link', 'tidypics')) {
  56. // add download button to title menu
  57. elgg_register_menu_item('title', array(
  58. 'name' => 'download',
  59. 'href' => "photos/download/$photo_guid",
  60. 'text' => elgg_echo('image:download'),
  61. 'link_class' => 'elgg-button elgg-button-action',
  62. ));
  63. }
  64. $content = elgg_view_entity($photo, array('full_view' => true));
  65. $body = elgg_view_layout('content', array(
  66. 'filter' => false,
  67. 'content' => $content,
  68. 'title' => $photo->getTitle(),
  69. 'sidebar' => elgg_view('photos/sidebar', array(
  70. 'page' => 'tp_view',
  71. 'image' => $photo,
  72. )),
  73. ));
  74. echo elgg_view_page($photo->getTitle(), $body);