From d8beb6f5301204cac3b74a827dbbc3082324de6f Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Mon, 9 Nov 2009 13:54:55 -0800 Subject: First cut at replacing swfupload with uploadify. Probably need to review the css and remove extra swfupload selectors. Also changed the dialog so tags can be entered for all the files being uploaded. Probably need to add better start processing so the batch is started before the first image is loaded. Maybe add a module variable so the number of simultaneous uploads can be initiated (currently hard ocded to 10. --- modules/gallery/controllers/simple_uploader.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'modules/gallery/controllers/simple_uploader.php') diff --git a/modules/gallery/controllers/simple_uploader.php b/modules/gallery/controllers/simple_uploader.php index bc508319..36464e24 100644 --- a/modules/gallery/controllers/simple_uploader.php +++ b/modules/gallery/controllers/simple_uploader.php @@ -66,6 +66,15 @@ class Simple_Uploader_Controller extends Controller { log::success("content", t("Added a photo"), html::anchor("photos/$item->id", t("view photo"))); } + $tags = $this->input->post("tags"); + if (!empty($tags)) { + foreach (split(",", $tags) as $tag_name) { + $tag_name = trim($tag_name); + if ($tag_name) { + $tag = tag::add($item, $tag_name); + } + } + } } catch (Exception $e) { Kohana::log("alert", $e->__toString()); if (file_exists($temp_filename)) { -- cgit v1.2.3 From 9546e19e34d08e0d55f066f04149794e566c3539 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 10 Nov 2009 12:49:13 -0800 Subject: Pass two of uploadify... remove the default.css file, removed the folder option and create a status area where succesful uploads are listed. --- lib/uploadify/default.css | 10 --- lib/uploadify/expressInstall.swf | Bin 727 -> 0 bytes modules/gallery/controllers/simple_uploader.php | 9 --- modules/gallery/css/gallery.css | 51 +++---------- modules/gallery/views/simple_uploader.html.php | 91 +++++++++++------------- 5 files changed, 53 insertions(+), 108 deletions(-) delete mode 100644 lib/uploadify/default.css delete mode 100644 lib/uploadify/expressInstall.swf (limited to 'modules/gallery/controllers/simple_uploader.php') diff --git a/lib/uploadify/default.css b/lib/uploadify/default.css deleted file mode 100644 index 2173d9ec..00000000 --- a/lib/uploadify/default.css +++ /dev/null @@ -1,10 +0,0 @@ -body { - font: 12px/16px Arial, Helvetica, sans-serif; -} -#fileQueue { - width: 400px; - height: 300px; - overflow: auto; - border: 1px solid #E5E5E5; - margin-bottom: 10px; -} \ No newline at end of file diff --git a/lib/uploadify/expressInstall.swf b/lib/uploadify/expressInstall.swf deleted file mode 100644 index 0fbf8fca..00000000 Binary files a/lib/uploadify/expressInstall.swf and /dev/null differ diff --git a/modules/gallery/controllers/simple_uploader.php b/modules/gallery/controllers/simple_uploader.php index 36464e24..bc508319 100644 --- a/modules/gallery/controllers/simple_uploader.php +++ b/modules/gallery/controllers/simple_uploader.php @@ -66,15 +66,6 @@ class Simple_Uploader_Controller extends Controller { log::success("content", t("Added a photo"), html::anchor("photos/$item->id", t("view photo"))); } - $tags = $this->input->post("tags"); - if (!empty($tags)) { - foreach (split(",", $tags) as $tag_name) { - $tag_name = trim($tag_name); - if ($tag_name) { - $tag = tag::add($item, $tag_name); - } - } - } } catch (Exception $e) { Kohana::log("alert", $e->__toString()); if (file_exists($temp_filename)) { diff --git a/modules/gallery/css/gallery.css b/modules/gallery/css/gallery.css index 077b21bc..066ab68a 100644 --- a/modules/gallery/css/gallery.css +++ b/modules/gallery/css/gallery.css @@ -56,15 +56,17 @@ /* Simple uploader ~~~~~~~~~~~~~~~~~~~~~~~ */ -#g-add-photos #SWFUpload_0 { - left: 134px; - position: relative; - top: -200px; +#g-add-photos-canvas { + border: 1px solid #ccc; + height: 200px; + margin: .5em 0; + overflow: auto; + width: 469px; } -#g-add-photos-canvas { +#g-add-photos-status { border: 1px solid #ccc; - height: 325px; + height: 125px; margin: .5em 0; overflow: auto; width: 469px; @@ -76,30 +78,9 @@ margin-left: .5em; } -#g-uploadqueue-infobar { - clear: both; -} - -#g-uploadqueue-infobar #g-cancelupload { - cursor: pointer; - display: none; -} - -#g-add-photos-queue .progressbar { - height: 4px; -} - -#g-add-photos-queue .status { - font-size: .75em; -} - -#g-add-photos-queue .box { - padding: .2em; -} - -#g-add-photos-queue .pending { - background-color: #e8e8e8; - border: 1px solid #d7d7d7; +#g-add-photos-status td { + text-align: left; + padding-left: 2em; } #g-add-photos-queue .error { @@ -107,16 +88,6 @@ border: 1px solid #ebb; } -#g-add-photos-queue .uploading { - background-color: #ff9; - border: 1px solid #ee8; -} - -#g-add-photos-queue .complete { - background-color: #cfc; - border: 1px solid #beb; -} - #g-add-photos p { margin: 0 } diff --git a/modules/gallery/views/simple_uploader.html.php b/modules/gallery/views/simple_uploader.html.php index 014919c3..a84a3b00 100644 --- a/modules/gallery/views/simple_uploader.html.php +++ b/modules/gallery/views/simple_uploader.html.php @@ -5,12 +5,10 @@ $("#g-add-photos-canvas").ready(function () { $("#g-uploadify").uploadify({ uploader: "", - folder: "", script: "id}") ?>", scriptData: Session::instance()->id(), "user_agent" => Input::instance()->server("HTTP_USER_AGENT"), - "tags" => "", "csrf" => $csrf)) ?>, fileExt: "*.gif;*.jpg;*.jpeg;*.png;*.flv;*.mp4;*.GIF;*.JPG;*.JPEG;*.PNG;*.FLV;*.MP4", fileDesc: for_js() ?>, @@ -31,6 +29,12 @@ .attr("disabled", "disabled"); return true; }, + onComplete: function(event, queueID, fileObj, response, data) { + $("#g-add-photos-status tbody").append( + "" + fileObj.name + "" + + Math.ceil(fileObj.size / 1000) + " KB" + "" + Math.floor(data.speed) + " KB/s "); + return true; + }, onSelect: function(event) { if ($("#g-upload-cancel-all").hasClass("ui-state-disabled")) { $("#g-upload-cancel-all") @@ -40,15 +44,6 @@ return true; } }); - - $('#g-add-photos-tags').autocomplete( - '', - {max: 30, multiple: true, multipleSeparator: ',', cacheLength: 1} - ); - $('#g-add-photos-tags').blur(function (event) { - $("#g-uploadify").uploadifySettings("scriptData", {"tags": $(this).val()}); - }); - }); @@ -57,47 +52,45 @@ html::purify($item->title))) ?> -
- -
    -
  • - suhosin.session.encrypt setting from Suhosin. You must disable this setting to upload photos.", +
    + +
      +
    • + suhosin.session.encrypt setting from Suhosin. You must disable this setting to upload photos.", array("encrypt_url" => "http://www.hardened-php.net/suhosin/configuration.html#suhosin.session.encrypt", - "suhosin_url" => "http://www.hardened-php.net/suhosin/")) ?> -
    • -
    - + "suhosin_url" => "http://www.hardened-php.net/suhosin/")) ?> +
  • +
