From 6fe1f0509baec67647dffd2e3bc123c6511d1511 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Sun, 19 Aug 2012 22:44:29 +0200 Subject: [PATCH] Replace deprecated wfMsg* calls with Message class calls. Doing this in steps of roughly 100 changes per commit, so that it remains reviewable. Change-Id: Ib15e670badd3f6aecae8b60e2f9129a31341ce16 --- includes/Exception.php | 14 ++++---- includes/FeedUtils.php | 16 ++++----- includes/FileDeleteForm.php | 43 +++++++++++++---------- includes/GlobalFunctions.php | 2 +- includes/HTMLForm.php | 38 ++++++++++---------- includes/ImagePage.php | 47 +++++++++++++------------ includes/Linker.php | 68 +++++++++++++++++++----------------- 7 files changed, 121 insertions(+), 107 deletions(-) diff --git a/includes/Exception.php b/includes/Exception.php index d5cf543fa4..25f90e6183 100644 --- a/includes/Exception.php +++ b/includes/Exception.php @@ -45,7 +45,7 @@ class MWException extends Exception { } /** - * Can the extension use wfMsg() to get i18n messages? + * Can the extension use the Message class/wfMessage to get i18n-ed messages? * * @return bool */ @@ -109,7 +109,7 @@ class MWException extends Exception { $args = array_slice( func_get_args(), 2 ); if ( $this->useMessageCache() ) { - return wfMsgNoTrans( $key, $args ); + return wfMessage( $key, $args )->plain(); } else { return wfMsgReplaceArgs( $fallback, $args ); } @@ -325,7 +325,7 @@ class ErrorPageError extends MWException { * * @param $title A title * @param $msg String|Message . In string form, should be a message key - * @param $params Array Array to wfMsg() + * @param $params Array Array to wfMessage() */ function __construct( $title, $msg, $params = null ) { $this->title = $title; @@ -335,7 +335,7 @@ class ErrorPageError extends MWException { if( $msg instanceof Message ){ parent::__construct( $msg ); } else { - parent::__construct( wfMsg( $msg ) ); + parent::__construct( wfMessage( $msg )->text() ); } } @@ -359,7 +359,7 @@ class BadTitleError extends ErrorPageError { /** * @param $msg string A message key (default: 'badtitletext') - * @param $params Array parameter to wfMsg() + * @param $params Array parameter to wfMessage() */ function __construct( $msg = 'badtitletext', $params = null ) { parent::__construct( 'badtitle', $msg, $params ); @@ -477,7 +477,7 @@ class UserBlockedError extends ErrorPageError { $reason = $block->mReason; if( $reason == '' ) { - $reason = wfMsg( 'blockednoreason' ); + $reason = wfMessage( 'blockednoreason' )->text(); } /* $ip returns who *is* being blocked, $intended contains who was meant to be blocked. @@ -536,7 +536,7 @@ class UserNotLoggedIn extends ErrorPageError { * Optional, default: 'exception-nologin-text' * @param $titleMsg A message key to set the page title. * Optional, default: 'exception-nologin' - * @param $params Parameters to wfMsg(). + * @param $params Parameters to wfMessage(). * Optiona, default: null */ public function __construct( diff --git a/includes/FeedUtils.php b/includes/FeedUtils.php index 16eba66f87..11b2675d87 100644 --- a/includes/FeedUtils.php +++ b/includes/FeedUtils.php @@ -129,22 +129,22 @@ class FeedUtils { if( $oldid ) { wfProfileIn( __METHOD__."-dodiff" ); - #$diffText = $de->getDiff( wfMsg( 'revisionasof', + #$diffText = $de->getDiff( wfMessage( 'revisionasof', # $wgLang->timeanddate( $timestamp ), # $wgLang->date( $timestamp ), - # $wgLang->time( $timestamp ) ), - # wfMsg( 'currentrev' ) ); + # $wgLang->time( $timestamp ) )->text(), + # wfMessage( 'currentrev' )->text() ); $diffText = ''; // Don't bother generating the diff if we won't be able to show it if ( $wgFeedDiffCutoff > 0 ) { $de = new DifferenceEngine( $title, $oldid, $newid ); $diffText = $de->getDiff( - wfMsg( 'previousrevision' ), // hack - wfMsg( 'revisionasof', + wfMessage( 'previousrevision' )->text(), // hack + wfMessage( 'revisionasof', $wgLang->timeanddate( $timestamp ), $wgLang->date( $timestamp ), - $wgLang->time( $timestamp ) ) ); + $wgLang->time( $timestamp ) )->text() ); } if ( $wgFeedDiffCutoff <= 0 || ( strlen( $diffText ) > $wgFeedDiffCutoff ) ) { @@ -170,7 +170,7 @@ class FeedUtils { // Omit large new page diffs, bug 29110 $diffText = self::getDiffLink( $title, $newid ); } else { - $diffText = '

' . wfMsg( 'newpage' ) . '

' . + $diffText = '

' . wfMessage( 'newpage' )->text() . '

' . '
' . nl2br( htmlspecialchars( $newtext ) ) . '
'; } } @@ -196,7 +196,7 @@ class FeedUtils { $diffUrl = $title->getFullUrl( $queryParameters ); $diffLink = Html::element( 'a', array( 'href' => $diffUrl ), - wfMsgForContent( 'showdiff' ) ); + wfMessage( 'showdiff' )->inContentLanguage()->text() ); return $diffLink; } diff --git a/includes/FileDeleteForm.php b/includes/FileDeleteForm.php index 1f0c195764..e75ad72944 100644 --- a/includes/FileDeleteForm.php +++ b/includes/FileDeleteForm.php @@ -101,7 +101,8 @@ class FileDeleteForm { $reason = $deleteReason; } elseif ( $deleteReason != '' ) { // Entry from drop down menu + additional comment - $reason = $deleteReasonList . wfMsgForContent( 'colon-separator' ) . $deleteReason; + $reason = $deleteReasonList . wfMessage( 'colon-separator' ) + ->inContentLanguage()->text() . $deleteReason; } else { $reason = $deleteReasonList; } @@ -156,9 +157,10 @@ class FileDeleteForm { $status = $file->deleteOld( $oldimage, $reason, $suppress ); if( $status->ok ) { // Need to do a log item - $logComment = wfMsgForContent( 'deletedrevision', $oldimage ); + $logComment = wfMessage( 'deletedrevision', $oldimage )->inContentLanguage()->text(); if( trim( $reason ) != '' ) { - $logComment .= wfMsgForContent( 'colon-separator' ) . $reason; + $logComment .= wfMessage( 'colon-separator' ) + ->inContentLanguage()->text() . $reason; } $logtype = $suppress ? 'suppress' : 'delete'; @@ -214,7 +216,7 @@ class FileDeleteForm { $suppress = " " . - Xml::checkLabel( wfMsg( 'revdelete-suppress' ), + Xml::checkLabel( wfMessage( 'revdelete-suppress' )->text(), 'wpSuppress', 'wpSuppress', false, array( 'tabindex' => '3' ) ) . " "; @@ -226,23 +228,28 @@ class FileDeleteForm { $form = Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getAction(), 'id' => 'mw-img-deleteconfirm' ) ) . Xml::openElement( 'fieldset' ) . - Xml::element( 'legend', null, wfMsg( 'filedelete-legend' ) ) . + Xml::element( 'legend', null, wfMessage( 'filedelete-legend' )->text() ) . Html::hidden( 'wpEditToken', $wgUser->getEditToken( $this->oldimage ) ) . $this->prepareMessage( 'filedelete-intro' ) . Xml::openElement( 'table', array( 'id' => 'mw-img-deleteconfirm-table' ) ) . " " . - Xml::label( wfMsg( 'filedelete-comment' ), 'wpDeleteReasonList' ) . + Xml::label( wfMessage( 'filedelete-comment' )->text(), 'wpDeleteReasonList' ) . " " . - Xml::listDropDown( 'wpDeleteReasonList', - wfMsgForContent( 'filedelete-reason-dropdown' ), - wfMsgForContent( 'filedelete-reason-otherlist' ), '', 'wpReasonDropDown', 1 ) . + Xml::listDropDown( + 'wpDeleteReasonList', + wfMessage( 'filedelete-reason-dropdown' )->inContentLanguage()->text(), + wfMessage( 'filedelete-reason-otherlist' )->inContentLanguage()->text(), + '', + 'wpReasonDropDown', + 1 + ) . " " . - Xml::label( wfMsg( 'filedelete-otherreason' ), 'wpReason' ) . + Xml::label( wfMessage( 'filedelete-otherreason' )->text(), 'wpReason' ) . " " . Xml::input( 'wpReason', 60, $wgRequest->getText( 'wpReason' ), @@ -255,7 +262,7 @@ class FileDeleteForm { " . - Xml::checkLabel( wfMsg( 'watchthis' ), + Xml::checkLabel( wfMessage( 'watchthis' )->text(), 'wpWatch', 'wpWatch', $checkWatch, array( 'tabindex' => '3' ) ) . " "; @@ -264,7 +271,7 @@ class FileDeleteForm { " . - Xml::submitButton( wfMsg( 'filedelete-submit' ), + Xml::submitButton( wfMessage( 'filedelete-submit' )->text(), array( 'name' => 'mw-filedelete-submit', 'id' => 'mw-filedelete-submit', 'tabindex' => '4' ) ) . " " . @@ -276,7 +283,7 @@ class FileDeleteForm { $title = Title::makeTitle( NS_MEDIAWIKI, 'Filedelete-reason-dropdown' ); $link = Linker::link( $title, - wfMsgHtml( 'filedelete-edit-reasonlist' ), + wfMessage( 'filedelete-edit-reasonlist' )->escaped(), array(), array( 'action' => 'edit' ) ); @@ -307,19 +314,17 @@ class FileDeleteForm { private function prepareMessage( $message ) { global $wgLang; if( $this->oldimage ) { - return wfMsgExt( + return wfMessage( "{$message}-old", # To ensure grep will find them: 'filedelete-intro-old', 'filedelete-nofile-old', 'filedelete-success-old' - 'parse', wfEscapeWikiText( $this->title->getText() ), $wgLang->date( $this->getTimestamp(), true ), $wgLang->time( $this->getTimestamp(), true ), - wfExpandUrl( $this->file->getArchiveUrl( $this->oldimage ), PROTO_CURRENT ) ); + wfExpandUrl( $this->file->getArchiveUrl( $this->oldimage ), PROTO_CURRENT ) )->parseAsBlock(); } else { - return wfMsgExt( + return wfMessage( $message, - 'parse', wfEscapeWikiText( $this->title->getText() ) - ); + )->parseAsBlock(); } } diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 391d11de2d..708fae6fb3 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1684,7 +1684,7 @@ function wfMsgExt( $key, $options ) { * looked up didn't exist but a XHTML string, this function checks for the * nonexistance of messages by checking the MessageCache::get() result directly. * - * @deprecated since 1.18 + * @deprecated since 1.18. Use Message::isDisabled(). * * @param $key String: the message key looked up * @return Boolean True if the message *doesn't* exist. diff --git a/includes/HTMLForm.php b/includes/HTMLForm.php index ab12377866..d1967294db 100644 --- a/includes/HTMLForm.php +++ b/includes/HTMLForm.php @@ -424,7 +424,7 @@ class HTMLForm extends ContextSource { /** * Set a message to display on a validation error. - * @param $msg Mixed String or Array of valid inputs to wfMsgExt() + * @param $msg Mixed String or Array of valid inputs to wfMessage() * (so each entry can be either a String or Array) * @return HTMLForm $this for chaining calls (since 1.20) */ @@ -700,7 +700,7 @@ class HTMLForm extends ContextSource { 'input', array( 'type' => 'reset', - 'value' => wfMsg( 'htmlform-reset' ) + 'value' => wfMessage( 'htmlform-reset' )->text() ) ) . "\n"; } @@ -776,7 +776,7 @@ class HTMLForm extends ContextSource { $errorstr .= Html::rawElement( 'li', array(), - wfMsgExt( $msg, array( 'parseinline' ), $error ) + wfMessage( $msg, $error )->parse() ); } @@ -813,7 +813,7 @@ class HTMLForm extends ContextSource { function getSubmitText() { return $this->mSubmitText ? $this->mSubmitText - : wfMsg( 'htmlform-submit' ); + : wfMessage( 'htmlform-submit' )->text(); } /** @@ -1051,7 +1051,7 @@ class HTMLForm extends ContextSource { * @return String */ public function getLegend( $key ) { - return wfMsg( "{$this->mMessagePrefix}-$key" ); + return wfMessage( "{$this->mMessagePrefix}-$key" )->text(); } /** @@ -1110,7 +1110,7 @@ abstract class HTMLFormField { */ function validate( $value, $alldata ) { if ( isset( $this->mParams['required'] ) && $this->mParams['required'] !== false && $value === '' ) { - return wfMsgExt( 'htmlform-required', 'parseinline' ); + return wfMessage( 'htmlform-required' )->parse(); } if ( isset( $this->mValidationCallback ) ) { @@ -1170,7 +1170,7 @@ abstract class HTMLFormField { $msgInfo = array(); } - $this->mLabel = wfMsgExt( $msg, 'parseinline', $msgInfo ); + $this->mLabel = wfMessage( $msg, $msgInfo )->parse(); } elseif ( isset( $params['label'] ) ) { $this->mLabel = $params['label']; } @@ -1642,7 +1642,7 @@ class HTMLFloatField extends HTMLTextField { # http://dev.w3.org/html5/spec/common-microsyntaxes.html#real-numbers # with the addition that a leading '+' sign is ok. if ( !preg_match( '/^((\+|\-)?\d+(\.\d+)?(E(\+|\-)?\d+)?)?$/i', $value ) ) { - return wfMsgExt( 'htmlform-float-invalid', 'parse' ); + return wfMessage( 'htmlform-float-invalid' )->parseAsBlock(); } # The "int" part of these message names is rather confusing. @@ -1651,7 +1651,7 @@ class HTMLFloatField extends HTMLTextField { $min = $this->mParams['min']; if ( $min > $value ) { - return wfMsgExt( 'htmlform-int-toolow', 'parse', array( $min ) ); + return wfMessage( 'htmlform-int-toolow', array( $min ) )->parseAsBlock(); } } @@ -1659,7 +1659,7 @@ class HTMLFloatField extends HTMLTextField { $max = $this->mParams['max']; if ( $max < $value ) { - return wfMsgExt( 'htmlform-int-toohigh', 'parse', array( $max ) ); + return wfMessage( 'htmlform-int-toohigh', array( $max ) )->parseAsBlock(); } } @@ -1686,7 +1686,7 @@ class HTMLIntField extends HTMLFloatField { # value to, eg, save in the DB, clean it up with intval(). if ( !preg_match( '/^((\+|\-)?\d+)?$/', trim( $value ) ) ) { - return wfMsgExt( 'htmlform-int-invalid', 'parse' ); + return wfMessage( 'htmlform-int-invalid' )->parseAsBlock(); } return true; @@ -1770,7 +1770,7 @@ class HTMLSelectField extends HTMLFormField { if ( in_array( $value, $validOptions ) ) return true; else - return wfMsgExt( 'htmlform-select-badoption', 'parseinline' ); + return wfMessage( 'htmlform-select-badoption' )->parse(); } function getInputHTML( $value ) { @@ -1808,7 +1808,9 @@ class HTMLSelectOrOtherField extends HTMLTextField { function __construct( $params ) { if ( !in_array( 'other', $params['options'], true ) ) { - $msg = isset( $params['other'] ) ? $params['other'] : wfMsg( 'htmlform-selectorother-other' ); + $msg = isset( $params['other'] ) ? + $params['other'] : + wfMessage( 'htmlform-selectorother-other' )->text(); $params['options'][$msg] = 'other'; } @@ -1912,7 +1914,7 @@ class HTMLMultiSelectField extends HTMLFormField { if ( count( $validValues ) == count( $value ) ) { return true; } else { - return wfMsgExt( 'htmlform-select-badoption', 'parseinline' ); + return wfMessage( 'htmlform-select-badoption' )->parse(); } } @@ -2114,7 +2116,7 @@ class HTMLSelectAndOtherField extends HTMLSelectField { } elseif ( $text == '' ) { $final = $list; } else { - $final = $list . wfMsgForContent( 'colon-separator' ) . $text; + $final = $list . wfMessage( 'colon-separator' )->inContentLanguage()->text() . $text; } } else { @@ -2123,7 +2125,7 @@ class HTMLSelectAndOtherField extends HTMLSelectField { $list = 'other'; $text = $final; foreach ( $this->mFlatOptions as $option ) { - $match = $option . wfMsgForContent( 'colon-separator' ); + $match = $option . wfMessage( 'colon-separator' )->inContentLanguage()->text(); if ( strpos( $text, $match ) === 0 ) { $list = $option; $text = substr( $text, strlen( $match ) ); @@ -2151,7 +2153,7 @@ class HTMLSelectAndOtherField extends HTMLSelectField { } if ( isset( $this->mParams['required'] ) && $this->mParams['required'] !== false && $value[1] === '' ) { - return wfMsgExt( 'htmlform-required', 'parseinline' ); + return wfMessage( 'htmlform-required' )->parse(); } return true; @@ -2180,7 +2182,7 @@ class HTMLRadioField extends HTMLFormField { if ( in_array( $value, $validOptions ) ) { return true; } else { - return wfMsgExt( 'htmlform-select-badoption', 'parseinline' ); + return wfMessage( 'htmlform-select-badoption' )->parse(); } } diff --git a/includes/ImagePage.php b/includes/ImagePage.php index ab3e2e39ba..7d45bcdcf4 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -181,7 +181,7 @@ class ImagePage extends Article { $out->addHTML( Xml::element( 'h2', array( 'id' => 'filelinks' ), - wfMsg( 'imagelinks' ) ) . "\n" ); + wfMessage( 'imagelinks' )->text() ) . "\n" ); $this->imageDupes(); # @todo FIXME: For some freaky reason, we can't redirect to foreign images. # Yet we return metadata about the target. Definitely an issue in the FileRepo @@ -195,7 +195,10 @@ class ImagePage extends Article { } if ( $showmeta ) { - $out->addHTML( Xml::element( 'h2', array( 'id' => 'metadata' ), wfMsg( 'metadata' ) ) . "\n" ); + $out->addHTML( Xml::element( + 'h2', + array( 'id' => 'metadata' ), + wfMessage( 'metadata' )->text() ) . "\n" ); $out->addWikiText( $this->makeMetadataTable( $formattedMetadata ) ); $out->addModules( array( 'mediawiki.action.view.metadata' ) ); } @@ -227,12 +230,12 @@ class ImagePage extends Article { */ protected function showTOC( $metadata ) { $r = array( - '
  • ' . wfMsgHtml( 'file-anchor-link' ) . '
  • ', - '
  • ' . wfMsgHtml( 'filehist' ) . '
  • ', - '
  • ' . wfMsgHtml( 'imagelinks' ) . '
  • ', + '
  • ' . wfMessage( 'file-anchor-link' )->escaped() . '
  • ', + '
  • ' . wfMessage( 'filehist' )->escaped() . '
  • ', + '
  • ' . wfMessage( 'imagelinks' )->escaped() . '
  • ', ); if ( $metadata ) { - $r[] = '
  • ' . wfMsgHtml( 'metadata' ) . '
  • '; + $r[] = '
  • ' . wfMessage( 'metadata' )->escaped() . '
  • '; } wfRunHooks( 'ImagePageShowTOC', array( $this, &$r ) ); @@ -250,7 +253,7 @@ class ImagePage extends Article { */ protected function makeMetadataTable( $metadata ) { $r = "
    "; - $r .= wfMsgNoTrans( 'metadata-help' ); + $r .= wfMessage( 'metadata-help' )->plain(); $r .= "\n"; foreach ( $metadata as $type => $stuff ) { foreach ( $stuff as $v ) { @@ -322,7 +325,7 @@ class ImagePage extends Article { $height_orig = $this->displayImg->getHeight( $page ); $height = $height_orig; - $longDesc = wfMsg( 'parentheses', $this->displayImg->getLongDesc() ); + $longDesc = wfMessage( 'parentheses', $this->displayImg->getLongDesc() )->text(); wfRunHooks( 'ImageOpenShowImageInlineBefore', array( &$this, &$out ) ); @@ -330,7 +333,7 @@ class ImagePage extends Article { # image # "Download high res version" link below the image - # $msgsize = wfMsgHtml( 'file-info-size', $width_orig, $height_orig, Linker::formatSize( $this->displayImg->getSize() ), $mime ); + # $msgsize = wfMessage( 'file-info-size', $width_orig, $height_orig, Linker::formatSize( $this->displayImg->getSize() ), $mime )->escaped(); # We'll show a thumbnail of this image if ( $width > $maxWidth || $height > $maxHeight ) { # Calculate the thumbnail size. @@ -346,7 +349,7 @@ class ImagePage extends Article { # Note that $height <= $maxHeight now, but might not be identical # because of rounding. } - $msgbig = wfMsgHtml( 'show-big-image' ); + $msgbig = wfMessage( 'show-big-image' )->escaped(); if ( $this->displayImg->getRepo()->canTransformVia404() ) { $thumbSizes = $wgImageLimits; } else { @@ -411,7 +414,7 @@ class ImagePage extends Article { $count = $this->displayImg->pageCount(); if ( $page > 1 ) { - $label = $out->parse( wfMsg( 'imgmultipageprev' ), false ); + $label = $out->parse( wfMessage( 'imgmultipageprev' )->text(), false ); $link = Linker::linkKnown( $this->getTitle(), $label, @@ -425,7 +428,7 @@ class ImagePage extends Article { } if ( $page < $count ) { - $label = wfMsg( 'imgmultipagenext' ); + $label = wfMessage( 'imgmultipagenext' )->text(); $link = Linker::linkKnown( $this->getTitle(), $label, @@ -457,8 +460,8 @@ class ImagePage extends Article { '
    ' . Xml::openElement( 'form', $formParams ) . Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) . - wfMsgExt( 'imgmultigoto', array( 'parseinline', 'replaceafter' ), $select ) . - Xml::submitButton( wfMsg( 'imgmultigo' ) ) . + wfMessage( 'imgmultigoto' )->rawParams( $select )->parse() . + Xml::submitButton( wfMessage( 'imgmultigo' )->text() ) . Xml::closeElement( 'form' ) . "
    $thumb1\n$thumb2
    " ); @@ -485,7 +488,7 @@ class ImagePage extends Article { $medialink = "[[Media:$filename|$linktext]]"; if ( !$this->displayImg->isSafeFile() ) { - $warning = wfMsgNoTrans( 'mediawarning' ); + $warning = wfMessage( 'mediawarning' )->plain(); // dirmark is needed here to separate the file name, which // most likely ends in Latin characters, from the description, // which may begin with the file type. In RTL environment @@ -593,9 +596,9 @@ EOT $wrap = "
    \n$1\n
    \n"; $repo = $this->mPage->getFile()->getRepo()->getDisplayName(); - if ( $descUrl && $descText && wfMsgNoTrans( 'sharedupload-desc-here' ) !== '-' ) { + if ( $descUrl && $descText && wfMessage( 'sharedupload-desc-here' )->plain() !== '-' ) { $out->wrapWikiMsg( $wrap, array( 'sharedupload-desc-here', $repo, $descUrl ) ); - } elseif ( $descUrl && wfMsgNoTrans( 'sharedupload-desc-there' ) !== '-' ) { + } elseif ( $descUrl && wfMessage( 'sharedupload-desc-there' )->plain() !== '-' ) { $out->wrapWikiMsg( $wrap, array( 'sharedupload-desc-there', $repo, $descUrl ) ); } else { $out->wrapWikiMsg( $wrap, array( 'sharedupload', $repo ), ''/*BACKCOMPAT*/ ); @@ -636,7 +639,7 @@ EOT # "Upload a new version of this file" link if ( UploadBase::userCanReUpload( $this->getContext()->getUser(), $this->mPage->getFile()->name ) ) { - $ulink = Linker::makeExternalLink( $this->getUploadUrl(), wfMsg( 'uploadnewversion-linktext' ) ); + $ulink = Linker::makeExternalLink( $this->getUploadUrl(), wfMessage( 'uploadnewversion-linktext' )->text() ); $out->addHTML( "
  • {$ulink}
  • \n" ); } @@ -644,7 +647,7 @@ EOT if ( $wgUseExternalEditor ) { $elink = Linker::linkKnown( $this->getTitle(), - wfMsgHtml( 'edit-externally' ), + wfMessage( 'edit-externally' )->escaped(), array(), array( 'action' => 'edit', @@ -654,8 +657,8 @@ EOT ); $out->addHTML( '
  • ' . $elink . ' ' . - wfMsgExt( 'edit-externally-help', array( 'parseinline' ) ) . - "
  • \n" + wfMessage( 'edit-externally-help' )->parse() . + "\n" ); } @@ -829,7 +832,7 @@ EOT } else { $link = Linker::makeExternalLink( $file->getDescriptionUrl(), $file->getTitle()->getPrefixedText() ); - $fromSrc = wfMsg( 'shared-repo-from', $file->getRepo()->getDisplayName() ); + $fromSrc = wfMessage( 'shared-repo-from', $file->getRepo()->getDisplayName() )->text(); } $out->addHTML( "
  • {$link} {$fromSrc}
  • \n" ); } diff --git a/includes/Linker.php b/includes/Linker.php index 3a4f7c3d2e..fe2650b30f 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -345,7 +345,7 @@ class Linker { } elseif ( in_array( 'known', $options ) ) { $defaults['title'] = $target->getPrefixedText(); } else { - $defaults['title'] = wfMsg( 'red-link-title', $target->getPrefixedText() ); + $defaults['title'] = wfMessage( 'red-link-title', $target->getPrefixedText() )->text(); } # Finally, merge the custom attribs with the default ones, and iterate @@ -825,7 +825,7 @@ class Linker { $s .= self::makeBrokenImageLinkObj( $title, $fp['title'], '', '', '', $time == true ); $zoomIcon = ''; } elseif ( !$thumb ) { - $s .= htmlspecialchars( wfMsg( 'thumbnail_error', '' ) ); + $s .= wfMessage( 'thumbnail_error', '' )->escaped(); $zoomIcon = ''; } else { $params = array( @@ -841,7 +841,7 @@ class Linker { Html::rawElement( 'a', array( 'href' => $url, 'class' => 'internal', - 'title' => wfMsg( 'thumbnail-more' ) ), + 'title' => wfMessage( 'thumbnail-more' )->text() ), Html::element( 'img', array( 'src' => $wgStylePath . '/common/images/magnify-clip' . ( $wgContLang->isRTL() ? '-rtl' : '' ) . '.png', 'width' => 15, @@ -971,7 +971,7 @@ class Linker { $key = strtolower( $name ); } - return self::linkKnown( SpecialPage::getTitleFor( $name ) , wfMsg( $key ) ); + return self::linkKnown( SpecialPage::getTitleFor( $name ) , wfMessage( $key )->text() ); } /** @@ -1063,7 +1063,7 @@ class Linker { } $contribsPage = SpecialPage::getTitleFor( 'Contributions', $userText ); - $items[] = self::link( $contribsPage, wfMsgHtml( 'contribslink' ), $attribs ); + $items[] = self::link( $contribsPage, wfMessage( 'contribslink' )->escaped(), $attribs ); } if ( $blockable && $wgUser->isAllowed( 'block' ) ) { $items[] = self::blockLink( $userId, $userText ); @@ -1104,7 +1104,7 @@ class Linker { */ public static function userTalkLink( $userId, $userText ) { $userTalkPage = Title::makeTitle( NS_USER_TALK, $userText ); - $userTalkLink = self::link( $userTalkPage, wfMsgHtml( 'talkpagelinktext' ) ); + $userTalkLink = self::link( $userTalkPage, wfMessage( 'talkpagelinktext' )->escaped() ); return $userTalkLink; } @@ -1115,7 +1115,7 @@ class Linker { */ public static function blockLink( $userId, $userText ) { $blockPage = SpecialPage::getTitleFor( 'Block', $userText ); - $blockLink = self::link( $blockPage, wfMsgHtml( 'blocklink' ) ); + $blockLink = self::link( $blockPage, wfMessage( 'blocklink' )->escaped() ); return $blockLink; } @@ -1126,7 +1126,7 @@ class Linker { */ public static function emailLink( $userId, $userText ) { $emailPage = SpecialPage::getTitleFor( 'Emailuser', $userText ); - $emailLink = self::link( $emailPage, wfMsgHtml( 'emaillink' ) ); + $emailLink = self::link( $emailPage, wfMessage( 'emaillink' )->escaped() ); return $emailLink; } @@ -1138,12 +1138,12 @@ class Linker { */ public static function revUserLink( $rev, $isPublic = false ) { if ( $rev->isDeleted( Revision::DELETED_USER ) && $isPublic ) { - $link = wfMsgHtml( 'rev-deleted-user' ); + $link = wfMessage( 'rev-deleted-user' )->escaped(); } elseif ( $rev->userCan( Revision::DELETED_USER ) ) { $link = self::userLink( $rev->getUser( Revision::FOR_THIS_USER ), $rev->getUserText( Revision::FOR_THIS_USER ) ); } else { - $link = wfMsgHtml( 'rev-deleted-user' ); + $link = wfMessage( 'rev-deleted-user' )->escaped(); } if ( $rev->isDeleted( Revision::DELETED_USER ) ) { return '' . $link . ''; @@ -1159,7 +1159,7 @@ class Linker { */ public static function revUserTools( $rev, $isPublic = false ) { if ( $rev->isDeleted( Revision::DELETED_USER ) && $isPublic ) { - $link = wfMsgHtml( 'rev-deleted-user' ); + $link = wfMessage( 'rev-deleted-user' )->escaped(); } elseif ( $rev->userCan( Revision::DELETED_USER ) ) { $userId = $rev->getUser( Revision::FOR_THIS_USER ); $userText = $rev->getUserText( Revision::FOR_THIS_USER ); @@ -1167,7 +1167,7 @@ class Linker { . wfMessage( 'word-separator' )->plain() . self::userToolLinks( $userId, $userText ); } else { - $link = wfMsgHtml( 'rev-deleted-user' ); + $link = wfMessage( 'rev-deleted-user' )->escaped(); } if ( $rev->isDeleted( Revision::DELETED_USER ) ) { return ' ' . $link . ''; @@ -1281,11 +1281,11 @@ class Linker { } if ( $pre ) { # written summary $presep autocomment (summary /* section */) - $pre .= wfMsgExt( 'autocomment-prefix', array( 'escapenoentities', 'content' ) ); + $pre .= wfMessage( 'autocomment-prefix' )->inContentLanguage()->escaped(); } if ( $post ) { # autocomment $postsep written summary (/* section */ summary) - $auto .= wfMsgExt( 'colon-separator', array( 'escapenoentities', 'content' ) ); + $auto .= wfMessage( 'colon-separator' )->inContentLanguage()->escaped(); } $auto = '' . $auto . ''; $comment = $pre . $link . $wgLang->getDirMark() . '' . $auto . $post . ''; @@ -1507,12 +1507,12 @@ class Linker { return ""; } if ( $rev->isDeleted( Revision::DELETED_COMMENT ) && $isPublic ) { - $block = " " . wfMsgHtml( 'rev-deleted-comment' ) . ""; + $block = " " . wfMessage( 'rev-deleted-comment' )->escaped() . ""; } elseif ( $rev->userCan( Revision::DELETED_COMMENT ) ) { $block = self::commentBlock( $rev->getComment( Revision::FOR_THIS_USER ), $rev->getTitle(), $local ); } else { - $block = " " . wfMsgHtml( 'rev-deleted-comment' ) . ""; + $block = " " . wfMessage( 'rev-deleted-comment' )->escaped() . ""; } if ( $rev->isDeleted( Revision::DELETED_COMMENT ) ) { return " $block"; @@ -1526,13 +1526,11 @@ class Linker { */ public static function formatRevisionSize( $size ) { if ( $size == 0 ) { - $stxt = wfMsgExt( 'historyempty', 'parsemag' ); + $stxt = wfMessage( 'historyempty' )->escaped(); } else { - global $wgLang; - $stxt = wfMsgExt( 'nbytes', 'parsemag', $wgLang->formatNum( $size ) ); + $stxt = wfMessage( 'nbytes' )->numParams( $size )->escaped(); $stxt = wfMessage( 'parentheses' )->rawParams( $stxt )->escaped(); } - $stxt = htmlspecialchars( $stxt ); return "$stxt"; } @@ -1588,7 +1586,7 @@ class Linker { * @return String: full html of the TOC */ public static function tocList( $toc, $lang = false ) { - $title = wfMsgExt( 'toc', array( 'language' => $lang, 'escape' ) ); + $title = wfMessage( 'toc' )->inLanguage( $lang )->escaped(); return '
    ' . '

    ' . $title . "

    \n" @@ -1803,11 +1801,14 @@ class Linker { # Construct the HTML $outText = '
    '; if ( $preview ) { - $outText .= wfMsgExt( 'templatesusedpreview', array( 'parse' ), count( $templates ) ); + $outText .= wfMessage( 'templatesusedpreview' )->numParams( count( $templates ) ) + ->parseAsBlock(); } elseif ( $section ) { - $outText .= wfMsgExt( 'templatesusedsection', array( 'parse' ), count( $templates ) ); + $outText .= wfMessage( 'templatesusedsection' )->numParams( count( $templates ) ) + ->parseAsBlock(); } else { - $outText .= wfMsgExt( 'templatesused', array( 'parse' ), count( $templates ) ); + $outText .= wfMessage( 'templatesused' )->numParams( count( $templates ) ) + ->parseAsBlock(); } $outText .= "
      \n"; @@ -1815,23 +1816,23 @@ class Linker { foreach ( $templates as $titleObj ) { $r = $titleObj->getRestrictions( 'edit' ); if ( in_array( 'sysop', $r ) ) { - $protected = wfMsgExt( 'template-protected', array( 'parseinline' ) ); + $protected = wfMessage( 'template-protected' )->parse(); } elseif ( in_array( 'autoconfirmed', $r ) ) { - $protected = wfMsgExt( 'template-semiprotected', array( 'parseinline' ) ); + $protected = wfMessage( 'template-semiprotected' )->parse(); } else { $protected = ''; } if ( $titleObj->quickUserCan( 'edit' ) ) { $editLink = self::link( $titleObj, - wfMsg( 'editlink' ), + wfMessage( 'editlink' )->text(), array(), array( 'action' => 'edit' ) ); } else { $editLink = self::link( $titleObj, - wfMsg( 'viewsourcelink' ), + wfMessage( 'viewsourcelink' )->text(), array(), array( 'action' => 'edit' ) ); @@ -1859,7 +1860,7 @@ class Linker { if ( count( $hiddencats ) > 0 ) { # Construct the HTML $outText = '
      '; - $outText .= wfMsgExt( 'hiddencategories', array( 'parse' ), $wgLang->formatnum( count( $hiddencats ) ) ); + $outText .= wfMessage( 'hiddencategories' )->numParams( count( $hiddencats ) )->parseAsBlock(); $outText .= "
        \n"; foreach ( $hiddencats as $titleObj ) { @@ -2019,7 +2020,8 @@ class Linker { */ public static function revDeleteLink( $query = array(), $restricted = false, $delete = true ) { $sp = SpecialPage::getTitleFor( 'Revisiondelete' ); - $html = $delete ? wfMsgHtml( 'rev-delundel' ) : wfMsgHtml( 'rev-showdeleted' ); + $msgKey = $delete ? 'rev-delundel' : 'rev-showdeleted'; + $html = wfMessage( $msgKey )->escaped(); $tag = $restricted ? 'strong' : 'span'; $link = self::link( $sp, $html, array(), $query, array( 'known', 'noclasses' ) ); return Xml::tags( $tag, array( 'class' => 'mw-revdelundel-link' ), wfMessage( 'parentheses' )->rawParams( $link )->escaped() ); @@ -2034,8 +2036,10 @@ class Linker { * of appearance with CSS */ public static function revDeleteLinkDisabled( $delete = true ) { - $html = $delete ? wfMsgHtml( 'rev-delundel' ) : wfMsgHtml( 'rev-showdeleted' ); - return Xml::tags( 'span', array( 'class' => 'mw-revdelundel-link' ), wfMessage( 'parentheses' )->rawParams( $html )->escaped() ); + $msgKey = $delete ? 'rev-delundel' : 'rev-showdeleted'; + $html = wfMessage( $msgKey )->escaped(); + $htmlParentheses = wfMessage( 'parentheses' )->rawParams( $html )->escaped(); + return Xml::tags( 'span', array( 'class' => 'mw-revdelundel-link' ), $htmlParentheses ); } /* Deprecated methods */ -- 2.20.1