r111142 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111141‎ | r111142 | r111143 >
Date:01:19, 10 February 2012
Author:robin
Status:deferred (Comments)
Tags:
Comment:
Update all wfMsg*() -> wfMessage(), and drop DummyLinker compatibility
Modified paths:
  • /trunk/extensions/WikimediaIncubator/IncubatorTest.php (modified) (history)
  • /trunk/extensions/WikimediaIncubator/InfoPage.php (modified) (history)
  • /trunk/extensions/WikimediaIncubator/ListUsersTestWiki.php (modified) (history)
  • /trunk/extensions/WikimediaIncubator/SpecialViewUserLang.php (modified) (history)
  • /trunk/extensions/WikimediaIncubator/TestWikiRC.php (modified) (history)
  • /trunk/extensions/WikimediaIncubator/WikimediaIncubator.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WikimediaIncubator/WikimediaIncubator.php
@@ -16,7 +16,7 @@
1717 'path' => __FILE__,
1818 'name' => 'Wikimedia Incubator',
1919 'author' => 'SPQRobin',
20 - 'version' => '4.7',
 20+ 'version' => '4.8',
2121 'url' => '//www.mediawiki.org/wiki/Extension:WikimediaIncubator',
2222 'descriptionmsg' => 'wminc-desc',
2323 );
Index: trunk/extensions/WikimediaIncubator/SpecialViewUserLang.php
@@ -19,7 +19,7 @@
2020 /**
2121 * @return String
2222 */
23 - function getDescription() { return wfMsg( 'wminc-viewuserlang' ); }
 23+ function getDescription() { return wfMessage( 'wminc-viewuserlang' )->plain(); }
