From 4ac9fa081a7c045f6a9f1cfc529d82423f485b2e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 8 Dec 2013 09:55:49 +0100 Subject: Update to MediaWiki 1.22.0 --- includes/specials/SpecialUpload.php | 126 +++++++++++++++++------------------- 1 file changed, 58 insertions(+), 68 deletions(-) (limited to 'includes/specials/SpecialUpload.php') diff --git a/includes/specials/SpecialUpload.php b/includes/specials/SpecialUpload.php index 89c06b2a..09facf4f 100644 --- a/includes/specials/SpecialUpload.php +++ b/includes/specials/SpecialUpload.php @@ -90,10 +90,9 @@ class SpecialUpload extends SpecialPage { // Guess the desired name from the filename if not provided $this->mDesiredDestName = $request->getText( 'wpDestFile' ); - if( !$this->mDesiredDestName && $request->getFileName( 'wpUploadFile' ) !== null ) { + if ( !$this->mDesiredDestName && $request->getFileName( 'wpUploadFile' ) !== null ) { $this->mDesiredDestName = $request->getFileName( 'wpUploadFile' ); } - $this->mComment = $request->getText( 'wpUploadDescription' ); $this->mLicense = $request->getText( 'wpLicense' ); $this->mDestWarningAck = $request->getText( 'wpDestFileWarningAck' ); @@ -104,6 +103,14 @@ class SpecialUpload extends SpecialPage { $this->mCopyrightSource = $request->getText( 'wpUploadSource' ); $this->mForReUpload = $request->getBool( 'wpForReUpload' ); // updating a file + + $commentDefault = ''; + $commentMsg = wfMessage( 'upload-default-description' )->inContentLanguage(); + if ( !$this->mForReUpload && !$commentMsg->isDisabled() ) { + $commentDefault = $commentMsg->plain(); + } + $this->mComment = $request->getText( 'wpUploadDescription', $commentDefault ); + $this->mCancelUpload = $request->getCheck( 'wpCancelUpload' ) || $request->getCheck( 'wpReUpload' ); // b/w compat @@ -135,19 +142,19 @@ class SpecialUpload extends SpecialPage { $this->outputHeader(); # Check uploading enabled - if( !UploadBase::isEnabled() ) { + if ( !UploadBase::isEnabled() ) { throw new ErrorPageError( 'uploaddisabled', 'uploaddisabledtext' ); } # Check permissions $user = $this->getUser(); $permissionRequired = UploadBase::isAllowed( $user ); - if( $permissionRequired !== true ) { + if ( $permissionRequired !== true ) { throw new PermissionsError( $permissionRequired ); } # Check blocks - if( $user->isBlocked() ) { + if ( $user->isBlocked() ) { throw new UserBlockedError( $user->getBlock() ); } @@ -172,7 +179,7 @@ class SpecialUpload extends SpecialPage { $this->processUpload(); } else { # Backwards compatibility hook - if( !wfRunHooks( 'UploadForm:initial', array( &$this ) ) ) { + if ( !wfRunHooks( 'UploadForm:initial', array( &$this ) ) ) { wfDebug( "Hook 'UploadForm:initial' broke output of the upload form" ); return; } @@ -214,6 +221,8 @@ class SpecialUpload extends SpecialPage { */ protected function getUploadForm( $message = '', $sessionKey = '', $hideIgnoreWarning = false ) { # Initialize form + $context = new DerivativeContext( $this->getContext() ); + $context->setTitle( $this->getTitle() ); // Remove subpage $form = new UploadForm( array( 'watch' => $this->getWatchCheck(), 'forreupload' => $this->mForReUpload, @@ -225,11 +234,10 @@ class SpecialUpload extends SpecialPage { 'texttop' => $this->uploadFormTextTop, 'textaftersummary' => $this->uploadFormTextAfterSummary, 'destfile' => $this->mDesiredDestName, - ), $this->getContext() ); - $form->setTitle( $this->getTitle() ); + ), $context ); # Check the token, but only if necessary - if( + if ( !$this->mTokenOk && !$this->mCancelUpload && ( $this->mUpload && $this->mUploadClicked ) ) { @@ -275,7 +283,7 @@ class SpecialUpload extends SpecialPage { $title = Title::makeTitleSafe( NS_FILE, $this->mDesiredDestName ); $user = $this->getUser(); // Show a subtitle link to deleted revisions (to sysops et al only) - if( $title instanceof Title ) { + if ( $title instanceof Title ) { $count = $title->isDeleted(); if ( $count > 0 && $user->isAllowed( 'deletedhistory' ) ) { $restorelink = Linker::linkKnown( @@ -333,15 +341,15 @@ class SpecialUpload extends SpecialPage { $warningHtml = '

' . $this->msg( 'uploadwarning' )->escaped() . "

\n" . '