From: Cash Costello
Date: Mon, 25 Oct 2010 00:22:20 +0000 (+0000)
Subject: supporting both basic and flash uploader
X-Git-Url: https://gitweb.fluxo.info/?a=commitdiff_plain;h=893364a28955358ad259bfb75798560616ab3d49;p=lorea%2Felgg.git
supporting both basic and flash uploader
---
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) {
-
Instructions here for uploading images using Ajax/Flash
-
-
Upload Files |
-
Clear Queue
+
Instructions here for uploading images using Ajax/Flash
+
+
+
+
Upload Files
+
+
+
Add titles and descriptions
+
+
Basic uploader
+
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);
+
?>
\ 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) {
';
+ if ($album) {
+ echo ' ';
}
if ($access_id) {
echo ' ';