From 63601400e476c6cf43d985f3e7b9864681695ed4 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 18 Jan 2013 16:46:04 +0100 Subject: Update to MediaWiki 1.20.2 this update includes: * adjusted Arch Linux skin * updated FluxBBAuthPlugin * patch for https://bugzilla.wikimedia.org/show_bug.cgi?id=44024 --- includes/specials/SpecialUpload.php | 141 +++++++++++++++++------------------- 1 file changed, 66 insertions(+), 75 deletions(-) (limited to 'includes/specials/SpecialUpload.php') diff --git a/includes/specials/SpecialUpload.php b/includes/specials/SpecialUpload.php index d6a76d02..43ea345b 100644 --- a/includes/specials/SpecialUpload.php +++ b/includes/specials/SpecialUpload.php @@ -150,7 +150,7 @@ class SpecialUpload extends SpecialPage { # Check blocks if( $user->isBlocked() ) { - throw new UserBlockedError( $user->mBlock ); + throw new UserBlockedError( $user->getBlock() ); } # Check whether we actually want to allow changing stuff @@ -235,7 +235,7 @@ class SpecialUpload extends SpecialPage { !$this->mTokenOk && !$this->mCancelUpload && ( $this->mUpload && $this->mUploadClicked ) ) { - $form->addPreText( wfMsgExt( 'session_fail_preview', 'parseinline' ) ); + $form->addPreText( $this->msg( 'session_fail_preview' )->parse() ); } # Give a notice if the user is uploading a file that has been deleted or moved @@ -255,16 +255,16 @@ class SpecialUpload extends SpecialPage { # Add text to form $form->addPreText( '
' . - wfMsgExt( 'uploadtext', 'parse', array( $this->mDesiredDestName ) ) . + $this->msg( 'uploadtext', array( $this->mDesiredDestName ) )->parseAsBlock() . '
' ); # Add upload error message $form->addPreText( $message ); # Add footer to form - $uploadFooter = wfMessage( 'uploadfooter' ); + $uploadFooter = $this->msg( 'uploadfooter' ); if ( !$uploadFooter->isDisabled() ) { $form->addPostText( '\n" ); + . $uploadFooter->parseAsBlock() . "\n" ); } return $form; @@ -280,14 +280,12 @@ class SpecialUpload extends SpecialPage { if( $title instanceof Title ) { $count = $title->isDeleted(); if ( $count > 0 && $user->isAllowed( 'deletedhistory' ) ) { - $link = wfMsgExt( - $user->isAllowed( 'delete' ) ? 'thisisdeleted' : 'viewdeleted', - array( 'parse', 'replaceafter' ), - Linker::linkKnown( - SpecialPage::getTitleFor( 'Undelete', $title->getPrefixedText() ), - wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $count ) - ) + $restorelink = Linker::linkKnown( + SpecialPage::getTitleFor( 'Undelete', $title->getPrefixedText() ), + $this->msg( 'restorelink' )->numParams( $count )->escaped() ); + $link = $this->msg( $user->isAllowed( 'delete' ) ? 'thisisdeleted' : 'viewdeleted' ) + ->rawParams( $restorelink )->parseAsBlock(); $this->getOutput()->addHTML( "
{$link}
" ); } } @@ -306,11 +304,11 @@ class SpecialUpload extends SpecialPage { */ protected function showRecoverableUploadError( $message ) { $sessionKey = $this->mUpload->stashSession(); - $message = '

' . wfMsgHtml( 'uploaderror' ) . "

\n" . + $message = '

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

\n" . '
' . $message . "
\n"; $form = $this->getUploadForm( $message, $sessionKey ); - $form->setSubmitText( wfMsg( 'upload-tryagain' ) ); + $form->setSubmitText( $this->msg( 'upload-tryagain' )->escaped() ); $this->showUploadForm( $form ); } /** @@ -335,7 +333,7 @@ class SpecialUpload extends SpecialPage { $sessionKey = $this->mUpload->stashSession(); - $warningHtml = '

' . wfMsgHtml( 'uploadwarning' ) . "

\n" + $warningHtml = '

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

