Index: trunk/phase3/includes/upload/UploadFromChunks.php |
— | — | @@ -57,13 +57,14 @@ |
58 | 58 | // check for the file: |
59 | 59 | return (bool)$request->getFileTempName( 'file' ); |
60 | 60 | } |
61 | | - |
62 | 61 | /* check warnings depending on chunk_mode */ |
63 | 62 | function checkWarnings(){ |
64 | | - $warning = array(); |
65 | | - return $warning; |
| 63 | + if( $this->chunk_mode == UploadFromChunks::DONE ){ |
| 64 | + return parent::checkWarnings(); |
| 65 | + }else{ |
| 66 | + return array(); |
| 67 | + } |
66 | 68 | } |
67 | | - |
68 | 69 | function isEmptyFile(){ |
69 | 70 | // does not apply to chunk init |
70 | 71 | if( $this->chunk_mode == UploadFromChunks::INIT ){ |
— | — | @@ -72,20 +73,17 @@ |
73 | 74 | return parent::isEmptyFile(); |
74 | 75 | } |
75 | 76 | } |
76 | | - |
77 | 77 | /** |
78 | 78 | * Verify whether the upload is sane. |
79 | 79 | * Returns self::OK or else an array with error information |
80 | 80 | */ |
81 | 81 | function verifyUpload() { |
82 | | - // no checks on chunk upload mode: |
83 | | - if( $this->chunk_mode == UploadFromChunks::INIT ) |
84 | | - return array( 'status' => self::OK ); |
85 | | - |
86 | | - // verify on init and last chunk request |
87 | | - if( $this->chunk_mode == UploadFromChunks::CHUNK || |
88 | | - $this->chunk_mode == UploadFromChunks::DONE ) |
| 82 | + // verify once DONE uploading chunks |
| 83 | + if( $this->chunk_mode == UploadFromChunks::DONE ){ |
89 | 84 | return parent::verifyUpload(); |
| 85 | + }else{ |
| 86 | + return array( 'status' => self::OK ); |
| 87 | + } |
90 | 88 | } |
91 | 89 | |
92 | 90 | // only run verifyFile on completed uploaded chunks |
— | — | @@ -185,7 +183,7 @@ |
186 | 184 | return $status; |
187 | 185 | } |
188 | 186 | } else if( $this->chunk_mode == UploadFromChunks::DONE ){ |
189 | | - // update the values from the local (session init) if not paseed again) |
| 187 | + // update the values from the local (session init) if not passed again) |
190 | 188 | if( $summary == '' ) |
191 | 189 | $summary = $this->mSummary; |
192 | 190 | |
— | — | @@ -194,7 +192,9 @@ |
195 | 193 | |
196 | 194 | if( $watch == '' ) |
197 | 195 | $watch = $this->mWatch; |
| 196 | + |
198 | 197 | $status = parent::performUpload( $summary, $comment, $watch, $user ); |
| 198 | + |
199 | 199 | if( !$status->isGood() ) { |
200 | 200 | return $status; |
201 | 201 | } |
— | — | @@ -209,7 +209,6 @@ |
210 | 210 | ) |
211 | 211 | ); |
212 | 212 | exit( 0 ); |
213 | | - |
214 | 213 | } |
215 | 214 | } |
216 | 215 | |
Index: trunk/phase3/includes/api/ApiUpload.php |
— | — | @@ -57,11 +57,11 @@ |
58 | 58 | // Check whether upload is enabled |
59 | 59 | if ( !UploadBase::isEnabled() ) |
60 | 60 | $this->dieUsageMsg( array( 'uploaddisabled' ) ); |
61 | | - |
| 61 | + |
62 | 62 | // One and only one of the following parameters is needed |
63 | 63 | $this->requireOnlyOneParameter( $this->mParams, |
64 | | - 'sessionkey', 'file', 'url', 'enablechunks' ); |
65 | | - |
| 64 | + 'sessionkey', 'file', 'url', 'enablechunks' ); |
| 65 | + |
66 | 66 | if ( $this->mParams['enablechunks'] ) { |
67 | 67 | /** |
68 | 68 | * Chunked upload mode |
— | — | @@ -88,11 +88,10 @@ |
89 | 89 | /** |
90 | 90 | * Return the status of the given background upload session_key: |
91 | 91 | */ |
92 | | - |
93 | 92 | // Check the session key |
94 | 93 | if( !isset( $_SESSION['wsDownload'][$this->mParams['sessionkey']] ) ) |
95 | 94 | return $this->dieUsageMsg( array( 'invalid-session-key' ) ); |
96 | | - |
| 95 | + |
97 | 96 | $sd =& $_SESSION['wsDownload'][$this->mParams['sessionkey']]; |
98 | 97 | // Keep passing down the upload sessionkey |
99 | 98 | $statusResult = array( |
— | — | @@ -100,22 +99,22 @@ |
101 | 100 | ); |
102 | 101 | |
103 | 102 | // put values into the final apiResult if available |
104 | | - if( isset( $sd['apiUploadResult'] ) ) |
| 103 | + if( isset( $sd['apiUploadResult'] ) ) |
105 | 104 | $statusResult['apiUploadResult'] = $sd['apiUploadResult']; |
106 | | - if( isset( $sd['loaded'] ) ) |
| 105 | + if( isset( $sd['loaded'] ) ) |
107 | 106 | $statusResult['loaded'] = $sd['loaded']; |
108 | | - if( isset( $sd['content_length'] ) ) |
| 107 | + if( isset( $sd['content_length'] ) ) |
109 | 108 | $statusResult['content_length'] = $sd['content_length']; |
110 | 109 | |
111 | | - return $this->getResult()->addValue( null, |
| 110 | + return $this->getResult()->addValue( null, |
112 | 111 | $this->getModuleName(), $statusResult ); |
113 | | - |
| 112 | + |
114 | 113 | } elseif( $this->mParams['sessionkey'] ) { |
115 | 114 | /** |
116 | 115 | * Upload stashed in a previous request |
117 | 116 | */ |
118 | 117 | $this->mUpload = new UploadFromStash(); |
119 | | - $this->mUpload->initialize( $this->mParams['filename'], |
| 118 | + $this->mUpload->initialize( $this->mParams['filename'], |
120 | 119 | $_SESSION['wsUploadData'][$this->mParams['sessionkey']] ); |
121 | 120 | } else { |
122 | 121 | /** |
— | — | @@ -135,14 +134,14 @@ |
136 | 135 | ); |
137 | 136 | } elseif ( isset( $this->mParams['url'] ) ) { |
138 | 137 | $this->mUpload = new UploadFromUrl(); |
139 | | - $this->mUpload->initialize( $this->mParams['filename'], |
| 138 | + $this->mUpload->initialize( $this->mParams['filename'], |
140 | 139 | $this->mParams['url'], $this->mParams['asyncdownload'] ); |
141 | 140 | |
142 | 141 | $status = $this->mUpload->fetchFile(); |
143 | 142 | if( !$status->isOK() ) { |
144 | 143 | return $this->dieUsage( 'fetchfileerror', $status->getWikiText() ); |
145 | 144 | } |
146 | | - |
| 145 | + |
147 | 146 | // check if we doing a async request set session info and return the upload_session_key) |
148 | 147 | if( $this->mUpload->isAsync() ){ |
149 | 148 | $upload_session_key = $status->value; |
— | — | @@ -161,11 +160,11 @@ |
162 | 161 | } |
163 | 162 | } |
164 | 163 | } |
165 | | - |
| 164 | + |
166 | 165 | if( !isset( $this->mUpload ) ) |
167 | 166 | $this->dieUsage( 'No upload module set', 'nomodule' ); |
168 | | - |
169 | | - |
| 167 | + |
| 168 | + |
170 | 169 | // Finish up the exec command: |
171 | 170 | $this->doExecUpload(); |
172 | 171 | |
— | — | @@ -196,7 +195,7 @@ |
197 | 196 | if( $permErrors !== true ) { |
198 | 197 | $this->dieUsageMsg( array( 'baddaccess-groups' ) ); |
199 | 198 | } |
200 | | - |
| 199 | + |
201 | 200 | // TODO: Move them to ApiBase's message map |
202 | 201 | $verification = $this->mUpload->verifyUpload(); |
203 | 202 | if( $verification['status'] !== UploadBase::OK ) { |
— | — | @@ -210,8 +209,8 @@ |
211 | 210 | break; |
212 | 211 | case UploadBase::FILETYPE_BADTYPE: |
213 | 212 | global $wgFileExtensions; |
214 | | - $this->dieUsage( 'This type of file is banned', 'filetype-banned', |
215 | | - 0, array( |
| 213 | + $this->dieUsage( 'This type of file is banned', 'filetype-banned', |
| 214 | + 0, array( |
216 | 215 | 'filetype' => $verification['finalExt'], |
217 | 216 | 'allowed' => $wgFileExtensions |
218 | 217 | ) ); |
— | — | @@ -227,12 +226,12 @@ |
228 | 227 | $this->dieUsage( 'Overwriting an existing file is not allowed', 'overwrite' ); |
229 | 228 | break; |
230 | 229 | case UploadBase::VERIFICATION_ERROR: |
231 | | - $this->getResult()->setIndexedTagName( $verification['details'], 'detail' ); |
| 230 | + $this->getResult()->setIndexedTagName( $verification['details'], 'detail' ); |
232 | 231 | $this->dieUsage( 'This file did not pass file verification', 'verification-error', |
233 | 232 | 0, array( 'details' => $verification['details'] ) ); |
234 | 233 | break; |
235 | 234 | case UploadBase::UPLOAD_VERIFICATION_ERROR: |
236 | | - $this->dieUsage( "The modification you tried to make was aborted by an extension hook", |
| 235 | + $this->dieUsage( "The modification you tried to make was aborted by an extension hook", |
237 | 236 | 'hookaborted', 0, array( 'error' => $verification['error'] ) ); |
238 | 237 | break; |
239 | 238 | default: |
— | — | @@ -242,14 +241,12 @@ |
243 | 242 | } |
244 | 243 | return $result; |
245 | 244 | } |
246 | | - |
247 | 245 | if( !$this->mParams['ignorewarnings'] ) { |
248 | 246 | $warnings = $this->mUpload->checkWarnings(); |
249 | 247 | if( $warnings ) { |
250 | | - |
251 | 248 | // Add indices |
252 | 249 | $this->getResult()->setIndexedTagName( $warnings, 'warning' ); |
253 | | - |
| 250 | + |
254 | 251 | if( isset( $warnings['duplicate'] ) ) { |
255 | 252 | $dupes = array(); |
256 | 253 | foreach( $warnings['duplicate'] as $key => $dupe ) |
— | — | @@ -262,16 +259,18 @@ |
263 | 260 | if( isset( $warnings['exists'] ) ) { |
264 | 261 | $warning = $warnings['exists']; |
265 | 262 | unset( $warnings['exists'] ); |
266 | | - $warnings[$warning['warning']] = $warning['file']->getName(); |
| 263 | + $warnings[$warning['warning']] = $warning['file']->getName(); |
267 | 264 | } |
268 | | - |
| 265 | + |
269 | 266 | $result['result'] = 'Warning'; |
270 | 267 | $result['warnings'] = $warnings; |
271 | 268 | |
272 | 269 | $sessionKey = $this->mUpload->stashSession(); |
273 | | - if ( !$sessionKey ) |
| 270 | + if ( !$sessionKey ) |
274 | 271 | $this->dieUsage( 'Stashing temporary file failed', 'stashfailed' ); |
| 272 | + |
275 | 273 | $result['sessionkey'] = $sessionKey; |
| 274 | + |
276 | 275 | return $result; |
277 | 276 | } |
278 | 277 | } |
— | — | @@ -283,8 +282,8 @@ |
284 | 283 | if( !$status->isGood() ) { |
285 | 284 | $error = $status->getErrorsArray(); |
286 | 285 | $this->getResult()->setIndexedTagName( $result['details'], 'error' ); |
287 | | - |
288 | | - $this->dieUsage( 'An internal error occurred', 'internal-error', 0, $error ); |
| 286 | + |
| 287 | + $this->dieUsage( 'An internal error occurred', 'internal-error', 0, $error ); |
289 | 288 | } |
290 | 289 | |
291 | 290 | $file = $this->mUpload->getLocalFile(); |
Index: trunk/phase3/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js |
— | — | @@ -336,26 +336,6 @@ |
337 | 337 | _this.processApiResult( data ); |
338 | 338 | }); |
339 | 339 | }, |
340 | | - doAjaxWarningIgnore:function(){ |
341 | | - var _this = this; |
342 | | - if( !_this.upload_session_key ) |
343 | | - return js_error('missing upload_session_key (can\'t ignore warnigns'); |
344 | | - //do the ignore warnings submit to the api: |
345 | | - var req = { |
346 | | - 'ignorewarnings' : 'true', |
347 | | - 'sessionkey' :!_this.upload_session_key |
348 | | - }; |
349 | | - //add token if present: |
350 | | - if(this.etoken) |
351 | | - req['token'] = this.etoken; |
352 | | - |
353 | | - do_api_req({ |
354 | | - 'data':req, |
355 | | - 'url': _this.api_url |
356 | | - },function(data){ |
357 | | - _this.processApiResult(data); |
358 | | - }); |
359 | | - }, |
360 | 340 | doAjaxUploadStatus:function() { |
361 | 341 | var _this = this; |
362 | 342 | |
— | — | @@ -452,10 +432,10 @@ |
453 | 433 | error_code = apiRes.error.code; |
454 | 434 | }else if( apiRes.upload.code ){ |
455 | 435 | if(typeof apiRes.upload.code == 'object'){ |
456 | | - if(apiRes.upload.code[0]){ |
| 436 | + if( apiRes.upload.code[0] ){ |
457 | 437 | error_code = apiRes.upload.code[0]; |
458 | 438 | } |
459 | | - if(apiRes.upload.code['status']){ |
| 439 | + if( apiRes.upload.code['status'] ){ |
460 | 440 | error_code = apiRes.upload.code['status']; |
461 | 441 | if(apiRes.upload.code['filtered']) |
462 | 442 | errorReplaceArg =apiRes.upload.code['filtered']; |
— | — | @@ -564,14 +544,36 @@ |
565 | 545 | wmsg+='</li>'; |
566 | 546 | } |
567 | 547 | wmsg+='</ul>'; |
568 | | - if( apiRes.upload.warnings.sessionkey) |
569 | | - _this.warnings_sessionkey = apiRes.upload.warnings.sessionkey; |
| 548 | + if( apiRes.upload.sessionkey) |
| 549 | + _this.warnings_sessionkey = apiRes.upload.sessionkey; |
| 550 | + |
570 | 551 | var bObj = {}; |
571 | 552 | bObj[ gM('mwe-ignorewarning') ] = function() { |
572 | | - js_log('ignorewarning req:') |
573 | | - //re-inciate the upload proccess |
574 | | - $j('#wpIgnoreWarning').attr('checked', true); |
575 | | - $j( _this.editForm ).submit(); |
| 553 | + //check if we have a stashed key: |
| 554 | + if( _this.warnings_sessionkey ){ |
| 555 | + //set to "loading" |
| 556 | + $j( '#upProgressDialog' ).html( mv_get_loading_img() ); |
| 557 | + //setup loading: |
| 558 | + var req = { |
| 559 | + 'action' : 'upload', |
| 560 | + 'sessionkey': _this.warnings_sessionkey, |
| 561 | + 'ignorewarnings':1, |
| 562 | + 'filename': $j('#wpDestFile').val(), |
| 563 | + 'token' : _this.etoken |
| 564 | + }; |
| 565 | + //run the upload from stash request |
| 566 | + do_api_req({ |
| 567 | + 'data': req, |
| 568 | + 'url' : _this.api_url |
| 569 | + }, function( data ){ |
| 570 | + _this.processApiResult( data ); |
| 571 | + }); |
| 572 | + }else{ |
| 573 | + js_log('No session key re-sending upload') |
| 574 | + //do a stashed upload |
| 575 | + $j('#wpIgnoreWarning').attr('checked', true); |
| 576 | + $j( _this.editForm ).submit(); |
| 577 | + } |
576 | 578 | }; |
577 | 579 | bObj[ gM('mwe-return-to-form') ] = function(){ |
578 | 580 | $j(this).dialog('close'); |
Index: trunk/phase3/js2/mwEmbed/mv_embed.js |
— | — | @@ -1016,7 +1016,7 @@ |
1017 | 1017 | js_log( 'embedVideoCheck:' ); |
1018 | 1018 | // Make sure we have jQuery |
1019 | 1019 | _this.jQueryCheck( function() { |
1020 | | - //set class videonojs to hidden |
| 1020 | + //set class videonojs to loading |
1021 | 1021 | $j('.videonojs').html( gM('mwe-loading_txt') ); |
1022 | 1022 | //Set up the embed video player class request: (include the skin js as well) |
1023 | 1023 | var depReq = [ |