Index: trunk/phase3/includes/specials/SpecialUpload.php |
— | — | @@ -41,6 +41,7 @@ |
42 | 42 | protected $mCopyrightSource; |
43 | 43 | |
44 | 44 | /** Hidden variables **/ |
| 45 | + protected $mDestWarningAck; |
45 | 46 | protected $mForReUpload; // The user followed an "overwrite this file" link |
46 | 47 | protected $mCancelUpload; // The user clicked "Cancel and return to upload form" button |
47 | 48 | protected $mTokenOk; |
— | — | @@ -68,6 +69,7 @@ |
69 | 70 | $this->mLicense = $request->getText( 'wpLicense' ); |
70 | 71 | |
71 | 72 | |
| 73 | + $this->mDestWarningAck = $request->getText( 'wpDestFileWarningAck' ); |
72 | 74 | $this->mIgnoreWarning = $request->getCheck( 'wpIgnoreWarning' ) |
73 | 75 | || $request->getCheck( 'wpUploadIgnoreWarning' ); |
74 | 76 | $this->mWatchthis = $request->getBool( 'wpWatchthis' ) && $wgUser->isLoggedIn(); |
— | — | @@ -201,6 +203,7 @@ |
202 | 204 | 'forreupload' => $this->mForReUpload, |
203 | 205 | 'sessionkey' => $sessionKey, |
204 | 206 | 'hideignorewarning' => $hideIgnoreWarning, |
| 207 | + 'destwarningack' => (bool)$this->mDestWarningAck, |
205 | 208 | ) ); |
206 | 209 | $form->setTitle( $this->getTitle() ); |
207 | 210 | |
— | — | @@ -276,13 +279,22 @@ |
277 | 280 | $this->showUploadForm( $form ); |
278 | 281 | } |
279 | 282 | /** |
280 | | - * Stashes the upload, shows the main form, but adds an "continue anyway button" |
| 283 | + * Stashes the upload, shows the main form, but adds an "continue anyway button". |
| 284 | + * Also checks whether there are actually warnings to display. |
281 | 285 | * |
282 | 286 | * @param array $warnings |
| 287 | + * @return boolean true if warnings were displayed, false if there are no |
| 288 | + * warnings and the should continue processing like there was no warning |
283 | 289 | */ |
284 | 290 | protected function showUploadWarning( $warnings ) { |
285 | 291 | global $wgUser; |
286 | 292 | |
| 293 | + # If there are no warnings, or warnings we can ignore, return early |
| 294 | + if ( !$warnings || ( count( $warnings ) == 1 && |
| 295 | + isset( $warnings['exists']) && $this->mDestWarningAck ) ) { |
| 296 | + return false; |
| 297 | + } |
| 298 | + |
287 | 299 | $sessionKey = $this->mUpload->stashSession(); |
288 | 300 | |
289 | 301 | $sk = $wgUser->getSkin(); |
— | — | @@ -317,6 +329,9 @@ |
318 | 330 | $form->addButton( 'wpCancelUpload', wfMsg( 'reuploaddesc' ) ); |
319 | 331 | |
320 | 332 | $this->showUploadForm( $form ); |
| 333 | + |
| 334 | + # Indicate that we showed a form |
| 335 | + return true; |
321 | 336 | } |
322 | 337 | |
323 | 338 | /** |
— | — | @@ -371,8 +386,7 @@ |
372 | 387 | // Check warnings if necessary |
373 | 388 | if( !$this->mIgnoreWarning ) { |
374 | 389 | $warnings = $this->mUpload->checkWarnings(); |
375 | | - if( count( $warnings ) ) { |
376 | | - $this->showUploadWarning( $warnings ); |
| 390 | + if( $this->showUploadWarning( $warnings ) ) { |
377 | 391 | return; |
378 | 392 | } |
379 | 393 | } |
— | — | @@ -671,6 +685,7 @@ |
672 | 686 | protected $mForReUpload; |
673 | 687 | protected $mSessionKey; |
674 | 688 | protected $mHideIgnoreWarning; |
| 689 | + protected $mDestWarningAck; |
675 | 690 | |
676 | 691 | protected $mSourceIds; |
677 | 692 | |
— | — | @@ -682,6 +697,7 @@ |
683 | 698 | $this->mSessionKey = isset( $options['sessionkey'] ) |
684 | 699 | ? $options['sessionkey'] : ''; |
685 | 700 | $this->mHideIgnoreWarning = !empty( $options['hideignorewarning'] ); |
| 701 | + $this->mDestWarningAck = !empty( $options['destwarningack'] ); |
686 | 702 | |
687 | 703 | $sourceDescriptor = $this->getSourceSection(); |
688 | 704 | $descriptor = $sourceDescriptor |
— | — | @@ -907,6 +923,12 @@ |
908 | 924 | ); |
909 | 925 | } |
910 | 926 | |
| 927 | + $descriptor['wpDestFileWarningAck'] = array( |
| 928 | + 'type' => 'hidden', |
| 929 | + 'id' => 'wpDestFileWarningAck', |
| 930 | + 'default' => $this->mDestWarningAck ? '1' : '', |
| 931 | + ); |
| 932 | + |
911 | 933 | return $descriptor; |
912 | 934 | |
913 | 935 | } |
Index: trunk/phase3/skins/common/upload.js |
— | — | @@ -46,13 +46,14 @@ |
47 | 47 | document.getElementById( 'wpDestFile' ).onchange = function ( e ) { |
48 | 48 | wgUploadWarningObj.checkNow(this.value); |
49 | 49 | }; |
50 | | - var optionsTable = document.getElementById( 'mw-htmlform-options' ).tBodies[0]; |
| 50 | + var optionsTable = document.getElementById( 'mw-htmlform-description' ).tBodies[0]; |
51 | 51 | var row = document.createElement( 'tr' ); |
52 | 52 | var td = document.createElement( 'td' ); |
53 | 53 | td.id = 'wpDestFile-warning'; |
54 | 54 | td.colSpan = 2; |
| 55 | + |
55 | 56 | row.appendChild( td ); |
56 | | - optionsTable.appendChild( row ); |
| 57 | + optionsTable.insertBefore( row, optionsTable.children[1] ); |
57 | 58 | } |
58 | 59 | |
59 | 60 | if ( wgAjaxLicensePreview ) { |
— | — | @@ -187,7 +188,18 @@ |
188 | 189 | |
189 | 190 | 'setWarning' : function (warning) { |
190 | 191 | var warningElt = document.getElementById( 'wpDestFile-warning' ); |
| 192 | + var ackElt = document.getElementsByName( 'wpDestFileWarningAck' ); |
| 193 | + |
191 | 194 | this.setInnerHTML(warningElt, warning); |
| 195 | + |
| 196 | + // Set a value in the form indicating that the warning is acknowledged and |
| 197 | + // doesn't need to be redisplayed post-upload |
| 198 | + if ( warning == '' || warning == ' ' ) { |
| 199 | + ackElt[0].value = ''; |
| 200 | + } else { |
| 201 | + ackElt[0].value = '1'; |
| 202 | + } |
| 203 | + |
192 | 204 | }, |
193 | 205 | 'setInnerHTML' : function (element, text) { |
194 | 206 | // Check for no change to avoid flicker in IE 7 |