\n" . '\n"; - $warningHtml .= wfMsgExt( 'uploadwarning-text', 'parse' ); + $warningHtml .= $this->msg( 'uploadwarning-text' )->parseAsBlock(); $form = $this->getUploadForm( $warningHtml, $sessionKey, /* $hideIgnoreWarning */ true ); - $form->setSubmitText( wfMsg( 'upload-tryagain' ) ); - $form->addButton( 'wpUploadIgnoreWarning', wfMsg( 'ignorewarning' ) ); - $form->addButton( 'wpCancelUpload', wfMsg( 'reuploaddesc' ) ); + $form->setSubmitText( $this->msg( 'upload-tryagain' )->text() ); + $form->addButton( 'wpUploadIgnoreWarning', $this->msg( 'ignorewarning' )->text() ); + $form->addButton( 'wpCancelUpload', $this->msg( 'reuploaddesc' )->text() ); $this->showUploadForm( $form ); @@ -376,7 +374,7 @@ class SpecialUpload extends SpecialPage { * @param $message string HTML string */ protected function showUploadError( $message ) { - $message = '

' . wfMsgHtml( 'uploadwarning' ) . "

\n" . + $message = '

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

\n" . '
' . $message . "
\n"; $this->showUploadForm( $this->getUploadForm( $message ) ); } @@ -414,8 +412,7 @@ class SpecialUpload extends SpecialPage { $permErrors = $this->mUpload->verifyTitlePermissions( $this->getUser() ); if( $permErrors !== true ) { $code = array_shift( $permErrors[0] ); - $this->showRecoverableUploadError( wfMsgExt( $code, - 'parseinline', $permErrors[0] ) ); + $this->showRecoverableUploadError( $this->msg( $code, $permErrors[0] )->parse() ); return; } @@ -469,7 +466,7 @@ class SpecialUpload extends SpecialPage { if ( in_array( $msgName, $wgForceUIMsgAsContentMsg ) ) { $msg[$msgName] = "{{int:$msgName}}"; } else { - $msg[$msgName] = wfMsgForContent( $msgName ); + $msg[$msgName] = wfMessage( $msgName )->inContentLanguage()->text(); } } @@ -516,7 +513,7 @@ class SpecialUpload extends SpecialPage { if( $local && $local->exists() ) { // We're uploading a new version of an existing file. // No creation, so don't watch it if we're not already. - return $local->getTitle()->userIsWatching(); + return $this->getUser()->isWatched( $local->getTitle() ); } else { // New page should get watched if that's our option. return $this->getUser()->getOption( 'watchcreations' ); @@ -536,33 +533,31 @@ class SpecialUpload extends SpecialPage { /** Statuses that only require name changing **/ case UploadBase::MIN_LENGTH_PARTNAME: - $this->showRecoverableUploadError( wfMsgHtml( 'minlength1' ) ); + $this->showRecoverableUploadError( $this->msg( 'minlength1' )->escaped() ); break; case UploadBase::ILLEGAL_FILENAME: - $this->showRecoverableUploadError( wfMsgExt( 'illegalfilename', - 'parseinline', $details['filtered'] ) ); + $this->showRecoverableUploadError( $this->msg( 'illegalfilename', + $details['filtered'] )->parse() ); break; case UploadBase::FILENAME_TOO_LONG: - $this->showRecoverableUploadError( wfMsgHtml( 'filename-toolong' ) ); + $this->showRecoverableUploadError( $this->msg( 'filename-toolong' )->escaped() ); break; case UploadBase::FILETYPE_MISSING: - $this->showRecoverableUploadError( wfMsgExt( 'filetype-missing', - 'parseinline' ) ); + $this->showRecoverableUploadError( $this->msg( 'filetype-missing' )->parse() ); break; case UploadBase::WINDOWS_NONASCII_FILENAME: - $this->showRecoverableUploadError( wfMsgExt( 'windows-nonascii-filename', - 'parseinline' ) ); + $this->showRecoverableUploadError( $this->msg( 'windows-nonascii-filename' )->parse() ); break; /** Statuses that require reuploading **/ case UploadBase::EMPTY_FILE: - $this->showUploadError( wfMsgHtml( 'emptyfile' ) ); + $this->showUploadError( $this->msg( 'emptyfile' )->escaped() ); break; case UploadBase::FILE_TOO_LARGE: - $this->showUploadError( wfMsgHtml( 'largefileserver' ) ); + $this->showUploadError( $this->msg( 'largefileserver' )->escaped() ); break; case UploadBase::FILETYPE_BADTYPE: - $msg = wfMessage( 'filetype-banned-type' ); + $msg = $this->msg( 'filetype-banned-type' ); if ( isset( $details['blacklistedExt'] ) ) { $msg->params( $this->getLanguage()->commaList( $details['blacklistedExt'] ) ); } else { @@ -585,7 +580,7 @@ class SpecialUpload extends SpecialPage { case UploadBase::VERIFICATION_ERROR: unset( $details['status'] ); $code = array_shift( $details['details'] ); - $this->showUploadError( wfMsgExt( $code, 'parseinline', $details['details'] ) ); + $this->showUploadError( $this->msg( $code, $details['details'] )->parse() ); break; case UploadBase::HOOK_ABORTED: if ( is_array( $details['error'] ) ) { # allow hooks to return error details in an array @@ -596,7 +591,7 @@ class SpecialUpload extends SpecialPage { $args = null; } - $this->showUploadError( wfMsgExt( $error, 'parseinline', $args ) ); + $this->showUploadError( $this->msg( $error, $args )->parse() ); break; default: throw new MWException( __METHOD__ . ": Unknown value `{$details['status']}`" ); @@ -641,37 +636,37 @@ class SpecialUpload extends SpecialPage { if( $exists['warning'] == 'exists' ) { // Exact match - $warning = wfMsgExt( 'fileexists', 'parseinline', $filename ); + $warning = wfMessage( 'fileexists', $filename )->parse(); } elseif( $exists['warning'] == 'page-exists' ) { // Page exists but file does not - $warning = wfMsgExt( 'filepageexists', 'parseinline', $filename ); + $warning = wfMessage( 'filepageexists', $filename )->parse(); } elseif ( $exists['warning'] == 'exists-normalized' ) { - $warning = wfMsgExt( 'fileexists-extension', 'parseinline', $filename, - $exists['normalizedFile']->getTitle()->getPrefixedText() ); + $warning = wfMessage( 'fileexists-extension', $filename, + $exists['normalizedFile']->getTitle()->getPrefixedText() )->parse(); } elseif ( $exists['warning'] == 'thumb' ) { // Swapped argument order compared with other messages for backwards compatibility - $warning = wfMsgExt( 'fileexists-thumbnail-yes', 'parseinline', - $exists['thumbFile']->getTitle()->getPrefixedText(), $filename ); + $warning = wfMessage( 'fileexists-thumbnail-yes', + $exists['thumbFile']->getTitle()->getPrefixedText(), $filename )->parse(); } elseif ( $exists['warning'] == 'thumb-name' ) { // Image w/o '180px-' does not exists, but we do not like these filenames $name = $file->getName(); $badPart = substr( $name, 0, strpos( $name, '-' ) + 1 ); - $warning = wfMsgExt( 'file-thumbnail-no', 'parseinline', $badPart ); + $warning = wfMessage( 'file-thumbnail-no', $badPart )->parse(); } elseif ( $exists['warning'] == 'bad-prefix' ) { - $warning = wfMsgExt( 'filename-bad-prefix', 'parseinline', $exists['prefix'] ); + $warning = wfMessage( 'filename-bad-prefix', $exists['prefix'] )->parse(); } elseif ( $exists['warning'] == 'was-deleted' ) { # If the file existed before and was deleted, warn the user of this $ltitle = SpecialPage::getTitleFor( 'Log' ); $llink = Linker::linkKnown( $ltitle, - wfMsgHtml( 'deletionlog' ), + wfMessage( 'deletionlog' )->escaped(), array(), array( 'type' => 'delete', 'page' => $filename ) ); - $warning = wfMsgExt( 'filewasdeleted', array( 'parse', 'replaceafter' ), $llink ); + $warning = wfMessage( 'filewasdeleted' )->rawParams( $llink )->parseAsBlock(); } return $warning; @@ -707,22 +702,18 @@ class SpecialUpload extends SpecialPage { * @return string */ public static function getDupeWarning( $dupes ) { - global $wgOut; - if( $dupes ) { - $msg = ''; - foreach( $dupes as $file ) { - $title = $file->getTitle(); - $msg .= $title->getPrefixedText() . - '|' . $title->getText() . "\n"; - } - $msg .= ''; - return '
  • ' . - wfMsgExt( 'file-exists-duplicate', array( 'parse' ), count( $dupes ) ) . - $wgOut->parse( $msg ) . - "
  • \n"; - } else { + if ( !$dupes ) { return ''; } + + $gallery = new ImageGallery; + $gallery->setShowBytes( false ); + foreach( $dupes as $file ) { + $gallery->add( $file->getTitle() ); + } + return '
  • ' . + wfMessage( 'file-exists-duplicate' )->numParams( count( $dupes ) )->parse() . + $gallery->toHtml() . "
  • \n"; } } @@ -775,7 +766,7 @@ class UploadForm extends HTMLForm { parent::__construct( $descriptor, $context, 'upload' ); # Set some form properties - $this->setSubmitText( wfMsg( 'uploadbtn' ) ); + $this->setSubmitText( $this->msg( 'uploadbtn' )->text() ); $this->setSubmitName( 'wpUpload' ); # Used message keys: 'accesskey-upload', 'tooltip-upload' $this->setSubmitTooltip( 'upload' ); @@ -830,7 +821,9 @@ class UploadForm extends HTMLForm { # that setting doesn't exist if ( !wfIsHipHop() ) { $this->mMaxUploadSize['file'] = min( $this->mMaxUploadSize['file'], - wfShorthandToInteger( ini_get( 'upload_max_filesize' ) ) ); + wfShorthandToInteger( ini_get( 'upload_max_filesize' ) ), + wfShorthandToInteger( ini_get( 'post_max_size' ) ) + ); } $descriptor['UploadFile'] = array( @@ -841,10 +834,9 @@ class UploadForm extends HTMLForm { 'label-message' => 'sourcefilename', 'upload-type' => 'File', 'radio' => &$radio, - 'help' => wfMsgExt( 'upload-maxfilesize', - array( 'parseinline', 'escapenoentities' ), + 'help' => $this->msg( 'upload-maxfilesize', $this->getContext()->getLanguage()->formatSize( $this->mMaxUploadSize['file'] ) - ) . ' ' . wfMsgHtml( 'upload_source_file' ), + )->parse() . ' ' . $this->msg( 'upload_source_file' )->escaped(), 'checked' => $selectedSourceType == 'file', ); if ( $canUploadByUrl ) { @@ -856,10 +848,9 @@ class UploadForm extends HTMLForm { 'label-message' => 'sourceurl', 'upload-type' => 'url', 'radio' => &$radio, - 'help' => wfMsgExt( 'upload-maxfilesize', - array( 'parseinline', 'escapenoentities' ), + 'help' => $this->msg( 'upload-maxfilesize', $this->getContext()->getLanguage()->formatSize( $this->mMaxUploadSize['url'] ) - ) . ' ' . wfMsgHtml( 'upload_source_url' ), + )->parse() . ' ' . $this->msg( 'upload_source_url' )->escaped(), 'checked' => $selectedSourceType == 'url', ); } @@ -890,16 +881,16 @@ class UploadForm extends HTMLForm { # Everything not permitted is banned $extensionsList = '
    ' . - wfMsgExt( 'upload-permitted', 'parse', $this->getContext()->getLanguage()->commaList( $wgFileExtensions ) ) . + $this->msg( 'upload-permitted', $this->getContext()->getLanguage()->commaList( $wgFileExtensions ) )->parseAsBlock() . "
    \n"; } else { # We have to list both preferred and prohibited $extensionsList = '
    ' . - wfMsgExt( 'upload-preferred', 'parse', $this->getContext()->getLanguage()->commaList( $wgFileExtensions ) ) . + $this->msg( 'upload-preferred', $this->getContext()->getLanguage()->commaList( $wgFileExtensions ) )->parseAsBlock() . "
    \n" . '
    ' . - wfMsgExt( 'upload-prohibited', 'parse', $this->getContext()->getLanguage()->commaList( $wgFileBlacklist ) ) . + $this->msg( 'upload-prohibited', $this->getContext()->getLanguage()->commaList( $wgFileBlacklist ) )->parseAsBlock() . "
    \n"; } } else { -- cgit v1.2.2