protected $mCopyrightSource;
/** Hidden variables **/
+ protected $mDestWarningAck;
protected $mForReUpload; // The user followed an "overwrite this file" link
protected $mCancelUpload; // The user clicked "Cancel and return to upload form" button
protected $mTokenOk;
$this->mLicense = $request->getText( 'wpLicense' );
+ $this->mDestWarningAck = $request->getText( 'wpDestFileWarningAck' );
$this->mIgnoreWarning = $request->getCheck( 'wpIgnoreWarning' )
|| $request->getCheck( 'wpUploadIgnoreWarning' );
$this->mWatchthis = $request->getBool( 'wpWatchthis' ) && $wgUser->isLoggedIn();
'forreupload' => $this->mForReUpload,
'sessionkey' => $sessionKey,
'hideignorewarning' => $hideIgnoreWarning,
+ 'destwarningack' => (bool)$this->mDestWarningAck,
) );
$form->setTitle( $this->getTitle() );
$this->showUploadForm( $form );
}
/**
- * Stashes the upload, shows the main form, but adds an "continue anyway button"
+ * Stashes the upload, shows the main form, but adds an "continue anyway button".
+ * Also checks whether there are actually warnings to display.
*
* @param array $warnings
+ * @return boolean true if warnings were displayed, false if there are no
+ * warnings and the should continue processing like there was no warning
*/
protected function showUploadWarning( $warnings ) {
global $wgUser;
+ # If there are no warnings, or warnings we can ignore, return early
+ if ( !$warnings || ( count( $warnings ) == 1 &&
+ isset( $warnings['exists']) && $this->mDestWarningAck ) ) {
+ return false;
+ }
+
$sessionKey = $this->mUpload->stashSession();
$sk = $wgUser->getSkin();
$form->addButton( 'wpCancelUpload', wfMsg( 'reuploaddesc' ) );
$this->showUploadForm( $form );
+
+ # Indicate that we showed a form
+ return true;
}
/**
// Check warnings if necessary
if( !$this->mIgnoreWarning ) {
$warnings = $this->mUpload->checkWarnings();
- if( count( $warnings ) ) {
- $this->showUploadWarning( $warnings );
+ if( $this->showUploadWarning( $warnings ) ) {
return;
}
}
protected $mForReUpload;
protected $mSessionKey;
protected $mHideIgnoreWarning;
+ protected $mDestWarningAck;
protected $mSourceIds;
$this->mSessionKey = isset( $options['sessionkey'] )
? $options['sessionkey'] : '';
$this->mHideIgnoreWarning = !empty( $options['hideignorewarning'] );
+ $this->mDestWarningAck = !empty( $options['destwarningack'] );
$sourceDescriptor = $this->getSourceSection();
$descriptor = $sourceDescriptor
);
}
+ $descriptor['wpDestFileWarningAck'] = array(
+ 'type' => 'hidden',
+ 'id' => 'wpDestFileWarningAck',
+ 'default' => $this->mDestWarningAck ? '1' : '',
+ );
+
return $descriptor;
}
document.getElementById( 'wpDestFile' ).onchange = function ( e ) {
wgUploadWarningObj.checkNow(this.value);
};
- var optionsTable = document.getElementById( 'mw-htmlform-options' ).tBodies[0];
+ var optionsTable = document.getElementById( 'mw-htmlform-description' ).tBodies[0];
var row = document.createElement( 'tr' );
var td = document.createElement( 'td' );
td.id = 'wpDestFile-warning';
td.colSpan = 2;
+
row.appendChild( td );
- optionsTable.appendChild( row );
+ optionsTable.insertBefore( row, optionsTable.children[1] );
}
if ( wgAjaxLicensePreview ) {
'setWarning' : function (warning) {
var warningElt = document.getElementById( 'wpDestFile-warning' );
+ var ackElt = document.getElementsByName( 'wpDestFileWarningAck' );
+
this.setInnerHTML(warningElt, warning);
+
+ // Set a value in the form indicating that the warning is acknowledged and
+ // doesn't need to be redisplayed post-upload
+ if ( warning == '' || warning == ' ' ) {
+ ackElt[0].value = '';
+ } else {
+ ackElt[0].value = '1';
+ }
+
},
'setInnerHTML' : function (element, text) {
// Check for no change to avoid flicker in IE 7