Author: sevein
Date: Fri Sep 11 09:13:59 2009
New Revision: 3228

Log:
Multi-upload new feature for file size detection based on 
QubitDigitalObject::getMaxUploadSize() and YUI uploader. Improvable.

Modified:
   trunk/apps/qubit/modules/digitalobject/templates/multiFileUploadSuccess.php
   trunk/web/js/multiFileUpload.js

Modified: 
trunk/apps/qubit/modules/digitalobject/templates/multiFileUploadSuccess.php
==============================================================================
--- trunk/apps/qubit/modules/digitalobject/templates/multiFileUploadSuccess.php 
Fri Sep 11 00:08:33 2009        (r3227)
+++ trunk/apps/qubit/modules/digitalobject/templates/multiFileUploadSuccess.php 
Fri Sep 11 09:13:59 2009        (r3228)
@@ -58,6 +58,7 @@
 <?php echo javascript_tag('
   YAHOO.widget.Uploader.SWFURL = "'.$uploadSwfPath.'";
 
+  var maxUploadSize = "'.$maxUploadSize.'";
   var uploadTmpDir = "'.$uploadTmpDir.'";
   var uploadResponsePath = "'.$uploadResponsePath.'";
 
@@ -65,6 +66,7 @@
   var i18nInfoObjectTitle = "'.__('%1% title', array('%1%' => 
sfConfig::get('app_ui_label_informationobject'))).'";
   var i18nFilename  = "'.__('file name').'";
   var i18nFilesize  = "'.__('file size').'";
+  var i18nOversizedFileListMessage = "'.__('These files couldn\'t be uploaded 
because of file size upload limits').'";
 '); ?>
 
 <?php echo javascript_tag(<<<EOF

Modified: trunk/web/js/multiFileUpload.js
==============================================================================
--- trunk/web/js/multiFileUpload.js     Fri Sep 11 00:08:33 2009        (r3227)
+++ trunk/web/js/multiFileUpload.js     Fri Sep 11 09:13:59 2009        (r3228)
@@ -63,26 +63,59 @@
   if ('fileList' in event && event.fileList != null)
   {
     fileList = event.fileList;
+    var oversizedFileList = new Array();
 
     // Make space for a thumbnail and progress bar
     for (var i in fileList)
     {
       var fileHash = fileList[i].id;
+      var fileName = fileList[i].name;
+      var fileSize = fileList[i].size; // bytes
 
-      // Create an upload block for this digital object
-      var uploadBlock = '<div id="upload-' + fileHash + '" 
class="multiFileUpload">';
-      uploadBlock    += '<div id="thumbnail-' + fileHash + '" 
class="digitalObject" style="width: ' + thumbWidth + 'px">';
-      uploadBlock    += '</div>';
-      $('#uploads').append(uploadBlock);
-
-      // Insert placeholder for thumbnail ("upload text + progress bar div")
-      var progress  = '<span style="color: #999; text-align: left">' + 
i18nUploading + '</span><br />';
-      progress     += '<div class="progress-bar" style="width=: ' + thumbWidth 
+ 'px;"></div>';
-      $('#thumbnail-' + fileHash).html(progress)
-
-      // Initialize progress bar
-      var progbar = '<div style="height:5px;width:' + thumbWidth + 
'px;background-color:#CCC;"></div>';
-      $('#thumbnail-' + fileHash + ' div.progress-bar').html(progbar);
+      if (fileSize > maxUploadSize)
+      {
+          oversizedFileList[oversizedFileList.length] = fileName;
+          uploader.removeFile(fileHash);
+      }
+      else
+      {
+        // Create an upload block for this digital object
+        var uploadBlock = '<div id="upload-' + fileHash + '" 
class="multiFileUpload">';
+        uploadBlock    += '<div id="thumbnail-' + fileHash + '" 
class="digitalObject" style="width: ' + thumbWidth + 'px">';
+        uploadBlock    += '</div>';
+        $('#uploads').append(uploadBlock);
+
+        // Insert placeholder for thumbnail ("upload text + progress bar div")
+        var progress  = '<span style="color: #999; text-align: left">' + 
i18nUploading + '</span><br />';
+        progress     += '<div class="progress-bar" style="width=: ' + 
thumbWidth + 'px;"></div>';
+        $('#thumbnail-' + fileHash).html(progress)
+
+        // Initialize progress bar
+        var progbar = '<div style="height:5px;width:' + thumbWidth + 
'px;background-color:#CCC;"></div>';
+        $('#thumbnail-' + fileHash + ' div.progress-bar').html(progbar);
+      }
+    }
+
+    // Show a list of files that couldn't be uploaded because maxUploadSize 
limit
+    if (oversizedFileList.length > 0)
+    {
+      if ($('#oversizedFileList').length)
+      {
+        $('#oversizedFileList').remove();
+      }
+
+      var oversizedFileListBlock = '<div id=\"oversizedFileList\">';
+      oversizedFileListBlock += '<p>' + i18nOversizedFileListMessage + ': ';
+
+      for (var j in oversizedFileList)
+      {
+        oversizedFileListBlock += oversizedFileList[j] + (j < 
(oversizedFileList.length - 1) ? ', ' : '');
+      }
+
+      oversizedFileListBlock += '.</p>';
+      oversizedFileListBlock += '</div>';
+
+      $('#uploads').before(oversizedFileListBlock);
     }
 
     // Start upload

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.ca/group/qubit-commits?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to