aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions/addalbum.php2
-rw-r--r--actions/ajax_upload.php5
-rw-r--r--actions/upload.php6
-rw-r--r--lib/album.php8
-rw-r--r--pages/edit_multiple.php54
-rw-r--r--pages/upload.php16
-rw-r--r--start.php12
-rw-r--r--views/default/tidypics/css.php27
-rw-r--r--views/default/tidypics/forms/ajax_upload.php36
-rw-r--r--views/default/tidypics/forms/edit_multi.php23
-rw-r--r--views/default/tidypics/forms/upload.php7
11 files changed, 127 insertions, 69 deletions
diff --git a/actions/addalbum.php b/actions/addalbum.php
index bdac9bfbf..8ddcca131 100644
--- a/actions/addalbum.php
+++ b/actions/addalbum.php
@@ -42,6 +42,8 @@ if (!$album->save()) {
forward(get_input('forward_url', $_SERVER['HTTP_REFERER']));
}
+mkdir(tp_get_img_dir() . $album->guid, 0755, true);
+
system_message(elgg_echo("album:created"));
// Remove the album post cache
diff --git a/actions/ajax_upload.php b/actions/ajax_upload.php
index 3d44df199..973e4220a 100644
--- a/actions/ajax_upload.php
+++ b/actions/ajax_upload.php
@@ -33,7 +33,8 @@ $image->setMimeType(tp_upload_get_mimetype($name));
$image->simpletype = "image";
$image->access_id = $album->access_id;
$image->title = substr($name, 0, strrpos($name, '.'));
-$image_guid = $image->save();
+$image->batch = get_input('batch');
+$result = $image->save();
$image->setOriginalFilename($name);
$image->saveImageFile($temp_file, $file_size);
@@ -43,5 +44,7 @@ $image->saveThumbnails($image_lib);
$album->prependImageList(array($image->guid));
+error_log('complete');
+
echo "1";
exit; \ No newline at end of file
diff --git a/actions/upload.php b/actions/upload.php
index 8dae85277..b3ad9ebc3 100644
--- a/actions/upload.php
+++ b/actions/upload.php
@@ -9,8 +9,8 @@ include_once dirname(dirname(__FILE__)) . "/lib/upload.php";
// Get common variables
$access_id = (int) get_input("access_id");
-$container_guid = (int) get_input('container_guid', 0);
-$album = get_entity($container_guid);
+$album_guid = (int) get_input('album_guid', 0);
+$album = get_entity($album_guid);
if (!$album) {
register_error(elgg_echo('tidypics:baduploadform'));
forward($_SERVER['HTTP_REFERER']);
@@ -101,7 +101,7 @@ foreach($_FILES as $key => $sent_file) {
//this will save to users folder in /image/ and organize by photo album
$file = new TidypicsImage();
- $file->container_guid = $container_guid;
+ $file->container_guid = $album_guid;
$file->setMimeType($mime);
$file->simpletype="image";
$file->access_id = $access_id;
diff --git a/lib/album.php b/lib/album.php
index 916ccbc31..0d5140875 100644
--- a/lib/album.php
+++ b/lib/album.php
@@ -210,9 +210,11 @@ class TidypicsAlbum extends ElggObject {
protected function deleteImages() {
// get all the images from this album as long as less than 999 images
$images = get_entities("object", "image", $this->guid, '', 999);
- foreach ($images as $image) {
- if ($image) {
- $image->delete();
+ if ($images) {
+ foreach ($images as $image) {
+ if ($image) {
+ $image->delete();
+ }
}
}
}
diff --git a/pages/edit_multiple.php b/pages/edit_multiple.php
index ec507ba4b..938ac203c 100644
--- a/pages/edit_multiple.php
+++ b/pages/edit_multiple.php
@@ -10,38 +10,36 @@ include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php";
gatekeeper();
set_context('photos');
-// parse out photo guids
-$file_string = get_input('files');
-$file_array_sent = explode('-', $file_string);
-$new_file_array = array();
-
-// set owner of page based on first photo guid
-$photo_guid = (int)$file_array_sent[0];
-$photo = get_entity($photo_guid);
-
-// set page owner based on owner of photo album
-set_page_owner($photo->owner_guid);
-$album = get_entity($photo->container_guid);
-if ($album) {
- $owner_guid = $album->container_guid;
- if ($owner_guid) {
- set_page_owner($owner_guid);
- }
-}
+set_page_owner(get_loggedin_userid());
-foreach ($file_array_sent as $file_guid) {
- if ($entity = get_entity($file_guid)) {
- if ($entity->canEdit()) {
- array_push($new_file_array, $file_guid);
- }
- if (!$album_guid) {
- $album_guid = $entity->container_guid;
+
+$batch = get_input('batch');
+if ($batch) {
+ $images = get_entities_from_metadata('batch', $batch, 'object', 'image', get_loggedin_userid(), 100);
+} 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');
-$area2 .= elgg_view_title($title);
-$area2 .= elgg_view("tidypics/forms/edit_multi", array('file_array' => $new_file_array, 'album_guid' => $album_guid));
-$body = elgg_view_layout('two_column_left_sidebar', $area1, $area2);
+
+$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/upload.php b/pages/upload.php
index 8e15dd612..b6a828cf9 100644
--- a/pages/upload.php
+++ b/pages/upload.php
@@ -9,11 +9,13 @@ include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php";
// must be logged in to upload images
gatekeeper();
-$album_guid = (int) get_input('container_guid');
+$album_guid = (int) get_input('album_guid');
if (!$album_guid) {
forward();
}
+$uploader = get_input('uploader', 'ajax');
+
$album = get_entity($album_guid);
//if album does not exist or user does not have access
@@ -22,9 +24,8 @@ if (!$album || !$album->canEdit()) {
forward($_SERVER['HTTP_REFERER']);
}
-// set page owner based on container (user or group)
-$container = $album->container_guid;
-set_page_owner($container);
+// set page owner based on container (user or group)
+set_page_owner($album->container_guid);
$page_owner = page_owner_entity();
if ($page_owner instanceof ElggGroup) {
@@ -36,8 +37,11 @@ set_context('photos');
$title = elgg_echo('album:addpix') . ': ' . $album->title;
$area2 .= elgg_view_title($title);
-$area2 .= elgg_view("tidypics/forms/upload", array('album' => $album_guid ) );
-//$area2 .= elgg_view("tidypics/forms/ajax_upload", array('album' => $album_guid ) );
+if ($uploader == 'basic') {
+ $area2 .= elgg_view("tidypics/forms/upload", array('album' => $album));
+} else {
+ $area2 .= elgg_view("tidypics/forms/ajax_upload", array('album' => $album));
+}
$body = elgg_view_layout('two_column_left_sidebar', '', $area2);
diff --git a/start.php b/start.php
index 9b3dab08f..a50f23c57 100644
--- a/start.php
+++ b/start.php
@@ -263,7 +263,10 @@ function tidypics_page_handler($page) {
case "upload": //upload images to album
if (isset($page[1])) {
- set_input('container_guid', $page[1]);
+ set_input('album_guid', $page[1]);
+ }
+ if (isset($page[2])) {
+ set_input('uploader', 'basic');
}
include($CONFIG->pluginspath . "tidypics/pages/upload.php");
break;
@@ -275,6 +278,13 @@ function tidypics_page_handler($page) {
include($CONFIG->pluginspath . "tidypics/pages/edit.php");
break;
+ case "batch": //update titles and descriptions
+ if (isset($page[1])) {
+ set_input('batch', $page[1]);
+ }
+ include($CONFIG->pluginspath . "tidypics/pages/edit_multiple.php");
+ break;
+
case "friends": // albums of friends
if (isset($page[1])) {
set_input('username', $page[1]);
diff --git a/views/default/tidypics/css.php b/views/default/tidypics/css.php
index 9e5a5c68d..ea2081da6 100644
--- a/views/default/tidypics/css.php
+++ b/views/default/tidypics/css.php
@@ -304,7 +304,7 @@ list-style: none;
.uploadifyQueueItem {
background-color:#F5F5F5;
border:2px solid #E5E5E5;
-font:11px Verdana,Geneva,sans-serif;
+font-size:11px;
margin-top:5px;
padding:10px;
width:350px;
@@ -322,4 +322,27 @@ width:100%;
background-color: #0099FF;
width: 1px;
height: 3px;
-} \ No newline at end of file
+}
+
+#tidypics_uploader {
+position:relative;
+width:400px;
+}
+
+#tidypics_choose_button {
+position:absolute;
+top:0;
+left:0;
+z-index:0;
+display:block;
+float:left;
+}
+
+#tidypics_flash_uploader {
+position:relative;
+z-index:100;
+}
+
+#uploadifyQueue {
+margin-bottom: 20px;
+}
diff --git a/views/default/tidypics/forms/ajax_upload.php b/views/default/tidypics/forms/ajax_upload.php
index b71068a13..25c658570 100644
--- a/views/default/tidypics/forms/ajax_upload.php
+++ b/views/default/tidypics/forms/ajax_upload.php
@@ -2,13 +2,14 @@
extend_view('metatags', 'tidypics/js/uploader');
-$container_guid = get_input('container_guid');
-$album = get_entity($vars['album']);
+$album = $vars['album'];
$access_id = $album->access_id;
$ts = time();
$token = generate_action_token($ts);
+$batch = time();
+
$maxfilesize = (float) get_plugin_setting('maxfilesize','tidypics');
if (!$maxfilesize) {
@@ -36,29 +37,46 @@ if ($quota) {
<div class="contentWrapper">
-<p>Instructions here for uploading images using Ajax/Flash</p>
-<input id="upload_file" name="upload_file" type="file" />
-<a href="javascript:$('#upload_file').uploadifyUpload();">Upload Files</a> |
-<a href="javascript:$('#upload_file').uploadifyClearQueue();">Clear Queue</a>
+ <p>Instructions here for uploading images using Ajax/Flash</p>
+
+ <div id="tidypics_uploader">
+ <a id="tidypics_choose_button">Choose images</a>
+ <div id="tidypics_flash_uploader">
+ <input type="file" id="uploadify" name="uploadify" />
+ </div>
+ </div>
+
+<a href="javascript:$('#uploadify').uploadifyUpload();">Upload Files</a>
+<!--
+<a href="javascript:$('#uploadify').uploadifyClearQueue();">Clear Queue</a>
+-->
+<br />
+<a href="<?php echo $vars['url']; ?>pg/photos/batch/<?php echo $batch; ?>">Add titles and descriptions</a>
+<br />
+<a href="<?php echo current_page_url(); ?>/basic">Basic uploader</a>
+
</div>
<script type="text/javascript">
-$("#upload_file").uploadify({
+$("#uploadify").uploadify({
'uploader' : '<?php echo $vars['url']; ?>mod/tidypics/vendors/uploadify/uploadify.swf',
'script' : '<?php echo $vars['url']; ?>action/tidypics/ajax_upload/',
'scriptData' : {
'album_guid' : '<?php echo $album->guid; ?>',
'__elgg_token' : '<?php echo $token; ?>',
'__elgg_ts' : '<?php echo $ts; ?>',
- 'Elgg' : '<?php echo session_id(); ?>'
+ 'Elgg' : '<?php echo session_id(); ?>',
+ 'batch' : '<?php echo $batch; ?>'
},
'fileDataName' : 'Image',
'cancelImg' : '/_images/cancel.png',
'multi' : true,
'auto' : false,
'fileDesc' : '<?php echo elgg_echo('tidypics:upload:filedesc'); ?>',
- 'fileExt' : '*.jpg;*.jpeg;*.png;*.gif'
+ 'fileExt' : '*.jpg;*.jpeg;*.png;*.gif',
+ 'wmode' : 'transparent',
+ 'buttonImg' : " "
});
</script>
diff --git a/views/default/tidypics/forms/edit_multi.php b/views/default/tidypics/forms/edit_multi.php
index 8c3e40242..aba6fd324 100644
--- a/views/default/tidypics/forms/edit_multi.php
+++ b/views/default/tidypics/forms/edit_multi.php
@@ -2,26 +2,25 @@
/**
* form for mass editing all uploaded images
*/
+
+$images = $vars['images'];
+$album = get_entity($images[0]->container_guid);
+
?>
<div class="contentWrapper">
<form action="<?php echo $vars['url']; ?>action/tidypics/edit_multi" method="post">
<?php
-
- $file_array = $vars['file_array'];
// make sure one of the images becomes the cover if there isn't one already
- $album_entity = get_entity($vars['album_guid']);
- if (!$album_entity->getCoverImageGuid()) {
+ if (!$album->getCoverImageGuid()) {
$no_cover = true;
}
- foreach ($file_array as $key => $file_guid) {
- $entity = get_entity($file_guid);
- $guid = $entity->guid;
- $body = $entity->description;
- $title = $entity->title;
- $tags = $entity->tags;
- $container_guid = $entity->container_guid;
+ foreach ($images as $key => $image) {
+ $guid = $image->guid;
+ $body = $image->description;
+ $title = $image->title;
+ $tags = $image->tags;
// first one is default cover if there isn't one already
if ($no_cover) {
@@ -54,7 +53,7 @@
}
?>
-<input type="hidden" name="container_guid" value="<?php echo $container_guid; ?>" />
+<input type="hidden" name="container_guid" value="<?php echo $album->guid; ?>" />
<p><input type="submit" name="submit" value="<?php echo elgg_echo('save'); ?>" /></p>
</form>
</div> \ No newline at end of file
diff --git a/views/default/tidypics/forms/upload.php b/views/default/tidypics/forms/upload.php
index 691d9701b..5a9703171 100644
--- a/views/default/tidypics/forms/upload.php
+++ b/views/default/tidypics/forms/upload.php
@@ -3,8 +3,7 @@ global $CONFIG;
//this is for image uploads only. Image edits are handled by edit.php form
-$container_guid = get_input('container_guid');
-$album = get_entity($vars['album']);
+$album = $vars['album'];
$access_id = $album->access_id;
$maxfilesize = (float) get_plugin_setting('maxfilesize','tidypics');
@@ -59,8 +58,8 @@ if ($quota) {
</p>
<p>
<?php
- if ($container_guid) {
- echo '<input type="hidden" name="container_guid" value="' . $container_guid . '" />';
+ if ($album) {
+ echo '<input type="hidden" name="album_guid" value="' . $album->guid . '" />';
}
if ($access_id) {
echo '<input type="hidden" name="access_id" value="' . $access_id . '" />';