aboutsummaryrefslogtreecommitdiff
path: root/mod/lightpics/pages/photos
diff options
context:
space:
mode:
Diffstat (limited to 'mod/lightpics/pages/photos')
-rw-r--r--mod/lightpics/pages/photos/album/add.php34
-rw-r--r--mod/lightpics/pages/photos/album/edit.php48
-rw-r--r--mod/lightpics/pages/photos/album/sort.php56
-rw-r--r--mod/lightpics/pages/photos/album/view.php63
-rw-r--r--mod/lightpics/pages/photos/all.php38
-rw-r--r--mod/lightpics/pages/photos/batch/edit.php44
-rw-r--r--mod/lightpics/pages/photos/friends.php34
-rw-r--r--mod/lightpics/pages/photos/image/download.php41
-rw-r--r--mod/lightpics/pages/photos/image/edit.php54
-rw-r--r--mod/lightpics/pages/photos/image/thumbnail.php38
-rw-r--r--mod/lightpics/pages/photos/image/upload.php64
-rw-r--r--mod/lightpics/pages/photos/image/view.php61
-rw-r--r--mod/lightpics/pages/photos/owner.php56
13 files changed, 631 insertions, 0 deletions
diff --git a/mod/lightpics/pages/photos/album/add.php b/mod/lightpics/pages/photos/album/add.php
new file mode 100644
index 000000000..d34d39177
--- /dev/null
+++ b/mod/lightpics/pages/photos/album/add.php
@@ -0,0 +1,34 @@
+<?php
+/**
+ * Create new album page
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+$owner = elgg_get_page_owner_entity();
+
+gatekeeper();
+group_gatekeeper();
+
+$title = elgg_echo('photos:add');
+
+// set up breadcrumbs
+elgg_push_breadcrumb(elgg_echo('photos'), "photos/all");
+if (elgg_instanceof($owner, 'user')) {
+ elgg_push_breadcrumb($owner->name, "photos/owner/$owner->username");
+} else {
+ elgg_push_breadcrumb($owner->name, "photos/group/$owner->guid/all");
+}
+elgg_push_breadcrumb($title);
+
+$vars = tidypics_prepare_form_vars();
+$content = elgg_view_form('photos/album/save', array('method' => 'post'), $vars);
+
+$body = elgg_view_layout('content', array(
+ 'content' => $content,
+ 'title' => $title,
+ 'filter' => '',
+));
+
+echo elgg_view_page($title, $body);
diff --git a/mod/lightpics/pages/photos/album/edit.php b/mod/lightpics/pages/photos/album/edit.php
new file mode 100644
index 000000000..7efb05ce1
--- /dev/null
+++ b/mod/lightpics/pages/photos/album/edit.php
@@ -0,0 +1,48 @@
+<?php
+/**
+ * Edit an album
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+$guid = (int) get_input('guid');
+
+if (!$entity = get_entity($guid)) {
+ // @todo either deleted or do not have access
+ forward('photos/all');
+}
+
+if (!$entity->canEdit()) {
+ // @todo cannot change it
+ forward('photos/all');
+}
+
+elgg_set_page_owner_guid($entity->getContainerGUID());
+$owner = elgg_get_page_owner_entity();
+
+gatekeeper();
+group_gatekeeper();
+
+$title = elgg_echo('album:edit');
+
+// set up breadcrumbs
+elgg_push_breadcrumb(elgg_echo('photos'), "photos/all");
+if (elgg_instanceof($owner, 'user')) {
+ elgg_push_breadcrumb($owner->name, "photos/owner/$owner->username");
+} else {
+ elgg_push_breadcrumb($owner->name, "photos/group/$owner->guid/all");
+}
+elgg_push_breadcrumb($entity->getTitle(), $entity->getURL());
+elgg_push_breadcrumb($title);
+
+$vars = tidypics_prepare_form_vars($entity);
+$content = elgg_view_form('photos/album/save', array('method' => 'post'), $vars);
+
+$body = elgg_view_layout('content', array(
+ 'content' => $content,
+ 'title' => $title,
+ 'filter' => '',
+));
+
+echo elgg_view_page($title, $body);
diff --git a/mod/lightpics/pages/photos/album/sort.php b/mod/lightpics/pages/photos/album/sort.php
new file mode 100644
index 000000000..005205dd5
--- /dev/null
+++ b/mod/lightpics/pages/photos/album/sort.php
@@ -0,0 +1,56 @@
+<?php
+/**
+ * Album sort page
+ *
+ * This displays a listing of all the photos so that they can be sorted
+ */
+
+gatekeeper();
+group_gatekeeper();
+
+// get the album entity
+$album_guid = (int) get_input('guid');
+$album = get_entity($album_guid);
+
+// panic if we can't get it
+if (!$album) {
+ forward();
+}
+
+// container should always be set, but just in case
+$owner = $album->getContainerEntity();
+elgg_set_page_owner_guid($owner->getGUID());
+
+$title = elgg_echo('tidypics:sort', array($album->getTitle()));
+
+// set up breadcrumbs
+elgg_push_breadcrumb(elgg_echo('photos'), 'photos/all');
+if (elgg_instanceof($owner, 'group')) {
+ elgg_push_breadcrumb($owner->name, "photos/group/$owner->guid/all");
+} else {
+ elgg_push_breadcrumb($owner->name, "photos/owner/$owner->username");
+}
+elgg_push_breadcrumb($album->getTitle(), $album->getURL());
+elgg_push_breadcrumb(elgg_echo('album:sort'));
+
+elgg_register_menu_item('title', array(
+ 'name' => 'upload',
+ 'href' => 'photos/upload/' . $album->getGUID(),
+ 'text' => elgg_echo('images:upload'),
+ 'link_class' => 'elgg-button elgg-button-action',
+));
+
+if ($album->getSize()) {
+ $content = elgg_view_form('photos/album/sort', array(), array('album' => $album));
+} else {
+ $content = elgg_echo('tidypics:sort:no_images');
+}
+
+$body = elgg_view_layout('content', array(
+ 'filter' => false,
+ 'content' => $content,
+ 'title' => $title,
+ 'sidebar' => elgg_view('tidypics/sidebar', array('page' => 'album')),
+));
+
+echo elgg_view_page($title, $body);
diff --git a/mod/lightpics/pages/photos/album/view.php b/mod/lightpics/pages/photos/album/view.php
new file mode 100644
index 000000000..6e111ab98
--- /dev/null
+++ b/mod/lightpics/pages/photos/album/view.php
@@ -0,0 +1,63 @@
+<?php
+/**
+ * This displays the photos that belong to an album
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+group_gatekeeper();
+
+// get the album entity
+$album_guid = (int) get_input('guid');
+$album = get_entity($album_guid);
+if (!$album) {
+ register_error(elgg_echo('noaccess'));
+ $_SESSION['last_forward_from'] = current_page_url();
+ forward('');
+}
+
+elgg_set_page_owner_guid($album->getContainerGUID());
+$owner = elgg_get_page_owner_entity();
+
+$title = elgg_echo($album->getTitle());
+
+// set up breadcrumbs
+elgg_push_breadcrumb(elgg_echo('photos'), 'photos/all');
+if (elgg_instanceof($owner, 'group')) {
+ elgg_push_breadcrumb($owner->name, "photos/group/$owner->guid/all");
+} else {
+ elgg_push_breadcrumb($owner->name, "photos/owner/$owner->username");
+}
+elgg_push_breadcrumb($album->getTitle());
+
+$content = elgg_view_entity($album, array('full_view' => true));
+
+if ($album->getContainerEntity()->canWriteToContainer()) {
+ elgg_register_menu_item('title', array(
+ 'name' => 'upload',
+ 'href' => 'photos/upload/' . $album->getGUID(),
+ 'text' => elgg_echo('images:upload'),
+ 'link_class' => 'elgg-button elgg-button-action',
+ ));
+}
+
+// only show sort button if there are images
+if ($album->canEdit() && $album->getSize() > 0) {
+ elgg_register_menu_item('title', array(
+ 'name' => 'sort',
+ 'href' => "photos/sort/" . $album->getGUID(),
+ 'text' => elgg_echo('album:sort'),
+ 'link_class' => 'elgg-button elgg-button-action',
+ 'priority' => 200,
+ ));
+}
+
+$body = elgg_view_layout('content', array(
+ 'filter' => false,
+ 'content' => $content,
+ 'title' => $album->getTitle(),
+ 'sidebar' => elgg_view('tidypics/sidebar', array('page' => 'album')),
+));
+
+echo elgg_view_page($title, $body);
diff --git a/mod/lightpics/pages/photos/all.php b/mod/lightpics/pages/photos/all.php
new file mode 100644
index 000000000..aef7f11c6
--- /dev/null
+++ b/mod/lightpics/pages/photos/all.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * View all albums on the site
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+elgg_push_breadcrumb(elgg_echo('photos'));
+
+$num_albums = 16;
+
+$offset = (int)get_input('offset', 0);
+$content = elgg_list_entities(array(
+ 'type' => 'object',
+ 'subtype' => 'album',
+ 'limit' => $num_albums,
+ 'full_view' => false,
+ 'list_type' => 'gallery',
+ 'list_type_toggle' => false,
+ 'gallery_class' => 'tidypics-gallery',
+));
+if (!$content) {
+ $content = elgg_echo('tidypics:none');
+}
+
+$title = elgg_echo('album:all');
+
+elgg_register_title_button('photos');
+
+$body = elgg_view_layout('content', array(
+ 'filter_context' => 'all',
+ 'content' => $content,
+ 'title' => $title,
+ 'sidebar' => elgg_view('tidypics/sidebar', array('page' => 'all')),
+));
+
+echo elgg_view_page($title, $body);
diff --git a/mod/lightpics/pages/photos/batch/edit.php b/mod/lightpics/pages/photos/batch/edit.php
new file mode 100644
index 000000000..ca9a55b18
--- /dev/null
+++ b/mod/lightpics/pages/photos/batch/edit.php
@@ -0,0 +1,44 @@
+<?php
+/**
+ * Edit the image information for a batch of images
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+gatekeeper();
+
+$guid = (int) get_input('guid');
+
+if (!$batch = get_entity($guid)) {
+ // @todo either deleted or do not have access
+ forward('photos/all');
+}
+
+if (!$batch->canEdit()) {
+ // @todo cannot change it
+ forward('photos/all');
+}
+
+$album = $batch->getContainerEntity();
+
+elgg_set_page_owner_guid($batch->getContainerEntity()->getContainerGUID());
+$owner = elgg_get_page_owner_entity();
+
+$title = elgg_echo('tidypics:editprops');
+
+elgg_push_breadcrumb(elgg_echo('photos'), "photos/all");
+elgg_push_breadcrumb($owner->name, "photos/owner/$owner->username");
+elgg_push_breadcrumb($album->getTitle(), $album->getURL());
+elgg_push_breadcrumb($title);
+
+$content = elgg_view_form('photos/batch/edit', array(), array('batch' => $batch));
+
+$body = elgg_view_layout('content', array(
+ 'filter' => false,
+ 'content' => $content,
+ 'title' => elgg_echo('tidypics:editprops'),
+ 'sidebar' => elgg_view('tidypics/sidebar', array('page' => 'album')),
+));
+
+echo elgg_view_page($title, $body);
diff --git a/mod/lightpics/pages/photos/friends.php b/mod/lightpics/pages/photos/friends.php
new file mode 100644
index 000000000..e6ac49cc6
--- /dev/null
+++ b/mod/lightpics/pages/photos/friends.php
@@ -0,0 +1,34 @@
+<?php
+/**
+ * List all the albums of someone's friends
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+$owner = elgg_get_page_owner_entity();
+
+elgg_push_breadcrumb(elgg_echo('photos'), "photos/all");
+elgg_push_breadcrumb($owner->name, "photos/friends/$owner->username");
+elgg_push_breadcrumb(elgg_echo('friends'));
+
+$title = elgg_echo('album:friends');
+
+
+$num_albums = 16;
+
+set_input('list_type', 'gallery');
+$content = list_user_friends_objects($owner->guid, 'album', $num_albums, false);
+if (!$content) {
+ $content = elgg_echo('tidypics:none');
+}
+
+elgg_register_title_button();
+
+$body = elgg_view_layout('content', array(
+ 'filter_context' => 'friends',
+ 'content' => $content,
+ 'title' => $title,
+));
+
+echo elgg_view_page($title, $body);
diff --git a/mod/lightpics/pages/photos/image/download.php b/mod/lightpics/pages/photos/image/download.php
new file mode 100644
index 000000000..ef47b7638
--- /dev/null
+++ b/mod/lightpics/pages/photos/image/download.php
@@ -0,0 +1,41 @@
+<?php
+/**
+ * Download a photo
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+$guid = (int) get_input('guid');
+$image = get_entity($guid);
+
+$disposition = get_input('disposition', 'attachment');
+
+if ($image) {
+ $filename = $image->originalfilename;
+ $mime = $image->mimetype;
+
+ header("Content-Type: $mime");
+ header("Content-Disposition: $disposition; filename=\"$filename\"");
+
+ $contents = $image->grabFile();
+
+ if (empty($contents)) {
+ echo file_get_contents(dirname(dirname(__FILE__)) . "/graphics/image_error_large.png" );
+ } else {
+
+ // expires every 60 days
+ $expires = 60 * 60*60*24;
+
+ header("Content-Length: " . strlen($contents));
+ header("Cache-Control: public", true);
+ header("Pragma: public", true);
+ header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT', true);
+
+ echo $contents;
+ }
+
+ exit;
+} else {
+ register_error(elgg_echo("image:downloadfailed"));
+}
diff --git a/mod/lightpics/pages/photos/image/edit.php b/mod/lightpics/pages/photos/image/edit.php
new file mode 100644
index 000000000..76c1381c9
--- /dev/null
+++ b/mod/lightpics/pages/photos/image/edit.php
@@ -0,0 +1,54 @@
+<?php
+/**
+ * Edit an image
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+$guid = (int) get_input('guid');
+
+if (!$entity = get_entity($guid)) {
+ // @todo either deleted or do not have access
+ forward('photos/all');
+}
+
+if (!$entity->canEdit()) {
+ // @todo cannot change it
+ forward($entity->getContainerEntity()->getURL());
+}
+
+$album = $entity->getContainerEntity();
+if (!$album) {
+
+}
+
+elgg_set_page_owner_guid($album->getContainerGUID());
+$owner = elgg_get_page_owner_entity();
+
+gatekeeper();
+group_gatekeeper();
+
+$title = elgg_echo('image:edit');
+
+// set up breadcrumbs
+elgg_push_breadcrumb(elgg_echo('photos'), "photos/all");
+if (elgg_instanceof($owner, 'user')) {
+ elgg_push_breadcrumb($owner->name, "photos/owner/$owner->username");
+} else {
+ elgg_push_breadcrumb($owner->name, "photos/group/$owner->guid/all");
+}
+elgg_push_breadcrumb($album->getTitle(), $album->getURL());
+elgg_push_breadcrumb($entity->getTitle(), $entity->getURL());
+elgg_push_breadcrumb($title);
+
+$vars = tidypics_prepare_form_vars($entity);
+$content = elgg_view_form('photos/image/save', array('method' => 'post'), $vars);
+
+$body = elgg_view_layout('content', array(
+ 'content' => $content,
+ 'title' => $title,
+ 'filter' => '',
+));
+
+echo elgg_view_page($title, $body);
diff --git a/mod/lightpics/pages/photos/image/thumbnail.php b/mod/lightpics/pages/photos/image/thumbnail.php
new file mode 100644
index 000000000..28fabf7aa
--- /dev/null
+++ b/mod/lightpics/pages/photos/image/thumbnail.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * Image thumbnail view
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+$guid = (int) get_input('guid');
+$size = get_input('size');
+$image = get_entity($guid);
+if (!$image) {
+ // @todo
+}
+
+if ($size == 'master') {
+ $contents = $image->getImage();
+} else {
+ $contents = $image->getThumbnail($size);
+}
+if (!$contents) {
+ forward("mod/lightpics/graphics/image_error_$size");
+}
+
+// expires every 14 days
+$expires = 14 * 60*60*24;
+
+// overwrite header caused by php session code so images can be cached
+$mime = $image->getMimeType();
+header("Content-Type: $mime");
+header("Content-Length: " . strlen($contents));
+header("Cache-Control: public", true);
+header("Pragma: public", true);
+header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT', true);
+
+// Return the thumbnail and exit
+echo $contents;
+exit;
diff --git a/mod/lightpics/pages/photos/image/upload.php b/mod/lightpics/pages/photos/image/upload.php
new file mode 100644
index 000000000..c8e57038c
--- /dev/null
+++ b/mod/lightpics/pages/photos/image/upload.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * Upload images
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+gatekeeper();
+
+$album_guid = (int) get_input('guid');
+if (!$album_guid) {
+ // @todo
+ forward();
+}
+
+$album = get_entity($album_guid);
+if (!$album) {
+ // @todo
+ // throw warning and forward to previous page
+ forward(REFERER);
+}
+
+if (!$album->getContainerEntity()->canWriteToContainer()) {
+ // @todo have to be able to edit album to upload photos
+ forward(REFERER);
+}
+
+// set page owner based on container (user or group)
+elgg_set_page_owner_guid($album->getContainerGUID());
+$owner = elgg_get_page_owner_entity();
+
+$title = elgg_echo('album:addpix');
+
+// set up breadcrumbs
+elgg_push_breadcrumb(elgg_echo('photos'), "photos/all");
+elgg_push_breadcrumb($owner->name, "photos/owner/$owner->username");
+elgg_push_breadcrumb($album->getTitle(), $album->getURL());
+elgg_push_breadcrumb(elgg_echo('album:addpix'));
+
+// load javascript dependences
+elgg_load_js('jquery-tmpl');
+elgg_load_js('jquery-load-image');
+elgg_load_js('jquery-canvas-to-blob');
+elgg_load_js('jquery-fileupload');
+elgg_load_js('jquery-fileupload-ui');
+elgg_load_js('tidypics:upload');
+
+$form_vars = array(
+ 'id' => 'fileupload',
+ 'action' => 'action/photos/image/upload',
+ 'enctype' => 'multipart/form-data',
+);
+
+$content = elgg_view_form('photos/basic_upload', $form_vars, array('entity' => $album));
+
+$body = elgg_view_layout('content', array(
+ 'content' => $content,
+ 'title' => $title,
+ 'filter' => '',
+ 'sidebar' => elgg_view('photos/sidebar', array('page' => 'upload')),
+));
+
+echo elgg_view_page($title, $body);
diff --git a/mod/lightpics/pages/photos/image/view.php b/mod/lightpics/pages/photos/image/view.php
new file mode 100644
index 000000000..e30bed70a
--- /dev/null
+++ b/mod/lightpics/pages/photos/image/view.php
@@ -0,0 +1,61 @@
+<?php
+/**
+ * View an image
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+group_gatekeeper();
+
+// get the photo entity
+$photo_guid = (int) get_input('guid');
+$photo = get_entity($photo_guid);
+if (!$photo) {
+ register_error(elgg_echo('noaccess'));
+ $_SESSION['last_forward_from'] = current_page_url();
+ forward('');
+}
+
+$photo->addView();
+
+// set page owner based on owner of photo album
+$album = $photo->getContainerEntity();
+if ($album) {
+ elgg_set_page_owner_guid($album->getContainerGUID());
+}
+$owner = elgg_get_page_owner_entity();
+
+// set up breadcrumbs
+elgg_push_breadcrumb(elgg_echo('photos'), 'photos/all');
+if (elgg_instanceof($owner, 'group')) {
+ elgg_push_breadcrumb($owner->name, "photos/group/$owner->guid/all");
+} else {
+ elgg_push_breadcrumb($owner->name, "photos/owner/$owner->username");
+}
+elgg_push_breadcrumb($album->getTitle(), $album->getURL());
+elgg_push_breadcrumb($photo->getTitle());
+
+if (elgg_get_plugin_setting('download_link', 'tidypics')) {
+ // add download button to title menu
+ elgg_register_menu_item('title', array(
+ 'name' => 'download',
+ 'href' => "photos/download/$photo_guid",
+ 'text' => elgg_echo('image:download'),
+ 'link_class' => 'elgg-button elgg-button-action',
+ ));
+}
+
+$content = elgg_view_entity($photo, array('full_view' => true));
+
+$body = elgg_view_layout('content', array(
+ 'filter' => false,
+ 'content' => $content,
+ 'title' => $photo->getTitle(),
+ 'sidebar' => elgg_view('photos/sidebar', array(
+ 'page' => 'view',
+ 'image' => $photo,
+ )),
+));
+
+echo elgg_view_page($photo->getTitle(), $body);
diff --git a/mod/lightpics/pages/photos/owner.php b/mod/lightpics/pages/photos/owner.php
new file mode 100644
index 000000000..506cb569b
--- /dev/null
+++ b/mod/lightpics/pages/photos/owner.php
@@ -0,0 +1,56 @@
+<?php
+/**
+ * Show all the albums that belong to a user or group
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+group_gatekeeper();
+
+$owner = elgg_get_page_owner_entity();
+
+$title = elgg_echo('album:user', array($owner->name));
+
+// set up breadcrumbs
+elgg_push_breadcrumb(elgg_echo('photos'), 'photos/all');
+elgg_push_breadcrumb($owner->name);
+
+
+$num_albums = 16;
+
+$content = elgg_list_entities(array(
+ 'type' => 'object',
+ 'subtype' => 'album',
+ 'container_guid' => $owner->getGUID(),
+ 'limit' => $num_albums,
+ 'full_view' => false,
+ 'list_type' => 'gallery',
+ 'list_type_toggle' => false,
+ 'gallery_class' => 'tidypics-gallery',
+));
+if (!$content) {
+ $content = elgg_echo('tidypics:none');
+}
+
+elgg_register_title_button();
+
+$params = array(
+ 'filter_context' => 'mine',
+ 'content' => $content,
+ 'title' => $title,
+ 'sidebar' => elgg_view('tidypics/sidebar', array('page' => 'owner')),
+);
+
+// don't show filter if out of filter context
+if ($owner instanceof ElggGroup) {
+ $params['filter'] = false;
+}
+
+if ($owner->getGUID() != elgg_get_logged_in_user_guid()) {
+ $params['filter_context'] = '';
+}
+
+$body = elgg_view_layout('content', $params);
+
+echo elgg_view_page($title, $body);