2424
2525 /**
2626 * Show the special page
@@ -52,13 +52,13 @@
5353 global $wgScript, $wgOut;
5454
5555 $wgOut->addHTML(
56 - Xml::fieldset( wfMsgHtml( 'wminc-viewuserlang' ) ) .
 56+ Xml::fieldset( wfMessage( 'wminc-viewuserlang' )->plain() ) .
5757 Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) .
5858 Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
5959 "<p>" .
60 - Xml::inputLabel( wfMsgHtml( 'wminc-viewuserlang-user' ), 'target', 'viewuserlang-username', 40, $target ) .
 60+ Xml::inputLabel( wfMessage( 'wminc-viewuserlang-user' )->text(), 'target', 'viewuserlang-username', 40, $target ) .
6161 ' ' .
62 - Xml::submitButton( wfMsgHtml( 'wminc-viewuserlang-go' ) ) .
 62+ Xml::submitButton( wfMessage( 'wminc-viewuserlang-go' )->text() ) .
6363 "</p>" .
6464 Xml::closeElement( 'form' ) .
6565 Xml::closeElement( 'fieldset' )
@@ -73,17 +73,16 @@
7474 global $wgOut, $wmincPref, $wmincProjectSite;
7575 if( User::isIP( $target ) ) {
7676 # show error if it is an IP address
77 - $wgOut->addHTML( Xml::span( wfMsg( 'wminc-ip', $target ), 'error' ) );
 77+ $wgOut->addHTML( Xml::span( wfMessage( 'wminc-ip', $target )->text(), 'error' ) );
7878 return;
7979 }
8080 $user = User::newFromName( $target );
8181 $name = $user->getName();
8282 $id = $user->getId();
8383 $langNames = Language::getLanguageNames();
84 - $linker = class_exists( 'DummyLinker' ) ? new DummyLinker : new Linker;
8584 if ( $user == null || $id == 0 ) {
8685 # show error if a user with that name does not exist
87 - $wgOut->addHTML( Xml::span( wfMsg( 'wminc-userdoesnotexist', $target ), 'error' ) );
 86+ $wgOut->addHTML( Xml::span( wfMessage( 'wminc-userdoesnotexist', $target )->text(), 'error' ) );
8887 return;
8988 }
9089 $userproject = $user->getOption( $wmincPref . '-project' );
@@ -91,19 +90,19 @@
9291 $usercode = $user->getOption( $wmincPref . '-code' );
9392 $prefix = IncubatorTest::displayPrefix( $userproject, $usercode ? $usercode : 'none' );
9493 if ( IncubatorTest::isContentProject( $userproject ) ) {
95 - $testwiki = $linker->link( Title::newFromText( $prefix ) );
 94+ $testwiki = Linker::link( Title::newFromText( $prefix ) );
9695 } elseif ( $prefix == $wmincProjectSite['short'] ) {
9796 $testwiki = htmlspecialchars( $wmincProjectSite['name'] );
9897 } else {
99 - $testwiki = wfMsgHtml( 'wminc-testwiki-none' );
 98+ $testwiki = wfMessage( 'wminc-testwiki-none' )->escaped();
10099 }
101100 $wgOut->addHtml(
102101 Xml::openElement( 'ul' ) .
103 - '<li>' . wfMsgHtml( 'username' ) . ' ' .
104 - $linker->userLink( $id, $name ) . $linker->userToolLinks( $id, $name, true ) . '</li>' .
105 - '<li>' . wfMsgHtml( 'loginlanguagelabel', $langNames[$user->getOption( 'language' )] .
106 - ' (' . $user->getOption( 'language' ) . ')' ) . '</li>' .
107 - '<li>' . wfMsgHtml( 'wminc-testwiki' ) . ' ' . $testwiki . '</li>' .
 102+ '<li>' . wfMessage( 'username' )->escaped() . ' ' .
 103+ Linker::userLink( $id, $name ) . Linker::userToolLinks( $id, $name, true ) . '</li>' .
 104+ '<li>' . wfMessage( 'loginlanguagelabel', $langNames[$user->getOption( 'language' )] .
 105+ ' (' . $user->getOption( 'language' ) . ')' )->escaped() . '</li>' .
 106+ '<li>' . wfMessage( 'wminc-testwiki' )->escaped() . ' ' . $testwiki . '</li>' .
108107 Xml::closeElement( 'ul' )
109108 );
110109 }
Index: trunk/extensions/WikimediaIncubator/ListUsersTestWiki.php
@@ -24,7 +24,7 @@
2525 $testwiki = IncubatorTest::getUrlParam();
2626 $project = self::getProjectInput();
2727 $input = $project ? $project['name'] : ( $testwiki ? $testwiki['prefix'] : null );
28 - $out .= Xml::label( wfMsg( 'wminc-testwiki' ), 'testwiki' ) . ' ' .
 28+ $out .= Xml::label( wfMessage( 'wminc-testwiki' )->text(), 'testwiki' ) . ' ' .
2929 Xml::input( 'testwiki', 20, $input, array( 'id' => 'testwiki' ) ) . '<br />';
3030 return true;
3131 }
@@ -38,12 +38,12 @@
3939 static function onSpecialListusersHeader( $pager, &$out ) {
4040 $project = self::getProjectInput();
4141 if( $project ) {
42 - $out .= wfMsgWikiHtml( 'wminc-listusers-testwiki', '"' . $project['name'] . '"' );
 42+ $out .= wfMessage( 'wminc-listusers-testwiki', '"' . $project['name'] . '"' )->parse();
4343 } else {
4444 $testwiki = IncubatorTest::getUrlParam();
4545 if ( $testwiki ) {
4646 $link = Linker::linkKnown( Title::newFromText( $testwiki['prefix'] ) );
47 - $out .= wfMsgWikiHtml( 'wminc-listusers-testwiki', $link );
 47+ $out .= wfMessage( 'wminc-listusers-testwiki', $link )->parse();
4848 }
4949 }
5050 return true;
Index: trunk/extensions/WikimediaIncubator/IncubatorTest.php
@@ -26,7 +26,7 @@
2727 $prefinsert[$wmincPref . '-project'] = array(
2828 'type' => 'select',
2929 'options' =>
30 - array( wfMsg( 'wminc-testwiki-none' ) => 'none' ) +
 30+ array( wfMessage( 'wminc-testwiki-none' )->plain() => 'none' ) +
3131 array_flip( $wmincProjects ) +
3232 array( $wmincProjectSite['name'] => $wmincProjectSite['short'] ),
3333 'section' => 'personal/i18n',
@@ -66,7 +66,7 @@
6767 array_key_exists( $alldata[$wmincPref.'-project'], $wmincProjects ) &&
6868 !$input ) {
6969 return Xml::element( 'span', array( 'class' => 'error' ),
70 - wfMsg( 'wminc-prefinfo-error' ) );
 70+ wfMessage( 'wminc-prefinfo-error' )->plain() );
7171 } else {
7272 return true;
7373 }
@@ -358,7 +358,7 @@
359359 static function checkPrefixMovePermissions( $oldtitle, $newtitle, $user, &$error ) {
360360 if( self::shouldWeShowUnprefixedError( $newtitle ) ) {
361361 # there should be an error with the new page title
362 - $error = wfMsgWikiHtml( 'wminc-error-move-unprefixed' );
 362+ $error = wfMessage( 'wminc-error-move-unprefixed' )->parse();
363363 return false;
364364 }
365365 return true;
@@ -374,9 +374,9 @@
375375 global $wgUser;
376376 if ( $wgUser->isAllowed( 'viewuserlang' ) ) {
377377 $user = $nt->getText();
378 - $links[] = $wgUser->getSkin()->link(
 378+ $links[] = Linker::link(
379379 SpecialPage::getTitleFor( 'ViewUserLang', $user ),
380 - wfMsgHtml( 'wminc-viewuserlang' )
 380+ wfMessage( 'wminc-viewuserlang' )->escaped()
381381 );
382382 }
383383 return true;
@@ -488,7 +488,7 @@
489489 # Show a link to the existing wiki
490490 $showLink = self::makeExternalLinkText( $link, true );
491491 $wgOut->addHtml( '<div class="wminc-wiki-exists">' .
492 - wfMsgHtml( 'wminc-error-wiki-exists', $showLink ) .
 492+ wfMessage( 'wminc-error-wiki-exists' )->rawParams( $showLink )->escaped() .
493493 '</div>' );
494494 }
495495 } elseif( array_key_exists( $p, $wmincSisterProjects ) ) {
@@ -497,7 +497,7 @@
498498 ( $title->getNsText() ? $title->getNsText() . ':' : '' ) . $prefix2['realtitle'] );
499499 $showLink = self::makeExternalLinkText( $link, true );
500500 $wgOut->addHtml( '<div class="wminc-wiki-sister">' .
501 - wfMsgHtml( 'wminc-error-wiki-sister', $showLink ) .
 501+ wfMessage( 'wminc-error-wiki-sister' )->rawParams( $showLink )->escaped() .
502502 '</div>' );
503503 } elseif ( self::shouldWeShowUnprefixedError( $title ) ) {
504504 # Unprefixed pages
@@ -508,7 +508,7 @@
509509 $suggest = self::displayPrefixedTitle( $suggesttitle, $title->getNamespace() );
510510 # Suggest to create a prefixed page
511511 $wgOut->addHtml( '<div class="wminc-unprefixed-suggest">' .
512 - wfMsgWikiHtml( 'wminc-error-unprefixed-suggest', $suggest ) .
 512+ wfMessage( 'wminc-error-unprefixed-suggest', $suggest )->parseAsBlock() .
513513 '</div>' );
514514 } else {
515515 $wgOut->addWikiMsg( 'wminc-error-unprefixed' );
@@ -535,7 +535,7 @@
536536 $wgOut->addHtml( $infopage->showMissingWiki() );
537537 }
538538 # Set the page title from "Wx/xyz - Incubator" to "Wikiproject Language - Incubator"
539 - $wgOut->setHTMLTitle( wfMsg( 'pagetitle', $infopage->mFormatTitle ) );
 539+ $wgOut->setHTMLTitle( wfMessage( 'pagetitle', $infopage->mFormatTitle )->text() );
540540 return true;
541541 }
542542
@@ -591,7 +591,7 @@
592592 */
593593 public static function getMainPage( $langCode, $prefix = null ) {
594594 # Take the "mainpage" msg in the given language
595 - $msg = wfMsgExt( 'mainpage', array( 'language' => $langCode ) );
 595+ $msg = wfMessage( 'mainpage' )->inLanguage( $langCode )->plain();
596596 $mainpage = $prefix !== null ? $prefix . '/' . $msg : $msg;
597597 return Title::newFromText( $mainpage );
598598 }
@@ -669,14 +669,14 @@
670670 }
671671 global $wgLogo;
672672 $prefixForPageTitle = str_replace( '/', '-', strtolower( $setLogo['prefix'] ) );
673 - $file = wfFindFile( wfMsgForContentNoTrans( 'Incubator-logo-' . $prefixForPageTitle ) );
 673+ $file = wfFindFile( wfMessage( 'Incubator-logo-' . $prefixForPageTitle )->inContentLanguage()->plain() );
