* ignorewarnings fixes
authorMichael Dale <dale@users.mediawiki.org>
Mon, 27 Jul 2009 21:32:25 +0000 (21:32 +0000)
committerMichael Dale <dale@users.mediawiki.org>
Mon, 27 Jul 2009 21:32:25 +0000 (21:32 +0000)
* removed extra debug statement
* supports do_close_session_update for php based requests

includes/HttpFunctions.php
includes/api/ApiUpload.php
js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js
js2/mwEmbed/libAddMedia/remoteSearchDriver.js

index 849ff7c..6d77136 100644 (file)
@@ -286,7 +286,7 @@ class HttpRequest {
                $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;
+               $this->do_close_session_update = ( isset( $opt['do_close_session_update'] ) ) ? true : false;
        }
 
        /**
@@ -461,7 +461,7 @@ class HttpRequest {
 
                // 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;
@@ -540,15 +540,15 @@ class simpleFileWriter {
                }
 
                // if more than session_update_interval second have passed update_session_progress
-               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() ){
-                               $this->status = $session_status;
-                               wfDebug( __METHOD__ . ' update session failed or was canceled');
-                               return 0;
-                       }
+               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() ){
+                                       $this->status = $session_status;
+                                       wfDebug( __METHOD__ . ' update session failed or was canceled');
+                                       return 0;
+                               }
                }
                return strlen( $data_packet );
        }
index b4e0dda..89dd1be 100644 (file)
@@ -72,8 +72,9 @@ class ApiUpload extends ApiBase {
                                $this->dieUsageMsg( $this->mUpload->status['error'] );
 
                } else if( $this->mParams['internalhttpsession'] ){
-                       $sd = & $_SESSION['wsDownload'][$this->mParams['internalhttpsession']];
+                       $sd = & $_SESSION['wsDownload'][ $this->mParams['internalhttpsession'] ];
 
+                       wfDebug("InternalHTTP:: " . print_r($this->mParams, true));
                        // get the params from the init session:
                        $this->mUpload = new UploadFromFile();
 
@@ -274,8 +275,6 @@ class ApiUpload extends ApiBase {
                        array_flip( $imProp ),
                        $this->getResult() );
 
-               wfDebug( "\n\n return result: " . print_r( $result, true ) );
-
                return $result;
        }
 
index 9b0efc4..64089c7 100644 (file)
@@ -194,10 +194,12 @@ mvBaseUploadInterface.prototype = {
                        var httpUpConf ={
                            'url'               : $j('#wpUploadFileURL').val(),
                            'filename'  : $j('#wpDestFile').val(),
-                           'comment'   : $j('#wpUploadDescription').val(),
-                               'ignorewarnings' :      ($j('#wpIgnoreWarning').is(':checked')) ?'true':'false' ,
+                           'comment'   : $j('#wpUploadDescription').val(),                             
                                'watch'         :  ($j('#wpWatchthis').is(':checked'))?'true':'false'                                       
                        }
+                       if( $j('#wpIgnoreWarning').is(':checked') ){
+                               httpUpConf[ 'ignorewarnings'] =  'true';
+                       }
                        //check for editToken
                        _this.etoken = $j("input[name='wpEditToken']").val();                                           
                        _this.doHttpUpload( httpUpConf );
@@ -459,8 +461,13 @@ mvBaseUploadInterface.prototype = {
                                _this.warnings_sessionkey = apiRes.upload.warnings.sessionkey;
                        var bObj = {};
                        bObj[ gM('ignorewarning') ] =   function() { 
-                                                                                        js_error('todo: ignore warnings action '); 
-                                                                                       };
+                               //re-inciate the upload proccess
+                               $j('#wpIgnoreWarning').attr('checked', true);
+                               $j( '#mw-upload-form' ).submit();                                                                                         
+                       };
+                       bObj[ gM('return-to-form') ] = function(){
+                               $j(this).dialog('close');
+                       }
                        _this.updateProgressWin(  gM('uploadwarning'),  '<h3>' + gM('uploadwarning') + '</h3>' +wmsg + '<p>',bObj);
                        return false;
                }                                                       
index 8a3eddc..45ef3da 100644 (file)
@@ -1380,12 +1380,12 @@ remoteSearchDriver.prototype = {
                                                //not sure if we can do remote url uploads (so just do a local post)
                                                js_log('got token for new page:' +editToken);                                                                           
                                                var postVars = {
-                                                       'wpSourceType'          :'web',
-                                                       'wpUploadFileURL'        : rObj.src,
-                                                       'wpDestFile'              : rObj.target_resource_title,
-                                                       'wpUploadDescription' : $j('#rsd_import_ta').val(),
-                                                       'wpWatchthis'            : $j('#wpWatchthis').val(),    
-                                                       'wpUpload'                      : 'Upload file'                                                                                                                                                                                                                                                                                                                         
+                                                       'wpSourceType'                  :'web',
+                                                       'wpUploadFileURL'               : rObj.src,
+                                                       'wpDestFile'                    : rObj.target_resource_title,
+                                                       'wpUploadDescription'   : $j('#rsd_import_ta').val(),
+                                                       'wpWatchthis'                   : $j('#wpWatchthis').val(),     
+                                                       'wpUpload'                              : 'Upload file'                                                                                                                                                                                                                                                                                                                         
                                                }
                                                //set to uploading:                                                                                                                                                                                     
                                                $j('#rsd_resource_import').append('<div id="rsd_import_progress"'+