$req = new HttpRequest( $sd['url'], array(
'target_file_path' => $sd['target_file_path'],
'upload_session_key'=> $upload_session_key,
- 'timeout' => $wgAsyncHTTPTimeout
+ 'timeout' => $wgAsyncHTTPTimeout,
+ 'do_close_session_update' => true
) );
// run the actual request .. (this can take some time)
wfDebug( __METHOD__ . 'do Request: ' . $sd['url'] . ' tf: ' . $sd['target_file_path'] );
$this->target_file_path = ( isset( $opt['target_file_path'] ) ) ? $opt['target_file_path'] : false;
$this->upload_session_key = ( isset( $opt['upload_session_key'] ) ) ? $opt['upload_session_key'] : false;
$this->headers_only = ( isset( $opt['headers_only'] ) ) ? $opt['headers_only'] : false;
+ $this->do_close_session_update = ( isset( $opt['do_close_session_update'] ) ) ? $opt['do_close_session_update'] : false;
}
/**
// set the write back function (if we are writing to a file)
if( $this->target_file_path ){
- $cwrite = new simpleFileWriter( $this->target_file_path, $this->upload_session_key );
+ $cwrite = new simpleFileWriter( $this->target_file_path,
+ $this->upload_session_key,
+ $this->do_close_session_update
+ );
if( !$cwrite->status->isOK() ){
wfDebug( __METHOD__ . "ERROR in setting up simpleFileWriter\n" );
$status = $cwrite->status;
var $session_id = null;
var $session_update_interval = 0; // how often to update the session while downloading
- function simpleFileWriter( $target_file_path, $upload_session_key ){
+ function simpleFileWriter( $target_file_path, $upload_session_key, $do_close_session_update = false ){
$this->target_file_path = $target_file_path;
$this->upload_session_key = $upload_session_key;
$this->status = Status::newGood();
+ $this->do_close_session_update = $do_close_session_update;
// open the file:
$this->fp = fopen( $this->target_file_path, 'w' );
if( $this->fp === false ){
}
// if more than session_update_interval second have passed update_session_progress
- if( $this->upload_session_key && ( ( time() - $this->prevTime ) > $this->session_update_interval ) ) {
+ if( $this->do_close_session_update &&
+ $this->upload_session_key && ( ( time() - $this->prevTime ) > $this->session_update_interval ) ) {
$this->prevTime = time();
$session_status = $this->update_session_progress();
if( !$session_status->isOK() ){
var httpUpConf ={
'url' : $j('#wpUploadFileURL').val(),
'filename' : $j('#wpDestFile').val(),
- 'comment' : $j('#wpUploadDescription').val()
+ 'comment' : $j('#wpUploadDescription').val(),
+ 'ignorewarnings' : ($j('#wpIgnoreWarning').is(':checked')) ?'true':'false' ,
+ 'watch' : ($j('#wpWatchthis').is(':checked'))?'true':'false'
}
//check for editToken
_this.etoken = $j("input[name='wpEditToken']").val();
//else try and get a token:
if(!_this.etoken && _this.api_url){
- js_log('Error:doHttpUpload: missing token');
-
+ js_log('Error:doHttpUpload: missing token');
}else{
req['token'] =_this.etoken;
}
+ //reset the done with action flag:
+ _this.action_done = false;
//do the api req
do_api_req({
'data': req,
bObj[ gM('ignorewarning') ] = function() {
js_error('todo: ignore warnings action ');
};
- _this.updateProgressWin( gM('uploadwarning'), '<h3>' + gM('uploadwarning') + '</h3>' +msg + '<p>',bObj);
+ _this.updateProgressWin( gM('uploadwarning'), '<h3>' + gM('uploadwarning') + '</h3>' +wmsg + '<p>',bObj);
return false;
}
//should be "OK"
if( apiRes.upload.imageinfo && apiRes.upload.imageinfo.descriptionurl ){
var url = apiRes.upload.imageinfo.descriptionurl;
//check done action:
- if(_this.done_upload_cb){
+ if( _this.done_upload_cb && typeof _this.done_upload_cb == 'function'){
//close up shop:
$j('#upProgressDialog').dialog('close');
//call the callback:
_this.done_upload_cb( url );
}else{
var bObj = {};
+ bObj[ gM('return-to-form')] = function(){
+ $j(this).dialog('close');
+ }
bObj[ gM('go-to-resource') ] = function(){
window.location = url;
- };
+ };
+ _this.action_done = true;
_this.updateProgressWin( gM('successfulupload'), gM( 'mv_upload_done', url), bObj);
js_log('apiRes.upload.imageinfo::'+url);
}
},
cancel_action:function(dlElm){
//confirm:
- if( confirm( gM('mv-cancel-confim') )){
- alert("do dialog close:: cancel_action mvbase");
+ if( confirm( gM('mv-cancel-confim') )){
//@@todo (cancel the encode / upload)
- $j(dlElm).dialog('close');
+ $j(this).dialog('close');
return false;
}else{
return true;