summaryrefslogtreecommitdiff
path: root/includes/specials/SpecialUpload.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/specials/SpecialUpload.php')
-rw-r--r--includes/specials/SpecialUpload.php141
1 files changed, 66 insertions, 75 deletions
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( '<div id="uploadtext">' .
- wfMsgExt( 'uploadtext', 'parse', array( $this->mDesiredDestName ) ) .
+ $this->msg( 'uploadtext', array( $this->mDesiredDestName ) )->parseAsBlock() .
'</div>' );
# Add upload error message
$form->addPreText( $message );
# Add footer to form
- $uploadFooter = wfMessage( 'uploadfooter' );
+ $uploadFooter = $this->msg( 'uploadfooter' );
if ( !$uploadFooter->isDisabled() ) {
$form->addPostText( '<div id="mw-upload-footer-message">'
- . $this->getOutput()->parse( $uploadFooter->plain() ) . "</div>\n" );
+ . $uploadFooter->parseAsBlock() . "</div>\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( "<div id=\"contentSub2\">{$link}</div>" );
}
}
@@ -306,11 +304,11 @@ class SpecialUpload extends SpecialPage {
*/
protected function showRecoverableUploadError( $message ) {
$sessionKey = $this->mUpload->stashSession();
- $message = '<h2>' . wfMsgHtml( 'uploaderror' ) . "</h2>\n" .
+ $message = '<h2>' . $this->msg( 'uploaderror' )->escaped() . "</h2>\n" .
'<div class="error">' . $message . "</div>\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 = '<h2>' . wfMsgHtml( 'uploadwarning' ) . "</h2>\n"
+ $warningHtml = '<h2>' . $this->msg( 'uploadwarning' )->escaped() . "</h2>\n"
. '<ul class="warning">';
foreach( $warnings as $warning => $args ) {
if( $warning == 'exists' ) {
@@ -343,8 +341,8 @@ class SpecialUpload extends SpecialPage {
} elseif( $warning == 'duplicate' ) {
$msg = self::getDupeWarning( $args );
} elseif( $warning == 'duplicate-archive' ) {
- $msg = "\t<li>" . wfMsgExt( 'file-deleted-duplicate', 'parseinline',
- array( Title::makeTitle( NS_FILE, $args )->getPrefixedText() ) )
+ $msg = "\t<li>" . $this->msg( 'file-deleted-duplicate',
+ Title::makeTitle( NS_FILE, $args )->getPrefixedText() )->parse()
. "</li>\n";
} else {
if ( $args === true ) {
@@ -352,17 +350,17 @@ class SpecialUpload extends SpecialPage {
} elseif ( !is_array( $args ) ) {
$args = array( $args );
}
- $msg = "\t<li>" . wfMsgExt( $warning, 'parseinline', $args ) . "</li>\n";
+ $msg = "\t<li>" . $this->msg( $warning, $args )->parse() . "</li>\n";
}
$warningHtml .= $msg;
}
$warningHtml .= "</ul>\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 = '<h2>' . wfMsgHtml( 'uploadwarning' ) . "</h2>\n" .
+ $message = '<h2>' . $this->msg( 'uploadwarning' )->escaped() . "</h2>\n" .
'<div class="error">' . $message . "</div>\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 = '<gallery>';
- foreach( $dupes as $file ) {
- $title = $file->getTitle();
- $msg .= $title->getPrefixedText() .
- '|' . $title->getText() . "\n";
- }
- $msg .= '</gallery>';
- return '<li>' .
- wfMsgExt( 'file-exists-duplicate', array( 'parse' ), count( $dupes ) ) .
- $wgOut->parse( $msg ) .
- "</li>\n";
- } else {
+ if ( !$dupes ) {
return '';
}
+
+ $gallery = new ImageGallery;
+ $gallery->setShowBytes( false );
+ foreach( $dupes as $file ) {
+ $gallery->add( $file->getTitle() );
+ }
+ return '<li>' .
+ wfMessage( 'file-exists-duplicate' )->numParams( count( $dupes ) )->parse() .
+ $gallery->toHtml() . "</li>\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 =
'<div id="mw-upload-permitted">' .
- wfMsgExt( 'upload-permitted', 'parse', $this->getContext()->getLanguage()->commaList( $wgFileExtensions ) ) .
+ $this->msg( 'upload-permitted', $this->getContext()->getLanguage()->commaList( $wgFileExtensions ) )->parseAsBlock() .
"</div>\n";
} else {
# We have to list both preferred and prohibited
$extensionsList =
'<div id="mw-upload-preferred">' .
- wfMsgExt( 'upload-preferred', 'parse', $this->getContext()->getLanguage()->commaList( $wgFileExtensions ) ) .
+ $this->msg( 'upload-preferred', $this->getContext()->getLanguage()->commaList( $wgFileExtensions ) )->parseAsBlock() .
"</div>\n" .
'<div id="mw-upload-prohibited">' .
- wfMsgExt( 'upload-prohibited', 'parse', $this->getContext()->getLanguage()->commaList( $wgFileBlacklist ) ) .
+ $this->msg( 'upload-prohibited', $this->getContext()->getLanguage()->commaList( $wgFileBlacklist ) )->parseAsBlock() .
"</div>\n";
}
} else {