diff options
author | alecpl <alec@alec.pl> | 2011-07-04 11:40:02 +0000 |
---|---|---|
committer | alecpl <alec@alec.pl> | 2011-07-04 11:40:02 +0000 |
commit | 4171c59bd79a54c1fd65128f7100247a4dec8720 (patch) | |
tree | 3261b05d91324840570c8ebe6b1084e26793701d /program/include | |
parent | 5b3ac324154b0d29e6e14db2b06fbc3636a3e708 (diff) |
- Add optional textual upload progress indicator (#1486039)
Diffstat (limited to 'program/include')
-rw-r--r-- | program/include/main.inc | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/program/include/main.inc b/program/include/main.inc index 7e2875ae9..2a5a66020 100644 --- a/program/include/main.inc +++ b/program/include/main.inc @@ -2080,3 +2080,45 @@ function rcube_log_bug($arg_arr) } } +function rcube_upload_progress() +{ + global $RCMAIL; + + $prefix = ini_get('apc.rfc1867_prefix'); + $params = array( + 'action' => $RCMAIL->action, + 'name' => get_input_value('_progress', RCUBE_INPUT_GET), + ); + + if (function_exists('apc_fetch')) { + $status = apc_fetch($prefix . $params['name']); + + if (!empty($status)) { + $status['percent'] = $status['current']/$status['total']*100; + $params = array_merge($status, $params); + } + } + + if (isset($params['percent'])) + $params['text'] = rcube_label(array('name' => 'uploadprogress', 'vars' => array( + 'percent' => $params['percent'] . '%', + 'current' => show_bytes($params['current']), + 'total' => show_bytes($params['total']) + ))); +console($params); + $RCMAIL->output->command('upload_progress_update', $params); + $RCMAIL->output->send(); +} + +function rcube_upload_progress_init() +{ + global $RCMAIL; + + // Enable upload progress bar + if (($seconds = $RCMAIL->config->get('upload_progress')) && ini_get('apc.rfc1867')) { + if ($field_name = ini_get('apc.rfc1867_name')) { + $RCMAIL->output->set_env('upload_progress_name', $field_name); + $RCMAIL->output->set_env('upload_progress_time', (int) $seconds); + } + } +} |