+ -
-

- -

-
    - parents() as $i => $parent): ?> - > title) ?> - -
  • title) ?>
  • -
-
- - -
- - -
- +
+

+ +

+
    + parents() as $i => $parent): ?> + > title) ?> + +
  • title) ?>
  • +
+
-
-
+
+
+
+ + + +
+
- - - - - + + + + -- cgit v1.2.3 From 421a975c0e042a56c12a9894afa38f5785d1fe6d Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 11 Nov 2009 18:47:10 -0800 Subject: Improve error handling. --- lib/gallery.common.css | 46 +++++++++++++++++++++++++ modules/gallery/controllers/simple_uploader.php | 2 +- modules/gallery/css/gallery.css | 42 ---------------------- modules/gallery/views/simple_uploader.html.php | 44 +++++++++++++++++++---- 4 files changed, 84 insertions(+), 50 deletions(-) (limited to 'modules/gallery/controllers/simple_uploader.php') diff --git a/lib/gallery.common.css b/lib/gallery.common.css index c80dc90f..7fbb9db0 100644 --- a/lib/gallery.common.css +++ b/lib/gallery.common.css @@ -593,6 +593,52 @@ div#g-action-status { margin-left: 0; } +/* Simple uploader ~~~~~~~~~~~~~~~~~~~~~~~ */ + +#g-add-photos-canvas { + border: 1px solid #ccc; + height: 200px; + margin: .5em 0; + overflow: auto; + width: 469px; +} + +#g-add-photos-status { + border: 1px solid #ccc; + height: 125px; + margin: .5em 0; + overflow: auto; + width: 469px; +} + +#g-add-photos button { + float: right; + margin-bottom: .5em; + margin-left: .5em; +} + +#g-add-photos-status li { + text-align: left; + padding-left: 2em; +} + +#g-add-photos-status li.g-success { + background: #d9efc2 url('images/ico-success.png') no-repeat .4em 50%; +} + +#g-add-photos-status li.g-error { + background: #f6cbca url('images/ico-error.png') no-repeat .4em 50%; +/* color: #f00;*/ +} + +#g-add-photos p { + margin: 0 +} + +#g-add-photos .g-breadcrumbs li { + padding-top: .5em; +} + /** ******************************************************************* * 7) Right to left language styles **********************************************************************/ diff --git a/modules/gallery/controllers/simple_uploader.php b/modules/gallery/controllers/simple_uploader.php index bc508319..d43d2f9d 100644 --- a/modules/gallery/controllers/simple_uploader.php +++ b/modules/gallery/controllers/simple_uploader.php @@ -79,7 +79,7 @@ class Simple_Uploader_Controller extends Controller { print "FILEID: $item->id"; } else { header("HTTP/1.1 400 Bad Request"); - print "ERROR: Invalid Upload"; + print "ERROR: " . t("Invalid Upload"); } } diff --git a/modules/gallery/css/gallery.css b/modules/gallery/css/gallery.css index 066ab68a..113f0e09 100644 --- a/modules/gallery/css/gallery.css +++ b/modules/gallery/css/gallery.css @@ -54,48 +54,6 @@ margin: 0; } -/* Simple uploader ~~~~~~~~~~~~~~~~~~~~~~~ */ - -#g-add-photos-canvas { - border: 1px solid #ccc; - height: 200px; - margin: .5em 0; - overflow: auto; - width: 469px; -} - -#g-add-photos-status { - border: 1px solid #ccc; - height: 125px; - margin: .5em 0; - overflow: auto; - width: 469px; -} - -#g-add-photos button { - float: right; - margin-bottom: .5em; - margin-left: .5em; -} - -#g-add-photos-status td { - text-align: left; - padding-left: 2em; -} - -#g-add-photos-queue .error { - background-color: #fcc; - border: 1px solid #ebb; -} - -#g-add-photos p { - margin: 0 -} - -#g-add-photos .g-breadcrumbs li { - padding-top: .5em; -} - /** ******************************************************************* * 2) Admin **********************************************************************/ diff --git a/modules/gallery/views/simple_uploader.html.php b/modules/gallery/views/simple_uploader.html.php index a84a3b00..8133f6c2 100644 --- a/modules/gallery/views/simple_uploader.html.php +++ b/modules/gallery/views/simple_uploader.html.php @@ -30,11 +30,43 @@ return true; }, onComplete: function(event, queueID, fileObj, response, data) { - $("#g-add-photos-status tbody").append( - "" + fileObj.name + "" + - Math.ceil(fileObj.size / 1000) + " KB" + "" + Math.floor(data.speed) + " KB/s "); + // @todo handle a response of "Error: xxxx" as an error + var re = /^error: (.*)$/i; + var msg = re.exec(response); + if (msg) { + $("#g-add-photos-status ul").append( + "
  • " + fileObj.name + " - " + msg[1] + "
  • "); + } else { + $("#g-add-photos-status ul").append( + "
  • " + fileObj.name + "
  • "); + } return true; }, + + onError: function(event, queueID, fileObj, errorObj) { + var msg = " - "; + if (errorObj.type == "HTTP") { + if (errorObj.info == "500") { + msg += "Error occurred processing the file"; + // Server error - check server logs + } else if (errorObj.info == "404") { + msg += "The upload script was not found."; + // Server script not found + } else { + // Server Error: status: errorObj.info + msg += "Error occurred communication with the server, status: " + errorObj.info; + } + } else if (errorObj.type == "File Size") { + var sizelimit = $("#g-uploadify").uploadifySettings(sizeLimit); + msg += fileObj.name+' '+errorObj.type+' Limit: '+Math.round(d.sizeLimit/1024)+'KB'; + } else { + msg += "Error occurred communication with the server, error " + errorObj.type + ": " + errorObj.info; + } + $("#g-add-photos-status ul").append( + "
  • " + fileObj.name + msg + "
  • "); + $("#g-uploadify" + queueID).remove(); + //return false; + }, onSelect: function(event) { if ($("#g-upload-cancel-all").hasClass("ui-state-disabled")) { $("#g-upload-cancel-all") @@ -79,10 +111,8 @@
    - - - -
    +
      +
    -- cgit v1.2.3