Changeset 4171c59 in github


Ignore:
Timestamp:
Jul 4, 2011 7:40:02 AM (23 months ago)
Author:
alecpl <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
7da13a3
Parents:
5b3ac324
Message:
  • Add optional textual upload progress indicator (#1486039)
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • CHANGELOG

    rb8605bd r4171c59  
    22=========================== 
    33 
     4- Add optional textual upload progress indicator (#1486039) 
    45- Fix parsing URLs containing commas (#1487970) 
    56- Added vertical splitter for books/groups list in addressbook (#1487923) 
  • config/main.inc.php.dist

    r15d7627 r4171c59  
    437437// Must be less than 'session_lifetime' 
    438438$rcmail_config['min_keep_alive'] = 60; 
     439 
     440// Enables files upload indicator. Requires APC installed and enabled apc.rfc1867 option. 
     441// By default refresh time is set to 1 second. You can set this value to true 
     442// or any integer value indicating number of seconds. 
     443$rcmail_config['upload_progress'] = false; 
    439444 
    440445// ---------------------------------- 
  • program/include/main.inc

    r3ddca3b r4171c59  
    20812081} 
    20822082 
     2083function rcube_upload_progress() 
     2084{ 
     2085    global $RCMAIL; 
     2086 
     2087    $prefix = ini_get('apc.rfc1867_prefix'); 
     2088    $params = array( 
     2089        'action' => $RCMAIL->action, 
     2090        'name' => get_input_value('_progress', RCUBE_INPUT_GET), 
     2091    ); 
     2092 
     2093    if (function_exists('apc_fetch')) { 
     2094        $status = apc_fetch($prefix . $params['name']); 
     2095 
     2096        if (!empty($status)) { 
     2097            $status['percent'] = $status['current']/$status['total']*100; 
     2098            $params = array_merge($status, $params); 
     2099        } 
     2100    } 
     2101 
     2102    if (isset($params['percent'])) 
     2103        $params['text'] = rcube_label(array('name' => 'uploadprogress', 'vars' => array( 
     2104            'percent' => $params['percent'] . '%', 
     2105            'current' => show_bytes($params['current']), 
     2106            'total'   => show_bytes($params['total']) 
     2107        ))); 
     2108console($params); 
     2109    $RCMAIL->output->command('upload_progress_update', $params); 
     2110    $RCMAIL->output->send(); 
     2111} 
     2112 
     2113function rcube_upload_progress_init() 
     2114{ 
     2115    global $RCMAIL; 
     2116 
     2117    // Enable upload progress bar 
     2118    if (($seconds = $RCMAIL->config->get('upload_progress')) && ini_get('apc.rfc1867')) { 
     2119        if ($field_name = ini_get('apc.rfc1867_name')) { 
     2120            $RCMAIL->output->set_env('upload_progress_name', $field_name); 
     2121            $RCMAIL->output->set_env('upload_progress_time', (int) $seconds); 
     2122        } 
     2123    } 
     2124} 
  • program/js/app.js

    r5b3ac324 r4171c59  
    32653265 
    32663266      // display upload indicator and cancel button 
    3267       var content = this.get_label('uploading' + (files > 1 ? 'many' : '')), 
     3267      var content = '<span>' + this.get_label('uploading' + (files > 1 ? 'many' : '')) + '</span>', 
    32683268        ts = frame_name.replace(/^rcmupload/, ''); 
    32693269 
    3270       if (this.env.loadingicon) 
     3270      if (!this.env.upload_progress_time && this.env.loadingicon) 
    32713271        content = '<img src="'+this.env.loadingicon+'" alt="" />'+content; 
    32723272      if (this.env.cancelicon) 
    32733273        content = '<a title="'+this.get_label('cancel')+'" onclick="return rcmail.cancel_attachment_upload(\''+ts+'\', \''+frame_name+'\');" href="#cancelupload"><img src="'+this.env.cancelicon+'" alt="" /></a>'+content; 
    32743274      this.add2attachment_list(ts, { name:'', html:content, complete:false }); 
     3275 
     3276      // upload progress support 
     3277      if (this.env.upload_progress_time) { 
     3278        this.upload_progress_start('upload', ts); 
     3279      } 
    32753280    } 
    32763281 
     
    33353340    $("iframe[name='"+frame_name+"']").remove(); 
    33363341    return false; 
     3342  }; 
     3343 
     3344  this.upload_progress_start = function(action, name) 
     3345  { 
     3346    window.setTimeout(function() { rcmail.http_request(action, {_progress: name}); }, 
     3347      this.env.upload_progress_time * 1000); 
     3348  }; 
     3349 
     3350  this.upload_progress_update = function(param) 
     3351  { 
     3352    var elem = $('#'+param.name + '> span'); 
     3353 
     3354    if (!elem.length || !param.text) 
     3355      return; 
     3356 
     3357    elem.text(param.text); 
     3358 
     3359    if (!param.done) 
     3360      this.upload_progress_start(param.action, param.name); 
    33373361  }; 
    33383362 
     
    56035627      frame_name = 'rcmupload'+ts; 
    56045628 
     5629    // upload progress support 
     5630    if (this.env.upload_progress_name) { 
     5631      var fname = this.env.upload_progress_name, 
     5632        field = $('input[name='+fname+']', form); 
     5633 
     5634      if (!field.length) { 
     5635        field = $('<input>').attr({type: 'hidden', name: fname}); 
     5636        field.appendTo(form); 
     5637      } 
     5638 
     5639      field.val(ts); 
     5640    } 
     5641 
    56055642    // have to do it this way for IE 
    56065643    // otherwise the form will be posted to a new window 
  • program/localization/en_US/labels.inc

    r9caf9ca r4171c59  
    211211$labels['attachments'] = 'Attachments'; 
    212212$labels['upload'] = 'Upload'; 
     213$labels['uploadprogress'] = '$percent ($current from $total)'; 
    213214$labels['close']  = 'Close'; 
    214215$labels['messageoptions']  = 'Message options...'; 
  • program/steps/mail/attachments.inc

    r569701d r4171c59  
    2020*/ 
    2121 
     22// Upload progress update 
     23if (!empty($_GET['_progress'])) { 
     24  rcube_upload_progress(); 
     25} 
    2226 
    2327$COMPOSE_ID = get_input_value('_id', RCUBE_INPUT_GPC); 
  • program/steps/mail/compose.inc

    ra208a4f r4171c59  
    12001200function rcmail_compose_attachment_form($attrib) 
    12011201{ 
    1202   global $OUTPUT; 
     1202  global $RCMAIL, $OUTPUT; 
    12031203 
    12041204  // add ID if not given 
    12051205  if (!$attrib['id']) 
    12061206    $attrib['id'] = 'rcmUploadbox'; 
     1207 
     1208  // Enable upload progress bar 
     1209  rcube_upload_progress_init(); 
    12071210 
    12081211  // find max filesize value 
Note: See TracChangeset for help on using the changeset viewer.