[svn r10493] path real progress bar for the upload

skala
Eric Marguin 19 years ago
parent 6dd23a7750
commit 0d0910d0e2
  1. 8
      main/inc/lib/formvalidator/FormValidator.class.php
  2. 10
      main/inc/lib/javascript/upload.js
  3. 19
      main/inc/lib/upload.xajax.php
  4. 2
      main/upload/upload_ppt.php

@ -224,7 +224,7 @@ EOT;
* @param upload_id the value of the field UPLOAD_IDENTIFIER
* @param delay the frequency of the xajax call
*/
function add_real_progress_bar($upload_id, $delay=2)
function add_real_progress_bar($upload_id, $delay=2,$waitAfterupload=false)
{
if(!function_exists('uploadprogress_get_info'))
{
@ -246,9 +246,9 @@ EOT;
// add the div where the progress bar will be displayed
$this->addElement('html','
<div id="dynamic_div_container" style="display:none">
<div id="dynamic_div_container" style="display:none;">
<div id="dynamic_div_label"></div>
<div id="dynamic_div_frame" style="width:214px; height:12px; border:1px solid grey">
<div id="dynamic_div_frame" style="width:214px; height:12px; border:1px solid grey; background-image:url('.api_get_path(REL_PATH).'main/img/real_upload_frame.gif);background-position:center;">
<div id="dynamic_div_filled" style="width:0%;height:100%;background-image:url('.api_get_path(REL_PATH).'main/img/real_upload_step.gif);background-repeat:repeat-x"></div>
</div>
</div>');
@ -262,7 +262,7 @@ EOT;
// add the upload event
$this->updateAttributes("onsubmit=\"myUpload.startRealUpload('dynamic_div','".$upload_id."','".$label."','".$this->getAttribute('id')."')\"");
$this->updateAttributes("onsubmit=\"myUpload.startRealUpload('dynamic_div','".$upload_id."','".$this->getAttribute('id')."',".$waitAfterupload.")\"");
}

@ -25,18 +25,22 @@ function upload(latency){
/**
* Starts the timer of the real upload progress
*/
function startRealUpload(domid, upload_id){
function startRealUpload(domid, upload_id, formid, waitAfterUpload){
__progress_bar_domid = domid;
__progress_bar_uploadid = upload_id;
__progress_bar_interval = setInterval(__refreshUpload,latency);
__progress_bar_waitAfterUpload = waitAfterUpload;
__upload_form_domid = formid;
__progress_bar_interval = setInterval(__refreshUpload,latency);
document.getElementById(domid+'_container').style.display = 'block';
}
/**
* Function called by a timer to update every x seconds the progress bar
*/
function __refreshUpload(){
xajax_updateProgress(__progress_bar_domid, __progress_bar_uploadid);
xajax_updateProgress(__progress_bar_domid, __progress_bar_uploadid, __progress_bar_waitAfterUpload);
}
/**

@ -1,8 +1,4 @@
<?php
/**
* Xajax action to handle the real progress bar for an upload
* @author Eric Marguin
*/
include("../global.inc.php");
require_once api_get_path(LIBRARY_PATH).'xajax/xajax.inc.php';
@ -15,13 +11,20 @@ $xajax_upload -> processRequests();
* @param div_id where the progress bar is displayed
* @param upload_id the identifier given in the field UPLOAD_IDENTIFIER
*/
function updateProgress($div_id, $upload_id){
function updateProgress($div_id, $upload_id, $waitAfterupload=false){
$objResponse = new XajaxResponse();
$objResponse = new XajaxResponse();
$ul_info = uploadprogress_get_info($upload_id);
$percent = intval($ul_info['bytes_uploaded']*100/$ul_info['bytes_total']);
$objResponse -> addAssign($div_id.'_label' , 'innerHTML', get_lang('Uploading').' : '.$percent.' %');
$objResponse -> addAssign($div_id.'_filled' , 'style.width', $percent.'%');
if($waitAfterupload && $ul_info['est_sec']<5) {
$objResponse -> addAssign($div_id.'_frame','innerHTML','<img src="'.api_get_path(WEB_CODE_PATH).'img/progress_bar.gif" />');
$objResponse -> addAssign($div_id.'_label','innerHTML',get_lang('ProcessingDatas'));
$objResponse -> addScript('clearInterval("myUpload.__progress_bar_interval")');
}
else {
$objResponse -> addAssign($div_id.'_label' , 'innerHTML', get_lang('Uploading').' : '.$percent.' %');
$objResponse -> addAssign($div_id.'_filled' , 'style.width', $percent.'%');
}
return $objResponse;

@ -109,7 +109,7 @@ if(!empty($errorMessage)){
}
$form = new FormValidator('update_course');
$form -> add_real_progress_bar('ppt2lp',1);
$form -> add_real_progress_bar('ppt2lp',1, true);
// build the form
$form -> addElement ('html','<br /><br />');
$form -> addElement('file', 'user_file','<img src="../img/powerpoint_big.gif" />');

Loading…
Cancel
Save