674674 if( !$file ) {
675675 # if MediaWiki:Incubator-logo-wx-xx(x) doesn't exist,
676676 # try a general, default logo for that project
677677 global $wmincProjects;
678678 $project = $setLogo['project'];
679679 $projectForFile = str_replace( ' ', '-', strtolower( $wmincProjects[$project] ) );
680 - $imageobj = wfFindFile( wfMsg( 'wminc-logo-' . $projectForFile ) );
 680+ $imageobj = wfFindFile( wfMessage( 'wminc-logo-' . $projectForFile )->plain() );
681681 if( $imageobj ) {
682682 $thumb = $imageobj->transform( array( 'width' => 135, 'height' => 135 ) );
683683 $wgLogo = $thumb->getUrl();
@@ -748,7 +748,7 @@
749749 * @return true
750750 */
751751 public static function onSpecialSearchPowerBox( &$showSections, $term, $opts ) {
752 - $showSections['testwiki'] = Xml::label( wfMsg( 'wminc-testwiki' ), 'testwiki' ) . ' ' .
 752+ $showSections['testwiki'] = Xml::label( wfMessage( 'wminc-testwiki' )->text(), 'testwiki' ) . ' ' .
753753 Xml::input( 'testwiki', 20, self::displayPrefix(), array( 'id' => 'testwiki' ) );
754754 return true;
755755 }
Index: trunk/extensions/WikimediaIncubator/InfoPage.php
@@ -60,7 +60,7 @@
6161 */
6262 public function makeLogo( $project, $clickable = true, $width = 25, $height = '', $url = '', $args = array() ) {
6363 $projectForFile = preg_replace('/ /', '-', strtolower( $project ) );
64 - $imageobj = wfFindFile( wfMsg( 'wminc-logo-' . $projectForFile ) );
 64+ $imageobj = wfFindFile( wfMessage( 'wminc-logo-' . $projectForFile )->plain() );
6565 $useUrl = $url ? $url : IncubatorTest::getSubdomain( 'www', IncubatorTest::getProject( $project, false, true ) );
6666 if ( !$imageobj ) { # image not found
6767 if( !$clickable ) {
@@ -120,7 +120,7 @@
121121 */
122122 public function showWelcome() {
123123 return Html::rawElement( 'div', array( 'class' => 'wminc-infopage-welcome' ),
124 - wfMsgWikiHtml( 'wminc-infopage-welcome' ) );
 124+ wfMessage( 'wminc-infopage-welcome' )->parseAsBlock() );
125125 }
126126
127127 /**
@@ -146,21 +146,21 @@
147147 public function showMissingWiki() {
148148 $content = Html::rawElement( 'div',
149149 array( 'class' => 'wminc-infopage-status' ),
150 - wfMsgWikiHtml( 'wminc-infopage-missingwiki-text',
151 - $this->mProjectName, $this->mLangName )
 150+ wfMessage( 'wminc-infopage-missingwiki-text',
 151+ $this->mProjectName, $this->mLangName )->parseAsBlock()
152152 ) .
153153 Html::rawElement( 'ul', array( 'class' => 'wminc-infopage-options' ),
154154 Html::rawElement( 'li', null,
155 - wfMsgExt( $this->mIsSister ? 'wminc-infopage-option-startsister' : 'wminc-infopage-option-startwiki',
156 - array( 'parseinline' ), $this->mProjectName, $this->mPortal ) ) .
 155+ wfMessage( $this->mIsSister ? 'wminc-infopage-option-startsister' : 'wminc-infopage-option-startwiki',
 156+ $this->mProjectName, $this->mPortal )->parse() ) .
157157 Html::rawElement( 'li', null,
158 - wfMsgExt( 'wminc-infopage-option-languages-existing',
159 - array( 'parseinline' ), $this->mProjectName ) ) .
 158+ wfMessage( 'wminc-infopage-option-languages-existing',
 159+ $this->mProjectName )->parse() ) .
160160 Html::rawElement( 'li', null,
161 - wfMsgExt( 'wminc-infopage-option-sisterprojects-existing',
162 - array( 'parseinline' ) ) . $this->listOtherProjects() ) .
 161+ wfMessage( 'wminc-infopage-option-sisterprojects-existing' )->parse() .
 162+ $this->listOtherProjects() ) .
163163 Html::rawElement( 'li', null,
164 - wfMsgExt( 'wminc-infopage-option-multilingual', array( 'parseinline' ) ) .
 164+ wfMessage( 'wminc-infopage-option-multilingual' )->parse() .
165165 $this->listMultilingualProjects() )
166166 );
167167 return $this->StandardInfoPage( $this->showWelcome(), '', $content );
@@ -179,7 +179,7 @@
180180 if( $this->mThisLangData['type'] != 'invalid' ) {
181181 $gotoLink = Linker::link(
182182 IncubatorTest::getMainPage( $this->mLangCode, $this->mPrefix ),
183 - wfMsgNoTrans( 'wminc-infopage-enter' ) );
 183+ wfMessage( 'wminc-infopage-enter' )->plain() );
184184 $gotoMainPage = Html::rawElement( 'span',
185185 array( 'class' => 'wminc-infopage-entertest' ),
186186 $wgLang->getArrow() . ' ' . ( $this->mIsSister ? $portalLink : $gotoLink ) );
@@ -187,11 +187,11 @@
188188 $subdomain = IncubatorTest::getSubdomain( $this->mLangCode, $this->mProjectCode );
189189 $subdomainLink = IncubatorTest::makeExternalLinkText( $subdomain, true );
190190 $content = Html::rawElement( 'div', array( 'class' => 'wminc-infopage-status' ),
191 - wfMsgWikiHtml( 'wminc-infopage-status-' . $substatus, $subdomainLink, $portalLink ) );
 191+ wfMessage( 'wminc-infopage-status-' . $substatus )->rawParams( $subdomainLink, $portalLink )->parseAsBlock() );
192192 if( $this->mSubStatus != 'approved' && $this->mThisLangData['type'] != 'invalid' ) {
193193 $content .= Html::element( 'div',
194194 array( 'class' => 'wminc-infopage-contribute' ),
195 - wfMsg( 'wminc-infopage-contribute' ) );
 195+ wfMessage( 'wminc-infopage-contribute' )->plain() );
196196 }
197197 return $this->StandardInfoPage( '', $gotoMainPage, $content );
198198 }
@@ -212,11 +212,11 @@
213213 }
214214 $content = Html::rawElement( 'div',
215215 array( 'class' => 'wminc-infopage-status' ),
216 - wfMsgWikiHtml( 'wminc-infopage-status-' . $this->mSubStatus, $subdomainLink )
 216+ wfMessage( 'wminc-infopage-status-' . $this->mSubStatus )->rawParams( $subdomainLink )->parseAsBlock()
217217 ) . Html::rawElement( 'ul', array( 'class' => 'wminc-infopage-options' ),
218 - Html::rawElement( 'li', null, wfMsgWikiHtml( 'wminc-infopage-option-sisterprojects-other' ) .
 218+ Html::rawElement( 'li', null, wfMessage( 'wminc-infopage-option-sisterprojects-other' )->parseAsBlock() .
219219 $this->listOtherProjects() ) .
220 - Html::rawElement( 'li', null, wfMsgWikiHtml( 'wminc-infopage-option-multilingual' ) .
 220+ Html::rawElement( 'li', null, wfMessage( 'wminc-infopage-option-multilingual' )->parseAsBlock() .
221221 $this->listMultilingualProjects() )
222222 );
223223 return $this->StandardInfoPage( $this->showWelcome(), $gotoSubdomain, $content );
Index: trunk/extensions/WikimediaIncubator/TestWikiRC.php
@@ -51,9 +51,9 @@
5252 list( $projectvalue, $codevalue ) = self::getValues();
5353 $opts->consumeValue( 'rc-testwiki-project' );
5454 $opts->consumeValue( 'rc-testwiki-code' );
55 - $label = Xml::label( wfMsg( 'wminc-testwiki' ), 'rc-testwiki' );
 55+ $label = Xml::label( wfMessage( 'wminc-testwiki' )->text(), 'rc-testwiki' );
5656 $select = new XmlSelect( 'rc-testwiki-project', 'rc-testwiki-project', $projectvalue );
57 - $select->addOption( wfMsg( 'wminc-testwiki-none' ), 'none' );
 57+ $select->addOption( wfMessage( 'wminc-testwiki-none' )->text(), 'none' );
5858 foreach( $wmincProjects as $prefix => $name ) {
5959 $select->addOption( $name, $prefix );
6060 }

Comments

#Comment by Nikerabbit (talk | contribs)   09:11, 10 February 2012

Wouldn't wrapWikiMsg be better for these:

+$wgOut->addHTML( Xml::span( wfMessage( 'wminc-ip', $target )->text(), 'error' ) );
#Comment by SPQRobin (talk | contribs)   14:28, 11 February 2012

Yes, I know wrapWikiMsg, but I prefer it this way :)

Status & tagging log