aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2012-07-13 22:50:23 -0400
committerCash Costello <cash.costello@gmail.com>2012-07-13 22:50:23 -0400
commit01730a85bced88f32d88efac995ea12294934a63 (patch)
tree62b71d96d02fce3a75393da08219714fdad4789d
parent919ae814fa2b651072b5bbb901e2183220a0dd30 (diff)
parent5cc8de829c0a7b86c8df27293f4825d0e340d592 (diff)
downloadelgg-01730a85bced88f32d88efac995ea12294934a63.tar.gz
elgg-01730a85bced88f32d88efac995ea12294934a63.tar.bz2
flash uploader working
-rw-r--r--actions/ajax_upload.php61
-rw-r--r--actions/ajax_upload_complete.php56
-rw-r--r--actions/photos/image/ajax_upload.php57
-rw-r--r--actions/photos/image/ajax_upload_complete.php74
-rw-r--r--actions/photos/image/upload.php2
-rw-r--r--classes/TidypicsImage.php2
-rw-r--r--lib/tidypics.php2
-rw-r--r--lib/watermark.php8
-rw-r--r--pages/photos/image/upload.php8
-rw-r--r--start.php43
-rw-r--r--views/default/forms/photos/ajax_upload.php66
-rw-r--r--views/default/js/photos/uploading.php85
-rw-r--r--views/default/photos/css.php169
13 files changed, 358 insertions, 275 deletions
diff --git a/actions/ajax_upload.php b/actions/ajax_upload.php
deleted file mode 100644
index 1f5588197..000000000
--- a/actions/ajax_upload.php
+++ /dev/null
@@ -1,61 +0,0 @@
-<?php
-/**
- * Elgg single upload action for flash/ajax uploaders
- *
- */
-
-include_once dirname(dirname(__FILE__)) . "/lib/upload.php";
-
-$album_guid = (int) get_input('album_guid');
-$file_var_name = get_input('file_var_name', 'Image');
-
-$album = get_entity($album_guid);
-if (!$album) {
- exit;
-}
-
-// probably POST limit exceeded
-if (empty($_FILES)) {
- echo 'Image was too large';
- exit;
-}
-
-$image_lib = get_plugin_setting('image_lib', 'tidypics');
-if (!$image_lib) {
- $image_lib = "GD";
-}
-
-$temp_file = $_FILES['Image']['tmp_name'];
-$name = $_FILES['Image']['name'];
-$file_size = $_FILES['Image']['size'];
-
-$mime = tp_upload_get_mimetype($name);
-if ($mime == 'unknown') {
- echo 'Not an image';
- exit;
-}
-
-$image = new TidypicsImage();
-$image->container_guid = $album_guid;
-$image->setMimeType($mime);
-$image->simpletype = "image";
-$image->access_id = $album->access_id;
-$image->title = substr($name, 0, strrpos($name, '.'));
-$image->batch = get_input('batch');
-$result = $image->save();
-
-$image->setOriginalFilename($name);
-$image->saveImageFile($temp_file, $file_size);
-
-$image->extractExifData();
-$image->saveThumbnails($image_lib);
-
-$album->prependImageList(array($image->guid));
-
-
-if (get_plugin_setting('img_river_view', 'tidypics') === "all") {
- add_to_river('river/object/image/create', 'create', $image->owner_guid, $image->guid);
-}
-
-echo "success";
-exit; \ No newline at end of file
diff --git a/actions/ajax_upload_complete.php b/actions/ajax_upload_complete.php
deleted file mode 100644
index 2abca50dc..000000000
--- a/actions/ajax_upload_complete.php
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php
-/**
- * A batch is complete so check if this is first upload to album
- *
- */
-
-$album_guid = (int) get_input('album_guid');
-
-$album = get_entity($album_guid);
-if (!$album) {
- exit;
-}
-
-if ($album->new_album == TP_NEW_ALBUM) {
- $new_album = true;
-} else {
- $new_album = false;
-}
-
-if ($album->new_album == TP_NEW_ALBUM) {
- $album->new_album = TP_OLD_ALBUM;
-
- // we throw the notification manually here so users are not told about the new album until there
- // is at least a few photos in it
- object_notifications('create', 'object', $album);
-
- add_to_river('river/object/album/create', 'create', $album->owner_guid, $album->guid);
-}
-
-$params = array(
- 'type' => 'object',
- 'subtype' => 'image',
- 'metadata_names' => 'batch',
- 'metadata_values' => get_input('batch'),
-);
-$images = elgg_get_entities_from_metadata($params);
-if ($images) {
- // Create a new batch object to contain these photos
- $batch = new ElggObject();
- $batch->subtype = "tidypics_batch";
- $batch->access_id = ACCESS_PUBLIC;
- $batch->container_guid = $album->guid;
- if ($batch->save()) {
- foreach ($images as $image) {
- add_entity_relationship($image->guid, "belongs_to_batch", $batch->getGUID());
- }
- if (get_plugin_setting('img_river_view', 'tidypics') == "batch" && $new_album == false) {
- add_to_river('river/object/tidypics_batch/create', 'create', $batch->getObjectOwnerGUID(), $batch->getGUID());
- }
- }
-}
-
-// plugins can register to be told when a Tidypics album has had images added
-trigger_elgg_event('upload', 'tp_album', $album);
-
-exit; \ No newline at end of file
diff --git a/actions/photos/image/ajax_upload.php b/actions/photos/image/ajax_upload.php
new file mode 100644
index 000000000..d6b083cf6
--- /dev/null
+++ b/actions/photos/image/ajax_upload.php
@@ -0,0 +1,57 @@
+<?php
+/**
+ * Elgg single upload action for flash/ajax uploaders
+ */
+
+elgg_load_library('tidypics:upload');
+
+$album_guid = (int) get_input('album_guid');
+$file_var_name = get_input('file_var_name', 'Image');
+$batch = get_input('batch');
+
+$album = get_entity($album_guid);
+if (!$album) {
+ echo elgg_echo('tidypics:baduploadform');
+ exit;
+}
+
+// probably POST limit exceeded
+if (empty($_FILES)) {
+ trigger_error('Tidypics warning: user exceeded post limit on image upload', E_USER_WARNING);
+ register_error(elgg_echo('tidypics:exceedpostlimit'));
+ exit;
+}
+
+$file = $_FILES['Image'];
+
+$mime = tp_upload_get_mimetype($file['name']);
+if ($mime == 'unknown') {
+ echo 'Not an image';
+ exit;
+}
+
+// we have to override the mime type because uploadify sends everything as application/octet-string
+$file['type'] = $mime;
+
+$image = new TidypicsImage();
+$image->container_guid = $album->getGUID();
+$image->setMimeType($mime);
+$image->access_id = $album->access_id;
+$image->batch = $batch;
+
+try {
+ $image->save($file);
+ $album->prependImageList(array($image->guid));
+
+ if (elgg_get_plugin_setting('img_river_view', 'tidypics') === "all") {
+ add_to_river('river/object/image/create', 'create', $image->getObjectOwnerGUID(), $image->getGUID());
+ }
+
+ echo elgg_echo('success');
+} catch (Exception $e) {
+ // remove the bits that were saved
+ $image->delete();
+ echo $e->getMessage();
+}
+
+exit; \ No newline at end of file
diff --git a/actions/photos/image/ajax_upload_complete.php b/actions/photos/image/ajax_upload_complete.php
new file mode 100644
index 000000000..6d398b3aa
--- /dev/null
+++ b/actions/photos/image/ajax_upload_complete.php
@@ -0,0 +1,74 @@
+<?php
+/**
+ * A batch is complete so check if this is first upload to album
+ *
+ */
+
+$batch = get_input('batch');
+$album_guid = (int) get_input('album_guid');
+$img_river_view = elgg_get_plugin_setting('img_river_view', 'tidypics');
+
+$album = get_entity($album_guid);
+if (!elgg_instanceof($album, 'object', 'album')) {
+ exit;
+}
+
+$params = array(
+ 'type' => 'object',
+ 'subtype' => 'image',
+ 'metadata_names' => 'batch',
+ 'metadata_values' => $batch,
+ 'limit' => 0
+);
+
+$images = elgg_get_entities_from_metadata($params);
+if ($images) {
+ // Create a new batch object to contain these photos
+ $batch = new ElggObject();
+ $batch->subtype = "tidypics_batch";
+ $batch->access_id = ACCESS_PUBLIC;
+ $batch->container_guid = $album->guid;
+
+ if ($batch->save()) {
+ foreach ($images as $image) {
+ add_entity_relationship($image->guid, "belongs_to_batch", $batch->getGUID());
+ }
+ }
+} else {
+ // @todo some sort of message to edit them manually.
+ exit;
+}
+
+// "added images to album" river
+if ($img_river_view == "batch" && $album->new_album == false) {
+ add_to_river('river/object/tidypics_batch/create', 'create', $batch->getObjectOwnerGUID(), $batch->getGUID());
+}
+
+// "created album" river
+if ($album->new_album) {
+ $album->new_album = false;
+ $album->first_upload = true;
+
+ add_to_river('river/object/album/create', 'create', $album->getOwnerGUID(), $album->getGUID());
+
+ // "created album" notifications
+ // we throw the notification manually here so users are not told about the new album until
+ // there are at least a few photos in it
+ if ($album->shouldNotify()) {
+ object_notifications('create', 'object', $album);
+ $album->last_notified = time();
+ }
+} else {
+ // "added image to album" notifications
+ if ($album->first_upload) {
+ $album->first_upload = false;
+ }
+
+ if ($album->shouldNotify()) {
+ object_notifications('create', 'object', $album);
+ $album->last_notified = time();
+ }
+}
+
+echo json_encode(array('batch_guid' => $batch->getGUID()));
+exit; \ No newline at end of file
diff --git a/actions/photos/image/upload.php b/actions/photos/image/upload.php
index 29df59b63..b917a1598 100644
--- a/actions/photos/image/upload.php
+++ b/actions/photos/image/upload.php
@@ -50,6 +50,8 @@ foreach ($_FILES['images']['name'] as $index => $value) {
continue;
}
+ $mime = tp_upload_get_mimetype($data['name']);
+
$image = new TidypicsImage();
$image->container_guid = $album->getGUID();
$image->setMimeType($mime);
diff --git a/classes/TidypicsImage.php b/classes/TidypicsImage.php
index a64743017..c0b5de723 100644
--- a/classes/TidypicsImage.php
+++ b/classes/TidypicsImage.php
@@ -302,7 +302,7 @@ class TidypicsImage extends ElggFile {
}
$file = new ElggFile();
- $file->owner_guid = $this->getObjectOwnerGUID();
+ $file->owner_guid = $this->getOwnerGUID();
$file->setFilename($thumb);
return $file->grabFile();
}
diff --git a/lib/tidypics.php b/lib/tidypics.php
index 16773f982..77a8787f6 100644
--- a/lib/tidypics.php
+++ b/lib/tidypics.php
@@ -196,7 +196,7 @@ function tidypics_list_photos(array $options = array()) {
foreach ($entities as $entity) {
$keys[] = $entity->guid;
}
- var_dump($options);
+
$entities = array_combine($keys, $entities);
$sorted_entities = array();
diff --git a/lib/watermark.php b/lib/watermark.php
index ce77c00e2..5b9a4abcd 100644
--- a/lib/watermark.php
+++ b/lib/watermark.php
@@ -48,7 +48,7 @@ function tp_get_watermark_filename($text, $owner) {
function tp_gd_watermark($image) {
global $CONFIG;
- $watermark_text = get_plugin_setting('watermark_text', 'tidypics');
+ $watermark_text = elgg_get_plugin_setting('watermark_text', 'tidypics');
if (!$watermark_text) {
return;
}
@@ -58,7 +58,7 @@ function tp_gd_watermark($image) {
return;
}
- $owner = get_loggedin_user();
+ $owner = elgg_get_logged_in_user_guid();
$watermark_text = tp_process_watermark_text($watermark_text, $owner);
@@ -91,13 +91,13 @@ function tp_gd_watermark($image) {
*/
function tp_imagick_watermark($filename) {
- $watermark_text = get_plugin_setting('watermark_text', 'tidypics');
+ $watermark_text = elgg_get_plugin_setting('watermark_text', 'tidypics');
if (!$watermark_text) {
return false;
}
// plugins can do their own watermark and return false to prevent this function from running
- if (trigger_plugin_hook('tp_watermark', 'imagick', $filename, true) === false) {
+ if (elgg_trigger_plugin_hook('tp_watermark', 'imagick', $filename, true) === false) {
return true;
}
diff --git a/pages/photos/image/upload.php b/pages/photos/image/upload.php
index 0c327d53e..395651ca9 100644
--- a/pages/photos/image/upload.php
+++ b/pages/photos/image/upload.php
@@ -14,12 +14,6 @@ if (!$album_guid) {
forward();
}
-if (elgg_get_plugin_setting('uploader', 'tidypics')) {
- $uploader = get_input('uploader', 'ajax');
-} else {
- $uploader = 'basic';
-}
-
$album = get_entity($album_guid);
if (!$album) {
// @todo
@@ -44,7 +38,7 @@ elgg_push_breadcrumb($owner->name, "photos/owner/$owner->username");
elgg_push_breadcrumb($album->getTitle(), $album->getURL());
elgg_push_breadcrumb(elgg_echo('album:addpix'));
-
+$uploader = get_input('uploader');
if ($uploader == 'basic') {
$content = elgg_view('forms/photos/basic_upload', array('entity' => $album));
} else {
diff --git a/start.php b/start.php
index 6ef3af541..1129c7f2f 100644
--- a/start.php
+++ b/start.php
@@ -12,7 +12,6 @@ elgg_register_event_handler('init', 'system', 'tidypics_init');
* Tidypics plugin initialization
*/
function tidypics_init() {
-
// Include core libraries
require dirname(__FILE__) . "/lib/tidypics.php";
@@ -78,14 +77,14 @@ function tidypics_init() {
elgg_register_plugin_hook_handler('notify:entity:message', 'object', 'tidypics_notify_message');
-/*
+ // ajax handler for uploads when use_only_cookies is set
+ elgg_register_plugin_hook_handler('forward', 'csrf', 'tidypics_ajax_session_handler');
+
+ /*
// Register for notifications
// slideshow plugin hook
register_plugin_hook('tp_slideshow', 'album', 'tidypics_slideshow');
-
- // ajax handler for uploads when use_only_cookies is set
- register_plugin_hook('forward', 'system', 'tidypics_ajax_session_handler');
*/
// Register actions
$base_dir = elgg_get_plugins_path() . 'tidypics/actions/photos';
@@ -95,8 +94,8 @@ function tidypics_init() {
elgg_register_action("photos/image/upload", "$base_dir/image/upload.php");
elgg_register_action("photos/image/save", "$base_dir/image/save.php");
elgg_register_action("photos/batch/edit", "$base_dir/batch/edit.php");
- //register_action("tidypics/ajax_upload", true, "$base_dir/ajax_upload.php");
- //register_action("tidypics/ajax_upload_complete", true, "$base_dir/ajax_upload_complete.php");
+ elgg_register_action("photos/image/ajax_upload", "$base_dir/image/ajax_upload.php", 'logged_in');
+ elgg_register_action("photos/image/ajax_upload_complete", "$base_dir/image/ajax_upload_complete.php", 'logged_in');
elgg_register_action("photos/image/tag", "$base_dir/image/tag.php");
elgg_register_action("photos/image/untag", "$base_dir/image/untag.php");
@@ -192,7 +191,14 @@ function tidypics_page_handler($page) {
case "upload": // upload images to album
set_input('guid', $page[1]);
- set_input('uploader', elgg_extract(2, $page, 'basic'));
+
+ if (elgg_get_plugin_setting('uploader', 'tidypics')) {
+ $default_uploader = 'ajax';
+ } else {
+ $default_uploader = 'basic';
+ }
+
+ set_input('uploader', elgg_extract(2, $page, $default_uploader));
require "$base/image/upload.php";
break;
@@ -454,15 +460,15 @@ function tp_mostrecentimages($max = 8, $pagination = true) {
* @param string $returnvalue
* @param array $params
*/
-function tidypics_ajax_session_handler($hook, $entity_type, $returnvalue, $params) {
- global $CONFIG;
+function tidypics_ajax_session_handler($hook, $entity_type, $value, $params) {
+ $www_root = elgg_get_config('wwwroot');
+ $url = $params['current_url'];
- $url = current_page_url();
- if ($url !== "{$CONFIG->wwwroot}action/tidypics/ajax_upload/") {
+ if ($url !== "{$www_root}action/photos/image/ajax_upload") {
return;
}
- if (get_loggedin_userid() != 0) {
+ if (elgg_get_logged_in_user_guid() != 0) {
return;
}
@@ -472,10 +478,15 @@ function tidypics_ajax_session_handler($hook, $entity_type, $returnvalue, $param
$token = get_input('__elgg_token');
$ts = get_input('__elgg_ts');
$session_id = get_input('Elgg');
+ $session_token = get_input('session_token');
$tidypics_token = get_input('tidypics_token');
$user_guid = get_input('user_guid');
-
$user = get_user($user_guid);
+ $timeout = elgg_get_config('action_token_timeout');
+ if (!$timeout) {
+ $timeout = 2;
+ }
+
if (!$user) {
return;
}
@@ -493,12 +504,14 @@ function tidypics_ajax_session_handler($hook, $entity_type, $returnvalue, $param
$generated_token = md5($session_id . get_site_secret() . $ts . $user->salt);
if ($tidypics_token !== $generated_token) {
+ echo "bad tp token";
return;
}
// passed token test, so login and process action
login($user);
- include $CONFIG->actions['tidypics/ajax_upload']['file'];
+ $actions = elgg_get_config('actions');
+ include $actions['photos/image/ajax_upload']['file'];
exit;
}
diff --git a/views/default/forms/photos/ajax_upload.php b/views/default/forms/photos/ajax_upload.php
index f0738994a..be25d628e 100644
--- a/views/default/forms/photos/ajax_upload.php
+++ b/views/default/forms/photos/ajax_upload.php
@@ -2,26 +2,22 @@
/**
* Tidypics ajax upload form body
*
- * @uses $vars['album']
+ * @uses $vars['entity']
*/
-$album = $vars['album'];
+$album = $vars['entity'];
$ts = time();
-$token = generate_action_token($ts);
$batch = time();
-$tidypics_token = md5(session_id() . get_site_secret() . $ts . get_loggedin_user()->salt);
-
+$tidypics_token = md5(session_id() . get_site_secret() . $ts . elgg_get_logged_in_user_entity()->salt);
$basic_uploader_url = current_page_url() . '/basic';
-$upload_endpoint_url = "{$vars['url']}action/tidypics/ajax_upload/";
-$upload_complete_url = "{$vars['url']}action/tidypics/ajax_upload_complete/";
-$maxfilesize = (float) get_plugin_setting('maxfilesize','tidypics');
+$maxfilesize = (float) elgg_get_plugin_setting('maxfilesize', 'tidypics');
if (!$maxfilesize) {
$maxfilesize = 5;
}
-$quota = get_plugin_setting('quota','tidypics');
+$quota = elgg_get_plugin_setting('quota', 'tidypics');
if ($quota) {
$image_repo_size_md = get_metadata_byname($album->container_guid, "image_repo_size");
$image_repo_size = (int)$image_repo_size_md->value;
@@ -40,30 +36,32 @@ if ($quota) {
?>
-<div class="contentWrapper">
-
- <p><?php echo sprintf(elgg_echo('tidypics:uploader:instructs'), $basic_uploader_url); ?></p>
+<p><?php echo elgg_echo('tidypics:uploader:instructs', array($basic_uploader_url)); ?></p>
- <ul id="tidypics_uploader_steps">
- <li>
- <div id="tidypics_uploader">
- <a id="tidypics_choose_button" href="<?php echo $basic_uploader_url; ?>">
- 1. <?php echo elgg_echo('tidypics:uploader:choose'); ?>
- </a>
- <div id="tidypics_flash_uploader">
- <input type="file" id="uploadify" name="uploadify" />
- </div>
- </div>
- </li>
- <li>
- <a id="tidypics_upload_button" class="tidypics_disable" href="javascript:$('#uploadify').uploadifyUpload();">
- 2. <?php echo elgg_echo('tidypics:uploader:upload'); ?>
+<ul id="tidypics-uploader-steps">
+ <li class="mbm">
+ <div id="tidypics-uploader">
+ <a id="tidypics-choose-button" href="<?php echo $basic_uploader_url; ?>">
+ 1. <?php echo elgg_echo('tidypics:uploader:choose'); ?>
</a>
- </li>
- <li>
- <a id="tidypics_describe_button" class="tidypics_disable" href="<?php echo $vars['url']; ?>pg/photos/batch/<?php echo $batch; ?>">
- 3. <?php echo elgg_echo('tidypics:uploader:describe'); ?>
- </a>
- </li>
- </ul>
-</div>
+ <div id="tidypics-flash-uploader">
+ <input type="file" id="uploadify" name="uploadify" class="hidden" />
+ <input type="hidden" name="album_guid" value="<?php echo $album->getGUID(); ?>" />
+ <input type="hidden" name="batch" value="<?php echo $batch; ?>" />
+ <input type="hidden" name="tidypics_token" value="<?php echo $tidypics_token; ?>" />
+ <input type="hidden" name="user_guid" value="<?php echo elgg_get_logged_in_user_guid(); ?>" />
+ <input type="hidden" name="Elgg" value="<?php echo session_id(); ?>" />
+ </div>
+ </div>
+ </li>
+ <li class="mbm">
+ <a id="tidypics-upload-button" class="tidypics-disable" href="#">
+ 2. <?php echo elgg_echo('tidypics:uploader:upload'); ?>
+ </a>
+ </li>
+ <li class="mbm">
+ <a id="tidypics-describe-button" class="tidypics-disable" href="#">
+ 3. <?php echo elgg_echo('tidypics:uploader:describe'); ?>
+ </a>
+ </li>
+</ul>
diff --git a/views/default/js/photos/uploading.php b/views/default/js/photos/uploading.php
index 59448dd46..cb79dc77c 100644
--- a/views/default/js/photos/uploading.php
+++ b/views/default/js/photos/uploading.php
@@ -1,27 +1,92 @@
<?php
/**
- *
+ * AJAX uploading
*/
-
-$site_url = elgg_get_site_url();
-$upload_endpoint_url = "{$site_url}action/tidypics/ajax_upload/";
-$upload_complete_url = "{$site_url}action/tidypics/ajax_upload_complete/";
-
?>
+//<script>
elgg.provide('elgg.tidypics.uploading');
elgg.tidypics.uploading.init = function() {
+
+ var fields = ['Elgg', 'user_guid', 'album_guid', 'batch', 'tidypics_token'];
+ var data = elgg.security.token;
+
+ $(fields).each(function(i, name) {
+ var value = $('input[name=' + name + ']').val();
+ if (value) {
+ data[name] = value;
+ }
+ });
+
+ data['XDEBUG_SESSION_START'] = 'netbeans-xdebug';
+
$("#uploadify").uploadify({
- 'uploader' : '<?php echo $site_url; ?>mod/tidypics/vendors/uploadify/uploadify.swf',
- 'script' : '<?php echo $upload_endpoint_url; ?>',
+ 'uploader' : elgg.config.wwwroot + 'mod/tidypics/vendors/uploadify/uploadify.swf',
+ 'script' : elgg.config.wwwroot + 'action/photos/image/ajax_upload',
+ 'cancelImg' : elgg.config.wwwroot + 'mod/tidypics/vendors/uploadify/cancel.png',
'fileDataName' : 'Image',
'multi' : true,
'auto' : false,
'wmode' : 'transparent',
'buttonImg' : " ",
- 'height' : 20,
- 'width' : 130
+ 'height' : $('#tidypics-choose-button').height(),
+ 'width' : $('#tidypics-choose-button').width(),
+ 'scriptData' : data,
+ 'onEmbedFlash' : function(event) {
+ // @todo This is supposed to mimick hovering over the link.
+ // hover events aren't firing for the object.
+ $("#" + event.id).hover(
+ function(){
+ $("#tidypics-choose-button").addClass('tidypics-choose-button-hover');
+ },
+ function(){
+ $("#tidypics-choose-button").removeClass('tidypics-choose-button-hover');
+ }
+ );
+ },
+ 'onSelectOnce' : function() {
+ $("#tidypics-upload-button").removeClass('tidypics-disable');
+ },
+ 'onAllComplete' : function() {
+ // @todo they can keep adding pics if they want. no need to disable this.
+ $("#tidypics-choose-button").addClass('tidypics-disable');
+ $("#tidypics-upload-button").addClass('tidypics-disable').die();
+ $("#tidypics-describe-button").removeClass('tidypics-disable');
+
+ elgg.action('photos/image/ajax_upload_complete', {
+ data: {
+ album_guid: data.album_guid,
+ batch: data.batch
+ },
+ success: function(json) {
+ var url = elgg.normalize_url('photos/edit/' + json.batch_guid)
+ $('#tidypics-describe-button').attr('href', url);
+ }
+ });
+ },
+ 'onComplete' : function(event, queueID, fileObj, response) {
+ // check for errors here
+ if (response != 'success') {
+ $("#uploadify" + queueID + " .percentage").text(" - " + response);
+ $("#uploadify" + queueID).addClass('uploadifyError');
+ }
+ $("#uploadify" + queueID + " > .cancel").remove();
+ return false;
+ },
+ 'onCancel' : function(event, queueID, fileObj, data) {
+ if (data.fileCount == 0) {
+ $("#tidypics-upload-button").addClass('tidypics-disable');
+ }
+ }
+
+ });
+
+ // bind to upload button
+ $('#tidypics-upload-button').live('click', function(e) {
+ var $uploadify = $('#uploadify');
+ $uploadify.uploadifyUpload();
+ e.preventDefault();
});
}
diff --git a/views/default/photos/css.php b/views/default/photos/css.php
index 3e448f27a..2290e1f9a 100644
--- a/views/default/photos/css.php
+++ b/views/default/photos/css.php
@@ -130,12 +130,82 @@
Tagging
*************************************** */
#tidypics_uploader {
-position:relative;
-width:400px;
-min-height:20px;
+ position:relative;
+ width:400px;
+ min-height:20px;
}
#tidypics_choose_button {
+ position:absolute;
+ top:0;
+ left:0;
+ z-index:0;
+ display:block;
+ float:left;
+}
+
+#tidypics_flash_uploader {
+ position:relative;
+ z-index:100;
+}
+
+/* ***************************************
+ AJAX UPLOADER
+*************************************** */
+#tidypics-uploader-steps {
+ list-style: none;
+}
+
+#tidypics-uploader-steps li a {
+ font-weight:bold;
+}
+
+.tidypics-choose-button-hover {
+ color:#0054a7;
+ text-decoration:underline;
+}
+
+.tidypics-disable {
+ color:#cccccc;
+}
+
+.tidypics-disable:hover {
+color:#cccccc;
+text-decoration:none;
+}
+
+
+.uploadifyQueueItem {
+background-color:#F5F5F5;
+border:2px solid #E5E5E5;
+font-size:11px;
+margin-top:5px;
+padding:10px;
+width:350px;
+}
+
+.uploadifyProgress {
+background-color:#FFFFFF;
+border-color:#808080 #C5C5C5 #C5C5C5 #808080;
+border-style:solid;
+border-width:1px;
+margin-top:10px;
+width:100%;
+}
+
+.uploadifyProgressBar {
+background-color: #0054a7;
+width: 1px;
+height: 3px;
+}
+
+#tidypics-uploader {
+ position:relative;
+ width:400px;
+ min-height:20px;
+}
+
+#tidypics-choose-button {
position:absolute;
top:0;
left:0;
@@ -144,11 +214,20 @@ display:block;
float:left;
}
-#tidypics_flash_uploader {
+#tidypics-flash-uploader {
position:relative;
z-index:100;
}
+.uploadifyQueueItem .cancel {
+ float: right;
+}
+
+.uploadifyError {
+border: 2px solid #FBCBBC;
+background-color: #FDE5DD;
+}
+
<?php
return true;
?>
@@ -465,88 +544,6 @@ display:inline;
list-style: none;
}
-/*----- uploadify ------*/
-
-#tidypics_uploader_steps {
-list-style:none;
-}
-
-#tidypics_uploader_steps li {
-margin-bottom: 20px;
-}
-
-#tidypics_uploader_steps li a {
-font-weight:bold;
-}
-
-.tidypics_choose_button_hover {
-color:#0054a7;
-text-decoration:underline;
-}
-
-.tidypics_disable {
-color:#cccccc;
-}
-
-.tidypics_disable:hover {
-color:#cccccc;
-text-decoration:none;
-}
-
-
-.uploadifyQueueItem {
-background-color:#F5F5F5;
-border:2px solid #E5E5E5;
-font-size:11px;
-margin-top:5px;
-padding:10px;
-width:350px;
-}
-
-.uploadifyProgress {
-background-color:#FFFFFF;
-border-color:#808080 #C5C5C5 #C5C5C5 #808080;
-border-style:solid;
-border-width:1px;
-margin-top:10px;
-width:100%;
-}
-
-.uploadifyProgressBar {
-background-color: #0054a7;
-width: 1px;
-height: 3px;
-}
-
-#tidypics_uploader {
-position:relative;
-width:400px;
-min-height:20px;
-}
-
-#tidypics_choose_button {
-position:absolute;
-top:0;
-left:0;
-z-index:0;
-display:block;
-float:left;
-}
-
-#tidypics_flash_uploader {
-position:relative;
-z-index:100;
-}
-
-.uploadifyQueueItem .cancel {
-float: right;
-}
-
-.uploadifyError {
-border: 2px solid #FBCBBC;
-background-color: #FDE5DD;
-}
-
#tidypics_album_sort {
padding:0;
margin:0;