r100529 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100528‎ | r100529 | r100530 >
Date:08:13, 23 October 2011
Author:ialex
Status:ok
Tags:
Comment:
* Use local context to get messages
* Simply use getLang() instead of getContext()->getLang() now that this method exists
* Also changed addWikiMsgArray() to use a Message object with addWikiText() for the parse operation; removed its $options parameter, no caller was using it
Modified paths:
  • /trunk/phase3/includes/OutputPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/OutputPage.php
@@ -784,7 +784,7 @@
785785 $this->mPagetitle = $nameWithTags;
786786
787787 # change "<i>foo&amp;bar</i>" to "foo&bar"
788 - $this->setHTMLTitle( wfMsg( 'pagetitle', Sanitizer::stripAllTags( $nameWithTags ) ) );
 788+ $this->setHTMLTitle( $this->msg( 'pagetitle', Sanitizer::stripAllTags( $nameWithTags ) )->text() );
789789 }
790790
791791 /**
@@ -1927,8 +1927,8 @@
19281928 if ( $this->getTitle() ) {
19291929 $this->mDebugtext .= 'Original title: ' . $this->getTitle()->getPrefixedText() . "\n";
19301930 }
1931 - $this->setPageTitle( wfMsg( $title ) );
1932 - $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
 1931+ $this->setPageTitle( $this->msg( $title )->text() );
 1932+ $this->setHTMLTitle( $this->msg( 'errorpagetitle' )->text() );
19331933 $this->setRobotPolicy( 'noindex,nofollow' );
19341934 $this->setArticleRelated( false );
19351935 $this->enableClientCache( false );
@@ -1953,8 +1953,8 @@
19541954 public function showPermissionsErrorPage( $errors, $action = null ) {
19551955 $this->mDebugtext .= 'Original title: ' .
19561956 $this->getTitle()->getPrefixedText() . "\n";
1957 - $this->setPageTitle( wfMsg( 'permissionserrors' ) );
1958 - $this->setHTMLTitle( wfMsg( 'permissionserrors' ) );
 1957+ $this->setPageTitle( $this->msg( 'permissionserrors' )->text() );
 1958+ $this->setHTMLTitle( $this->msg( 'permissionserrors' )->text() );
19591959 $this->setRobotPolicy( 'noindex,nofollow' );
19601960 $this->setArticleRelated( false );
19611961 $this->enableClientCache( false );
@@ -1970,8 +1970,8 @@
19711971 * @param $version Mixed: the version of MediaWiki needed to use the page
19721972 */
19731973 public function versionRequired( $version ) {
1974 - $this->setPageTitle( wfMsg( 'versionrequired', $version ) );
1975 - $this->setHTMLTitle( wfMsg( 'versionrequired', $version ) );
 1974+ $this->setPageTitle( $this->msg( 'versionrequired', $version )->text() );
 1975+ $this->setHTMLTitle( $this->msg( 'versionrequired', $version )->text() );
19761976 $this->setRobotPolicy( 'noindex,nofollow' );
19771977 $this->setArticleRelated( false );
19781978 $this->mBodytext = '';
@@ -1997,19 +1997,19 @@
19981998 throw new PermissionsError( 'read' );
19991999 }
20002000
2001 - $this->setPageTitle( wfMsg( 'loginreqtitle' ) );
2002 - $this->setHtmlTitle( wfMsg( 'errorpagetitle' ) );
 2001+ $this->setPageTitle( $this->msg( 'loginreqtitle' )->text() );
 2002+ $this->setHTMLTitle( $this->msg( 'errorpagetitle' )->text() );
