upload.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. * Upload images
  4. *
  5. * @author Cash Costello
  6. * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
  7. */
  8. gatekeeper();
  9. $album_guid = (int) get_input('guid');
  10. if (!$album_guid) {
  11. // @todo
  12. forward();
  13. }
  14. $album = get_entity($album_guid);
  15. if (!$album) {
  16. // @todo
  17. // throw warning and forward to previous page
  18. forward(REFERER);
  19. }
  20. if (!$album->getContainerEntity()->canWriteToContainer()) {
  21. // @todo have to be able to edit album to upload photos
  22. forward(REFERER);
  23. }
  24. // set page owner based on container (user or group)
  25. elgg_set_page_owner_guid($album->getContainerGUID());
  26. $owner = elgg_get_page_owner_entity();
  27. $title = elgg_echo('album:addpix');
  28. // set up breadcrumbs
  29. elgg_push_breadcrumb(elgg_echo('photos'), 'photos/siteimagesall');
  30. elgg_push_breadcrumb(elgg_echo('tidypics:albums'), 'photos/all');
  31. elgg_push_breadcrumb($owner->name, "photos/owner/$owner->username");
  32. elgg_push_breadcrumb($album->getTitle(), $album->getURL());
  33. elgg_push_breadcrumb(elgg_echo('album:addpix'));
  34. $uploader = get_input('uploader');
  35. if ($uploader == 'basic') {
  36. $content = elgg_view('forms/photos/basic_upload', array('entity' => $album));
  37. } else {
  38. elgg_load_js('jquery.plupload-tp');
  39. elgg_load_js('jquery.plupload.ui-tp');
  40. elgg_load_js('jquery.plupload.ui.lang-tp');
  41. elgg_load_css('jquery.plupload.jqueryui-theme');
  42. elgg_load_css('jquery.plupload.ui');
  43. elgg_load_js('tidypics:uploading');
  44. $content = elgg_view('forms/photos/ajax_upload', array('entity' => $album));
  45. }
  46. $body = elgg_view_layout('content', array(
  47. 'content' => $content,
  48. 'title' => $title,
  49. 'filter' => '',
  50. 'sidebar' => elgg_view('photos/sidebar', array('page' => 'upload')),
  51. ));
  52. echo elgg_view_page($title, $body);