Merge "Use Message::sizeParams to simplify code when building messages"
This commit is contained in:
commit
ae5c51f354
7 changed files with 17 additions and 31 deletions
|
|
@ -4623,9 +4623,9 @@ class EditPage implements IEditObject {
|
|||
}
|
||||
|
||||
$out = $this->context->getOutput();
|
||||
$lang = $this->context->getLanguage();
|
||||
$maxArticleSize = $this->context->getConfig()->get( 'MaxArticleSize' );
|
||||
if ( $this->tooBig || $this->contentLength > $maxArticleSize * 1024 ) {
|
||||
$lang = $this->context->getLanguage();
|
||||
$out->wrapWikiMsg( "<div class='error' id='mw-edit-longpageerror'>\n$1\n</div>",
|
||||
[
|
||||
'longpageerror',
|
||||
|
|
@ -4636,8 +4636,9 @@ class EditPage implements IEditObject {
|
|||
} else {
|
||||
$longPageHint = $this->context->msg( 'longpage-hint' );
|
||||
if ( !$longPageHint->isDisabled() ) {
|
||||
$msgText = trim( $longPageHint->params( $lang->formatSize( $this->contentLength ),
|
||||
$this->contentLength )->text() );
|
||||
$msgText = trim( $longPageHint->sizeParams( $this->contentLength )
|
||||
->params( $this->contentLength ) // Keep this unformatted for math inside message
|
||||
->text() );
|
||||
if ( $msgText !== '' && $msgText !== '-' ) {
|
||||
$out->addWikiTextAsInterface( "<div id='mw-edit-longpage-hint'>\n$msgText\n</div>" );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -282,16 +282,14 @@ abstract class ImageHandler extends MediaHandler {
|
|||
* @return string
|
||||
*/
|
||||
public function getLongDesc( $file ) {
|
||||
global $wgLang;
|
||||
$pages = $file->pageCount();
|
||||
$size = htmlspecialchars( $wgLang->formatSize( $file->getSize() ) );
|
||||
if ( $pages === false || $pages <= 1 ) {
|
||||
$msg = wfMessage( 'file-info-size' )->numParams( $file->getWidth(),
|
||||
$file->getHeight() )->params( $size,
|
||||
$file->getHeight() )->sizeParams( $file->getSize() )->params(
|
||||
'<span class="mime-type">' . $file->getMimeType() . '</span>' )->parse();
|
||||
} else {
|
||||
$msg = wfMessage( 'file-info-size-pages' )->numParams( $file->getWidth(),
|
||||
$file->getHeight() )->params( $size,
|
||||
$file->getHeight() )->sizeParams( $file->getSize() )->params(
|
||||
'<span class="mime-type">' . $file->getMimeType() . '</span>' )->numParams( $pages )->parse();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -386,24 +386,18 @@ class SvgHandler extends ImageHandler {
|
|||
* @return string
|
||||
*/
|
||||
public function getLongDesc( $file ) {
|
||||
global $wgLang;
|
||||
|
||||
$metadata = $this->validateMetadata( $file->getMetadataArray() );
|
||||
if ( isset( $metadata['error'] ) ) {
|
||||
return wfMessage( 'svg-long-error', $metadata['error']['message'] )->text();
|
||||
}
|
||||
|
||||
$size = $wgLang->formatSize( $file->getSize() );
|
||||
|
||||
if ( $this->isAnimatedImage( $file ) ) {
|
||||
$msg = wfMessage( 'svg-long-desc-animated' );
|
||||
} else {
|
||||
$msg = wfMessage( 'svg-long-desc' );
|
||||
}
|
||||
|
||||
$msg->numParams( $file->getWidth(), $file->getHeight() )->params( $size );
|
||||
|
||||
return $msg->parse();
|
||||
return $msg->numParams( $file->getWidth(), $file->getHeight() )->sizeParams( $file->getSize() )->parse();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -234,12 +234,9 @@ class FullSearchResultWidget implements SearchResultWidget {
|
|||
->escaped();
|
||||
// TODO: This is a bit odd...but requires changing the i18n message to fix
|
||||
} elseif ( $result->getByteSize() !== null || $result->getWordCount() > 0 ) {
|
||||
$lang = $this->specialPage->getLanguage();
|
||||
$bytes = $lang->formatSize( $result->getByteSize() );
|
||||
$words = $result->getWordCount();
|
||||
|
||||
return $this->specialPage->msg( 'search-result-size', $bytes )
|
||||
->numParams( $words )
|
||||
return $this->specialPage->msg( 'search-result-size' )
|
||||
->sizeParams( $result->getByteSize() )
|
||||
->numParams( $result->getWordCount() )
|
||||
->escaped();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -160,10 +160,10 @@ class SpecialFileDuplicateSearch extends SpecialPage {
|
|||
$out->addModuleStyles( 'mediawiki.special' );
|
||||
$out->addHTML( '<div id="mw-fileduplicatesearch-icon">' .
|
||||
$thumb->toHtml( [ 'desc-link' => false ] ) . '<br />' .
|
||||
$this->msg( 'fileduplicatesearch-info' )->numParams(
|
||||
$img->getWidth(), $img->getHeight() )->params(
|
||||
$this->getLanguage()->formatSize( $img->getSize() ),
|
||||
$img->getMimeType() )->parseAsBlock() .
|
||||
$this->msg( 'fileduplicatesearch-info' )
|
||||
->numParams( $img->getWidth(), $img->getHeight() )
|
||||
->sizeParams( $img->getSize() )
|
||||
->params( $img->getMimeType() )->parseAsBlock() .
|
||||
'</div>' );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ class SpecialPagesWithProp extends QueryPage {
|
|||
if ( $isBinary || $isTooLong ) {
|
||||
$message = $this
|
||||
->msg( $isBinary ? 'pageswithprop-prophidden-binary' : 'pageswithprop-prophidden-long' )
|
||||
->params( $this->getLanguage()->formatSize( $valueLength ) );
|
||||
->sizeParams( $valueLength );
|
||||
|
||||
$propValue = Html::element( 'span', [ 'class' => 'prop-value-hidden' ], $message->text() );
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -183,9 +183,7 @@ class UploadForm extends HTMLForm {
|
|||
UploadBase::getMaxPhpUploadSize()
|
||||
);
|
||||
|
||||
$help = $this->msg( 'upload-maxfilesize',
|
||||
$this->getContext()->getLanguage()->formatSize( $this->mMaxUploadSize['file'] )
|
||||
)->parse();
|
||||
$help = $this->msg( 'upload-maxfilesize' )->sizeParams( $this->mMaxUploadSize['file'] )->parse();
|
||||
|
||||
// If the user can also upload by URL, there are 2 different file size limits.
|
||||
// This extra message helps stress which limit corresponds to what.
|
||||
|
|
@ -217,9 +215,7 @@ class UploadForm extends HTMLForm {
|
|||
'label-message' => 'sourceurl',
|
||||
'upload-type' => 'url',
|
||||
'radio' => &$radio,
|
||||
'help' => $this->msg( 'upload-maxfilesize',
|
||||
$this->getContext()->getLanguage()->formatSize( $this->mMaxUploadSize['url'] )
|
||||
)->parse() .
|
||||
'help' => $this->msg( 'upload-maxfilesize' )->sizeParams( $this->mMaxUploadSize['url'] )->parse() .
|
||||
$this->msg( 'word-separator' )->escaped() .
|
||||
$this->msg( 'upload_source_url' )->parse(),
|
||||
'checked' => $selectedSourceType == 'url',
|
||||
|
|
|
|||
Loading…
Reference in a new issue