Changeset 11975


Ignore:
Timestamp:
Aug 19, 2011, 6:04:43 PM (9 years ago)
Author:
plg
Message:

feature 2410 added: uploadify upgraded from version 2.1.0 to 3.0.0 (still beta,
but said as stable by users on uploadify forums)

bug 2411 fixed: thanks to uploadify 3.0.0, the "Browse" button is now localized
(text in any language)

bug 1653 fixed: if the selected file exceeds the upload_max_size (as defined in
the php.ini), an alert is shown and the file is not added to the queue.

bug 2412 fixed: ability to select GIF files with the Flash Uploader.

Location:
trunk/admin
Files:
2 added
2 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/photos_add_direct_prepare.inc.php

    r11966 r11975  
    8686  $max_upload_width = round(sqrt($available_memory/(2 * $fudge_factor)));
    8787  $max_upload_height = round(2 * $max_upload_width / 3);
    88   $max_upload_resolution = floor($max_upload_width * $max_upload_height / (1024 * 1024));
     88 
     89  // we don't want dimensions like 2995x1992 but 3000x2000
     90  $max_upload_width = round($max_upload_width/100)*100;
     91  $max_upload_height = round($max_upload_height/100)*100;
     92 
     93  $max_upload_resolution = floor($max_upload_width * $max_upload_height / (1000000));
    8994
    9095  // no need to display a limitation warning if the limitation is huge like 20MP
  • trunk/admin/include/photos_add_direct_process.inc.php

    r11962 r11975  
    4343      );
    4444  }
    45  
    46   $category_id = $_POST['category'];
    47 
     45  else
     46  {
     47    $category_id = $_POST['category'];
     48  }
     49
     50  if (isset($_POST['onUploadError']) and is_array($_POST['onUploadError']) and count($_POST['onUploadError']) > 0)
     51  {
     52    foreach ($_POST['onUploadError'] as $error)
     53    {
     54      array_push($page['errors'], $error);
     55    }
     56  }
     57   
    4858  $image_ids = array();
    4959       
  • trunk/admin/include/uploadify/uploadify.css

    r11966 r11975  
    11/*
    2 Uploadify v2.1.0
    3 Release Date: August 24, 2009
    4 
    5 Copyright (c) 2009 Ronnie Garcia, Travis Nickels
     2Uploadify v3.0.0
     3Copyright (c) 2010 Ronnie Garcia
    64
    75Permission is hereby granted, free of charge, to any person obtaining a copy
     
    2321THE SOFTWARE.
    2422*/
     23
     24.uploadify {margin:0 auto 10px auto}
     25
     26.uploadifyButton {
     27        display: block;
     28        cursor: pointer;
     29        font-size: 11px;
     30        font-weight: bold;
     31        color: #eeeeee;
     32        padding: 8px 0;
     33        text-align: center;
     34        height: 14px;
     35        width: 100%;
     36        background-color: #464646;
     37-webkit-border-radius:5px;
     38-moz-border-radius:5px;
     39border-radius:5px;
     40letter-spacing:2px;
     41}
     42.uploadify:hover .uploadifyButton {
     43        color:#fff;
     44        background-color: #333;
     45        cursor:pointer;
     46}
     47.uploadifyQueueItem {
     48        background-color: #F5F5F5;
     49        -webkit-border-radius: 3px;
     50        -moz-border-radius: 3px;
     51        border-radius: 3px;
     52        font: 11px Verdana, Geneva, sans-serif;
     53        margin-top: 5px;
     54        max-width: 350px;
     55        padding: 10px;
     56}
     57.uploadifyQueueItem .cancel {
     58        float: right;
     59}
     60.uploadifyQueueItem .fileName, .uploadifyQueueItem .data {
     61        float: left;
     62}
     63.uploadifyQueue .completed {
     64        background-color: #E5E5E5;
     65}
     66.uploadifyProgress {
     67        background-color: #E5E5E5;
     68        margin-top: 25px;
     69        height: 3px;
     70        width: 100%;
     71        position: relative;
     72}
     73.uploadifyProgressBar {
     74        background-color: #0099FF;
     75        height: 3px;
     76        width: 1px;
     77        position: absolute;
     78        left: 0px;
     79}
     80.uploadifyError {
     81        background-color: #FDE5DD !important;
     82}
     83
     84
     85/* Piwigo specific */
    2586#fileQueue {
    2687        width: 420px;
     
    50111        background-color: #333;
    51112        border: 1px solid #666;
    52         margin-top: 10px;
    53113        width: 100%;
    54114}
  • trunk/admin/themes/default/template/photos_add_direct.tpl

    r11967 r11975  
    11{if $upload_mode eq 'multiple'}
    22{combine_script id='jquery.jgrowl' load='footer' require='jquery' path='themes/default/js/plugins/jquery.jgrowl_minimized.js' }
    3 {combine_script id='swfobject' load='footer' path='admin/include/uploadify/swfobject.js'}
    4 {combine_script id='jquery.uploadify' load='footer' require='jquery' path='admin/include/uploadify/jquery.uploadify.v2.1.0.min.js' }
     3{combine_script id='jquery.uploadify' load='footer' require='jquery' path='admin/include/uploadify/jquery.uploadify.v3.0.0.min.js' }
    54{combine_css path="admin/themes/default/uploadify.jGrowl.css"}
    65{combine_css path="admin/include/uploadify/uploadify.css"}
     
    177176var session_id = '{$session_id}';
    178177var pwg_token = '{$pwg_token}';
    179 var buttonText = 'Browse';
    180 var sizeLimit = {$upload_max_filesize};
     178var buttonText = "{'Select files'|@translate}";
     179var sizeLimit = Math.round({$upload_max_filesize} / 1024); /* in KBytes */
    181180
    182181{literal}
    183182  jQuery("#uploadify").uploadify({
    184     'uploader'       : uploadify_path + '/uploadify.swf',
    185     'script'         : uploadify_path + '/uploadify.php',
    186     'scriptData'     : {
    187       'upload_id' : upload_id,
    188       'session_id' : session_id,
    189       'pwg_token' : pwg_token,
    190     },
    191     'cancelImg'      : uploadify_path + '/cancel.png',
     183    'uploader'       : uploadify_path + '/uploadify.php',
     184    'langFile'       : uploadify_path + '/uploadifyLang_en.js',
     185    'swf'            : uploadify_path + '/uploadify.swf',
     186
     187    buttonCursor     : 'pointer',
     188    'buttonText'     : buttonText,
     189    'width'          : 300,
     190    'cancelImage'    : uploadify_path + '/cancel.png',
    192191    'queueID'        : 'fileQueue',
    193192    'auto'           : false,
    194     'buttonText'     : buttonText,
    195193    'multi'          : true,
    196     'fileDesc'       : 'Photo files (*.jpg,*.jpeg,*.png)',
    197     'fileExt'        : '*.jpg;*.JPG;*.jpeg;*.JPEG;*.png;*.PNG',
    198     'sizeLimit'      : sizeLimit,
     194    'fileTypeDesc'   : 'Photo files',
     195    'fileTypeExts'   : '*.jpg;*.JPG;*.jpeg;*.JPEG;*.png;*.PNG;*.gif;*.GIF',
     196    'fileSizeLimit'  : sizeLimit,
     197    'progressData'   : 'percentage',
     198    requeueErrors   : false,
    199199    'onSelect'       : function(event,ID,fileObj) {
    200200      jQuery("#fileQueue").show();
    201201    },
    202     'onAllComplete'  : function(event, data) {
    203       if (data.errors) {
     202    'onQueueComplete'  : function(stats) {
     203      jQuery("input[name=submit_upload]").click();
     204    },
     205    onUploadError: function (file,errorCode,errorMsg,errorString,swfuploadifyQueue) {
     206      /* uploadify calls the onUploadError trigger when the user cancels a file! */
     207      /* There no error so we skip it to avoid panic.                            */
     208      if ("Cancelled" == errorString) {
    204209        return false;
    205210      }
    206       else {
    207         jQuery("input[name=submit_upload]").click();
    208       }
    209     },
    210     onError: function (event, queueID ,fileObj, errorObj) {
    211       var msg;
    212 
    213       if (errorObj.type === "HTTP") {
    214         if (errorObj.info === 404) {
    215           alert('Could not find upload script.');
    216           msg = 'Could not find upload script.';
    217         }
    218         else {
    219           msg = errorObj.type+": "+errorObj.info;
    220         }
    221       }
    222       else if (errorObj.type ==="File Size") {
    223         msg = "File too big";
    224         msg = msg + '<br>'+fileObj.name+': '+humanReadableFileSize(fileObj.size);
    225         msg = msg + '<br>Limit: '+humanReadableFileSize(sizeLimit);
    226       }
    227       else {
    228         msg = errorObj.type+": "+errorObj.info;
    229       }
     211
     212      var msg = file.name+', '+errorString;
     213
     214      /* Let's put the error message in the form to display once the form is     */
     215      /* performed, it makes support easier when user can copy/paste the error   */
     216      /* thrown.                                                                 */
     217      jQuery("#uploadForm").append('<input type="hidden" name="onUploadError[]" value="'+msg+'">');
    230218
    231219      jQuery.jGrowl(
    232         '<p></p>'+msg,
     220        '<p></p>onUploadError '+msg,
    233221        {
    234222          theme:  'error',
    235223          header: 'ERROR',
    236           sticky: true
    237         }
    238       );
    239 
    240       jQuery("#fileUploadgrowl" + queueID).fadeOut(
    241         250,
    242         function() {
    243           jQuery("#fileUploadgrowl" + queueID).remove()
    244         }
    245       );
    246       return false;
    247     },
    248     onCancel: function (a, b, c, d) {
    249       var msg = "Cancelled uploading: "+c.name;
    250       jQuery.jGrowl(
    251         '<p></p>'+msg,
    252         {
    253           theme:  'warning',
    254           header: 'Cancelled Upload',
    255224          life:   4000,
    256225          sticky: false
    257226        }
    258227      );
     228
     229      return false;
    259230    },
    260     onClearQueue: function (a, b) {
    261       var msg = "Cleared "+b.fileCount+" files from queue";
    262       jQuery.jGrowl(
    263         '<p></p>'+msg,
    264         {
    265           theme:  'warning',
    266           header: 'Cleared Queue',
    267           life:   4000,
    268           sticky: false
    269         }
    270       );
    271     },
    272     onComplete: function (a, b ,c, response, e) {
    273       var size = Math.round(c.size/1024);
    274 
    275       var response = jQuery.parseJSON(response);
    276 
     231    onUploadSuccess: function (file,data,response) {
     232      var data = jQuery.parseJSON(data);
    277233      jQuery("#uploadedPhotos").parent("fieldset").show();
    278       jQuery("#uploadedPhotos").prepend('<img src="'+response.thumbnail_url+'" class="thumbnail"> ');
    279 
    280       jQuery.jGrowl(
    281         '<p></p>'+c.name+' - '+size+'KB',
    282         {
    283           theme:  'success',
    284           header: 'Upload Complete',
    285           life:   4000,
    286           sticky: false
    287         }
    288       );
     234
     235      /* Let's display the thumbnail of the uploaded photo, no need to wait the  */
     236      /* end of the queue                                                        */
     237      jQuery("#uploadedPhotos").prepend('<img src="'+data.thumbnail_url+'" class="thumbnail"> ');
    289238    }
    290239  });
     
    296245
    297246    jQuery("#uploadify").uploadifySettings(
    298       'scriptData',
     247      'postData',
    299248      {
    300249        'category_id' : jQuery("select[name=category] option:selected").val(),
    301250        'level' : jQuery("select[name=level] option:selected").val(),
     251        'upload_id' : upload_id,
     252        'session_id' : session_id,
     253        'pwg_token' : pwg_token,
    302254      }
    303255    );
     
    413365
    414366{elseif $upload_mode eq 'multiple'}
    415    
    416     <p>
    417       <input type="file" name="uploadify" id="uploadify">
    418     </p>
     367    <div id="uploadify">You've got a problem with your JavaScript</div>
    419368
    420369    <div id="fileQueue" style="display:none"></div>
Note: See TracChangeset for help on using the changeset viewer.