20032003 $this->setRobotPolicy( 'noindex,nofollow' );
20042004 $this->setArticleRelated( false );
20052005
20062006 $loginTitle = SpecialPage::getTitleFor( 'Userlogin' );
20072007 $loginLink = Linker::linkKnown(
20082008 $loginTitle,
2009 - wfMsgHtml( 'loginreqlink' ),
 2009+ $this->msg( 'loginreqlink' )->escaped(),
20102010 array(),
20112011 array( 'returnto' => $this->getTitle()->getPrefixedText() )
20122012 );
2013 - $this->addHTML( wfMessage( 'loginreqpagetext' )->rawParams( $loginLink )->parse() .
 2013+ $this->addHTML( $this->msg( 'loginreqpagetext' )->rawParams( $loginLink )->parse() .
20142014 "\n<!--" . $this->getTitle()->getPrefixedUrl() . '-->' );
20152015
20162016 # Don't return to the main page if the user can't read it
@@ -2029,14 +2029,14 @@
20302030 */
20312031 public function formatPermissionsErrorMessage( $errors, $action = null ) {
20322032 if ( $action == null ) {
2033 - $text = wfMsgNoTrans( 'permissionserrorstext', count( $errors ) ) . "\n\n";
 2033+ $text = $this->msg( 'permissionserrorstext', count( $errors ) )->plain() . "\n\n";
20342034 } else {
2035 - $action_desc = wfMsgNoTrans( "action-$action" );
2036 - $text = wfMsgNoTrans(
 2035+ $action_desc = $this->msg( "action-$action" )->plain();
 2036+ $text = $this->msg(
20372037 'permissionserrorstext-withaction',
20382038 count( $errors ),
20392039 $action_desc
2040 - ) . "\n\n";
 2040+ )->plain() . "\n\n";
20412041 }
20422042
20432043 if ( count( $errors ) > 1 ) {
@@ -2044,13 +2044,13 @@
20452045
20462046 foreach( $errors as $error ) {
20472047 $text .= '<li>';
2048 - $text .= call_user_func_array( 'wfMsgNoTrans', $error );
 2048+ $text .= call_user_func_array( array( $this, 'msg' ), $error )->plain();
20492049 $text .= "</li>\n";
20502050 }
20512051 $text .= '</ul>';
20522052 } else {
20532053 $text .= "<div class=\"permissions-errors\">\n" .
2054 - call_user_func_array( 'wfMsgNoTrans', reset( $errors ) ) .
 2054+ call_user_func_array( array( $this, 'msg' ), reset( $errors ) )->plain() .
20552055 "\n</div>";
20562056 }
20572057
@@ -2090,12 +2090,12 @@
20912091 if ( !empty( $reasons ) ) {
20922092 // Permissions error
20932093 if( $source ) {
2094 - $this->setPageTitle( wfMsg( 'viewsource' ) );
 2094+ $this->setPageTitle( $this->msg( 'viewsource' )->text() );
20952095 $this->setSubtitle(
2096 - wfMsg( 'viewsourcefor', Linker::linkKnown( $this->getTitle() ) )
 2096+ $this->msg( 'viewsourcefor', Linker::linkKnown( $this->getTitle() ) )->text()
20972097 );
20982098 } else {
2099 - $this->setPageTitle( wfMsg( 'badaccess' ) );
 2099+ $this->setPageTitle( $this->msg( 'badaccess' )->text() );
21002100 }
21012101 $this->addWikiText( $this->formatPermissionsErrorMessage( $reasons, $action ) );
21022102 } else {
@@ -2160,12 +2160,12 @@
21612161 ? 'lag-warn-normal'
21622162 : 'lag-warn-high';
21632163 $wrap = Html::rawElement( 'div', array( 'class' => "mw-{$message}" ), "\n$1\n" );
2164 - $this->wrapWikiMsg( "$wrap\n", array( $message, $this->getContext()->getLang()->formatNum( $lag ) ) );
 2164+ $this->wrapWikiMsg( "$wrap\n", array( $message, $this->getLang()->formatNum( $lag ) ) );
21652165 }
21662166 }
21672167
21682168 public function showFatalError( $message ) {
2169 - $this->setPageTitle( wfMsg( 'internalerror' ) );
 2169+ $this->setPageTitle( $this->msg( 'internalerror' )->text() );
21702170 $this->setRobotPolicy( 'noindex,nofollow' );
21712171 $this->setArticleRelated( false );
21722172 $this->enableClientCache( false );
@@ -2174,23 +2174,23 @@
21752175 }
21762176
21772177 public function showUnexpectedValueError( $name, $val ) {
2178 - $this->showFatalError( wfMsg( 'unexpected', $name, $val ) );
 2178+ $this->showFatalError( $this->msg( 'unexpected', $name, $val )->text() );
21792179 }
21802180
21812181 public function showFileCopyError( $old, $new ) {
2182 - $this->showFatalError( wfMsg( 'filecopyerror', $old, $new ) );
 2182+ $this->showFatalError( $this->msg( 'filecopyerror', $old, $new )->text() );
21832183 }
21842184
21852185 public function showFileRenameError( $old, $new ) {
2186 - $this->showFatalError( wfMsg( 'filerenameerror', $old, $new ) );
 2186+ $this->showFatalError( $this->msg( 'filerenameerror', $old, $new )->text() );
21872187 }
21882188
21892189 public function showFileDeleteError( $name ) {
2190 - $this->showFatalError( wfMsg( 'filedeleteerror', $name ) );
 2190+ $this->showFatalError( $this->msg( 'filedeleteerror', $name )->text() );
21912191 }
21922192
21932193 public function showFileNotFoundError( $name ) {
2194 - $this->showFatalError( wfMsg( 'filenotfound', $name ) );
 2194+ $this->showFatalError( $this->msg( 'filenotfound', $name )->text() );
21952195 }
21962196
21972197 /**
@@ -2202,10 +2202,8 @@
22032203 */
22042204 public function addReturnTo( $title, $query = array(), $text = null ) {
22052205 $this->addLink( array( 'rel' => 'next', 'href' => $title->getFullURL() ) );
2206 - $link = wfMsgHtml(
2207 - 'returnto',
2208 - Linker::link( $title, $text, array(), $query )
2209 - );
 2206+ $link = $this->msg( 'returnto' )->rawParams(
 2207+ Linker::link( $title, $text, array(), $query ) )->escaped();
22102208 $this->addHTML( "<p id=\"mw-returnto\">{$link}</p>\n" );
22112209 }
22122210
@@ -2259,7 +2257,7 @@
22602258 $ret = Html::htmlHeader( array( 'lang' => $this->getLang()->getCode(), 'dir' => $userdir, 'class' => 'client-nojs' ) );
22612259
22622260 if ( $this->getHTMLTitle() == '' ) {
2263 - $this->setHTMLTitle( wfMsg( 'pagetitle', $this->getPageTitle() ) );
 2261+ $this->setHTMLTitle( $this->msg( 'pagetitle', $this->getPageTitle() )->text() );
22642262 }
22652263
22662264 $openHead = Html::openElement( 'head' );
@@ -2291,7 +2289,7 @@
22922290 # Classes for LTR/RTL directionality support
22932291 $bodyAttrs['class'] = "mediawiki $userdir sitedir-$sitedir";
22942292
2295 - if ( $this->getContext()->getLang()->capitalizeAllNouns() ) {
 2293+ if ( $this->getLang()->capitalizeAllNouns() ) {
22962294 # A <body> class is probably not the best way to do this . . .
22972295 $bodyAttrs['class'] .= ' capitalize-all-nouns';
22982296 }
@@ -2425,7 +2423,7 @@
24262424 // correct timestamp and emptiness data
24272425 $query = ResourceLoader::makeLoaderQuery(
24282426 array(), // modules; not determined yet
2429 - $this->getContext()->getLang()->getCode(),
 2427+ $this->getLang()->getCode(),
24302428 $this->getSkin()->getSkinName(),
24312429 $user,
24322430 null, // version; not determined yet
@@ -2481,7 +2479,7 @@
24822480
24832481 $url = ResourceLoader::makeLoaderURL(
24842482 array_keys( $modules ),
2485 - $this->getContext()->getLang()->getCode(),
 2483+ $this->getLang()->getCode(),
24862484 $this->getSkin()->getSkinName(),
24872485 $user,
24882486 $version,
@@ -2800,7 +2798,7 @@
28012799 if ( $this->isArticleRelated() && $this->getTitle() && $this->getTitle()->quickUserCan( 'edit' )
28022800 && ( $this->getTitle()->exists() || $this->getTitle()->quickUserCan( 'create' ) ) ) {
28032801 // Original UniversalEditButton
2804 - $msg = wfMsg( 'edit' );
 2802+ $msg = $this->msg( 'edit' )->text();
28052803 $tags[] = Html::element( 'link', array(
28062804 'rel' => 'alternate',
28072805 'type' => 'application/x-wiki',
@@ -2833,7 +2831,7 @@
28342832 'rel' => 'search',
28352833 'type' => 'application/opensearchdescription+xml',
28362834 'href' => wfScript( 'opensearch_desc' ),
2837 - 'title' => wfMsgForContent( 'opensearch-desc' ),
 2835+ 'title' => $this->msg( 'opensearch-desc' )->inContentLanguage()->text(),
28382836 ) );
28392837
28402838 if ( $wgEnableAPI ) {
@@ -2908,7 +2906,7 @@
29092907 $format,
29102908 $link,
29112909 # Used messages: 'page-rss-feed' and 'page-atom-feed' (for an easier grep)
2912 - wfMsg( "page-{$format}-feed", $this->getTitle()->getPrefixedText() )
 2910+ $this->msg( "page-{$format}-feed", $this->getTitle()->getPrefixedText() )->text()
29132911 );
29142912 }
29152913
@@ -2928,7 +2926,7 @@
29292927 $tags[] = $this->feedLink(
29302928 $type,
29312929 $feedUrl,
2932 - wfMsg( "site-{$type}-feed", $wgSitename )
 2930+ $this->msg( "site-{$type}-feed", $wgSitename )->text()
29332931 );
29342932 }
29352933 } elseif ( $this->getTitle()->getPrefixedText() != $rctitle->getPrefixedText() ) {
@@ -2936,7 +2934,7 @@
29372935 $tags[] = $this->feedLink(
29382936 $format,
29392937 $rctitle->getLocalURL( "feed={$format}" ),
2940 - wfMsg( "site-{$format}-feed", $wgSitename ) # For grep: 'site-rss-feed', 'site-atom-feed'.
 2938+ $this->msg( "site-{$format}-feed", $wgSitename )->text() # For grep: 'site-rss-feed', 'site-atom-feed'.
29412939 );
29422940 }
29432941 }
@@ -3199,16 +3197,11 @@
32003198 * Like addWikiMsg() except the parameters are taken as an array
32013199 * instead of a variable argument list.
32023200 *
3203 - * $options is passed through to wfMsgExt(), see that function for details.
3204 - *
32053201 * @param $name string
32063202 * @param $args array
3207 - * @param $options array
32083203 */
3209 - public function addWikiMsgArray( $name, $args, $options = array() ) {
3210 - $options[] = 'parse';
3211 - $text = wfMsgExt( $name, $options, $args );
3212 - $this->addHTML( $text );
 3204+ public function addWikiMsgArray( $name, $args ) {
 3205+ $this->addWikiText( $this->msg( $name, $args )->plain() );
32133206 }
32143207
32153208 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r113394* (bug 35014) Fix for r100529: including a special page no longer sets the pa...ialex20:06, 8 March 2012

Status & tagging log