aboutsummaryrefslogtreecommitdiff
path: root/pages
diff options
context:
space:
mode:
Diffstat (limited to 'pages')
-rw-r--r--pages/edit_multiple.php52
-rw-r--r--pages/photos/batch/edit.php44
-rw-r--r--pages/photos/image/thumbnail.php34
-rw-r--r--pages/photos/image/upload.php61
-rw-r--r--pages/thumbnail.php78
5 files changed, 107 insertions, 162 deletions
diff --git a/pages/edit_multiple.php b/pages/edit_multiple.php
deleted file mode 100644
index 7c7b989cf..000000000
--- a/pages/edit_multiple.php
+++ /dev/null
@@ -1,52 +0,0 @@
-<?php
-/**
- * Tidypics: Edit the properties of multiple images
- *
- * Called after upload only
- */
-
-include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php";
-
-gatekeeper();
-set_context('photos');
-
-set_page_owner(get_loggedin_userid());
-
-
-$batch = get_input('batch');
-if ($batch) {
- $images = elgg_get_entities_from_metadata(array(
- 'metadata_name' => 'batch',
- 'metadata_value' => $batch,
- 'type' => 'object',
- 'subtype' => 'image',
- 'owner_guid' => get_loggedin_userid(),
- 'limit' => ELGG_ENTITIES_NO_VALUE,
- ));
-} else {
- // parse out photo guids
- $file_string = get_input('files');
- $file_array_sent = explode('-', $file_string);
-
- $images = array();
- foreach ($file_array_sent as $file_guid) {
- if ($entity = get_entity($file_guid)) {
- if ($entity->canEdit()) {
- array_push($images, $entity);
- }
- }
- }
-}
-
-if (!$images) {
- forward($_SERVER['HTTP_REFERER']);
-}
-
-
-$title = elgg_echo('tidypics:editprops');
-
-$content .= elgg_view_title($title);
-$content .= elgg_view("tidypics/forms/edit_multi", array('images' => $images));
-
-$body = elgg_view_layout('two_column_left_sidebar', '', $content);
-page_draw($title, $body);
diff --git a/pages/photos/batch/edit.php b/pages/photos/batch/edit.php
new file mode 100644
index 000000000..b96ddf408
--- /dev/null
+++ b/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->title, $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/pages/photos/image/thumbnail.php b/pages/photos/image/thumbnail.php
new file mode 100644
index 000000000..ae07f2706
--- /dev/null
+++ b/pages/photos/image/thumbnail.php
@@ -0,0 +1,34 @@
+<?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
+}
+
+$contents = $image->getThumbnail($size);
+if (!$contents) {
+ forward("mod/tidypics/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/pages/photos/image/upload.php b/pages/photos/image/upload.php
index 6580c6f52..526972a35 100644
--- a/pages/photos/image/upload.php
+++ b/pages/photos/image/upload.php
@@ -1,62 +1,59 @@
<?php
/**
- * Tidypics Upload Images Page
+ * Upload images
*
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
*/
-include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php";
-
-global $CONFIG;
-
-// must be logged in to upload images
gatekeeper();
-$album_guid = (int) get_input('album_guid');
+$album_guid = (int) get_input('guid');
if (!$album_guid) {
+ // @todo
forward();
}
-if (get_plugin_setting('uploader', 'tidypics') != "disabled") {
+if (elgg_get_plugin_setting('uploader', 'tidypics') != "disabled") {
$uploader = get_input('uploader', 'ajax');
} else {
$uploader = 'basic';
}
-
$album = get_entity($album_guid);
-
-//if album does not exist or user does not have access
if (!$album || !$album->canEdit()) {
+ // @todo
// throw warning and forward to previous page
- forward($_SERVER['HTTP_REFERER']);
+ forward(REFERER);
+}
+
+if (!$album->canEdit()) {
+ // @todo have to be able to edit album to upload photos
}
// set page owner based on container (user or group)
-set_page_owner($album->container_guid);
+elgg_set_page_owner_guid($album->getContainerGUID());
+$owner = elgg_get_page_owner_entity();
-$page_owner = page_owner_entity();
-if ($page_owner instanceof ElggGroup) {
- add_submenu_item( sprintf(elgg_echo('album:group'),$page_owner->name),
- $CONFIG->wwwroot . "pg/photos/owned/" . $page_owner->username);
-}
+$title = elgg_echo('album:addpix');
-set_context('photos');
-$title = elgg_echo('album:addpix') . ': ' . $album->title;
-$area2 .= elgg_view_title($title);
+// 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'));
-if ($uploader == 'basic') {
- $area2 .= elgg_view('input/form', array(
- 'action' => "{$CONFIG->wwwroot}action/tidypics/upload",
- 'body' => elgg_view('forms/tidypics/basic_upload', array('album' => $album)),
- 'internalid' => 'tidypicsUpload',
- 'enctype' => 'multipart/form-data',
- 'method' => 'post',
- ));
+if ($uploader == 'basic') {
+ $content = elgg_view('forms/photos/basic_upload', array('entity' => $album));
} else {
- $area2 .= elgg_view("forms/tidypics/ajax_upload", array('album' => $album));
+ $content = elgg_view('forms/photos/ajax_upload', array('entity' => $album));
}
-$body = elgg_view_layout('two_column_left_sidebar', '', $area2);
+$body = elgg_view_layout('content', array(
+ 'content' => $content,
+ 'title' => $title,
+ 'filter' => '',
+));
-page_draw($title, $body);
+echo elgg_view_page($title, $body);
diff --git a/pages/thumbnail.php b/pages/thumbnail.php
deleted file mode 100644
index 9daa2f9c0..000000000
--- a/pages/thumbnail.php
+++ /dev/null
@@ -1,78 +0,0 @@
-<?php
-
-/**
- * Tidypics Thumbnail
- *
- */
-
-// Get file GUID
-$file_guid = (int) get_input('file_guid');
-
-// Get file thumbnail size
-$size = get_input('size');
-// only 3 possibilities
-if ($size != 'small' && $size != 'thumb') {
- $size = 'large';
-}
-
-$error_image = '';
-switch ($size) {
- case 'thumb':
- $error_image = "image_error_thumb.png";
- break;
- case 'small':
- $error_image = "image_error_small.png";
- break;
- case 'large':
- $error_image = "image_error_large.png";
- break;
-}
-
-// Get file entity
-$file = get_entity($file_guid);
-if (!$file) {
- forward('mod/tidypics/graphics/' . $error_image);
-}
-
-if ($file->getSubtype() != "image") {
- forward('mod/tidypics/graphics/' . $error_image);
-}
-
-// Get filename
-if ($size == "thumb") {
- $thumbfile = $file->thumbnail;
-} else if ($size == "small") {
- $thumbfile = $file->smallthumb;
-} else {
- $thumbfile = $file->largethumb;
-}
-
-if (!$thumbfile) {
- forward('mod/tidypics/graphics/' . $error_image);
-}
-
-// create Elgg File object
-$readfile = new ElggFile();
-$readfile->owner_guid = $file->owner_guid;
-$readfile->setFilename($thumbfile);
-$contents = $readfile->grabFile();
-
-// send error image if file could not be read
-if (!$contents) {
- forward('mod/tidypics/graphics/' . $error_image);
-}
-
-// expires every 14 days
-$expires = 14 * 60*60*24;
-
-// overwrite header caused by php session code so images can be cached
-$mime = $file->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;