r81598 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81597‎ | r81598 | r81599 >
Date:16:34, 6 February 2011
Author:ialex
Status:ok
Tags:
Comment:
Use OutputPage::wrapWikiMsg(), much easier
Modified paths:
  • /trunk/extensions/Renameuser/Renameuser_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Renameuser/Renameuser_body.php
@@ -177,24 +177,18 @@
178178 # Let user read warnings
179179 return;
180180 } elseif ( !$wgRequest->wasPosted() || !$wgUser->matchEditToken( $wgRequest->getVal( 'token' ) ) ) {
181 - $wgOut->addWikiText( "<div class=\"errorbox\">" . wfMsg( 'renameuser-error-request' ) . "</div>" );
 181+ $wgOut->wrapWikiMsg( "<div class=\"errorbox\">$1</div>", 'renameuser-error-request' );
182182 return;
183183 } elseif ( !is_object( $oldusername ) ) {
184 - $wgOut->addWikiText(
185 - "<div class=\"errorbox\">"
186 - . wfMsg( 'renameusererrorinvalid', $wgRequest->getText( 'oldusername' ) )
187 - . "</div>"
188 - );
 184+ $wgOut->wrapWikiMsg( "<div class=\"errorbox\">$1</div>",
 185+ array( 'renameusererrorinvalid', $wgRequest->getText( 'oldusername' ) ) );
189186 return;
190187 } elseif ( !is_object( $newusername ) ) {
191 - $wgOut->addWikiText(
192 - "<div class=\"errorbox\">"
193 - . wfMsg( 'renameusererrorinvalid', $wgRequest->getText( 'newusername' ) )
194 - . "</div>"
195 - );
 188+ $wgOut->wrapWikiMsg( "<div class=\"errorbox\">$1</div>",
 189+ array( 'renameusererrorinvalid', $wgRequest->getText( 'newusername' ) ) );
196190 return;
197191 } elseif ( $oldusername->getText() == $newusername->getText() ) {
198 - $wgOut->addWikiText( "<div class=\"errorbox\">" . wfMsg( 'renameuser-error-same-user' ) . "</div>" );
 192+ $wgOut->wrapWikiMsg( "<div class=\"errorbox\">$1</div>", 'renameuser-error-same-user' );
199193 return;
200194 }
201195
@@ -204,13 +198,13 @@
205199
206200 // It won't be an object if for instance "|" is supplied as a value
207201 if ( !is_object( $olduser ) ) {
208 - $wgOut->addWikiText( "<div class=\"errorbox\">" . wfMsg( 'renameusererrorinvalid',
209 - $oldusername->getText() ) . "</div>" );
 202+ $wgOut->wrapWikiMsg( "<div class=\"errorbox\">$1</div>",
 203+ array( 'renameusererrorinvalid', $oldusername->getText() ) );
210204 return;
211205 }
212206 if ( !is_object( $newuser ) || !User::isCreatableName( $newuser->getName() ) ) {
213 - $wgOut->addWikiText( "<div class=\"errorbox\">" . wfMsg( 'renameusererrorinvalid',
214 - $newusername->getText() ) . "</div>" );
 207+ $wgOut->wrapWikiMsg( "<div class=\"errorbox\">$1</div>",
 208+ array( 'renameusererrorinvalid', $newusername->getText() ) );
215209 return;
216210 }
217211
@@ -237,14 +231,14 @@
238232 }
239233
240234 if ( $uid == 0 ) {
241 - $wgOut->addWikiText( "<div class=\"errorbox\">" . wfMsg( 'renameusererrordoesnotexist' ,
242 - $oldusername->getText() ) . "</div>" );
 235+ $wgOut->wrapWikiMsg( "<div class=\"errorbox\">$1</div>",
 236+ array( 'renameusererrordoesnotexist', $oldusername->getText() ) );
243237 return;
244238 }
245239
246240 if ( $newuser->idForName() != 0 ) {
247 - $wgOut->addWikiText( "<div class=\"errorbox\">" . wfMsg( 'renameusererrorexists',
248 - $newusername->getText() ) . "</div>" );
 241+ $wgOut->wrapWikiMsg( "<div class=\"errorbox\">$1</div>",
 242+ array( 'renameusererrorexists', $newusername->getText() ) );
249243 return;
250244 }
251245
@@ -254,13 +248,11 @@
255249 // Check edit count
256250 if ( !$wgUser->isAllowed( 'siteadmin' ) ) {
257251 if ( RENAMEUSER_CONTRIBLIMIT != 0 && $contribs > RENAMEUSER_CONTRIBLIMIT ) {
258 - $wgOut->addWikiText( "<div class=\"errorbox\">" .
259 - wfMsg( 'renameusererrortoomany',
260 - $oldusername->getText(),
 252+ $wgOut->wrapWikiMsg( "<div class=\"errorbox\">$1</div>",
 253+ array( 'renameusererrortoomany', $oldusername->getText(),
261254 $wgLang->formatNum( $contribs ),
262255 $wgLang->formatNum( RENAMEUSER_CONTRIBLIMIT )
263 - )
264 - . "</div>" );
 256+ ) );
265257 return;
266258 }
267259 }
@@ -337,8 +329,8 @@
338330 }
339331
340332 // Output success message stuff :)
341 - $wgOut->addWikiText( "<div class=\"successbox\">" . wfMsg( 'renameusersuccess', $oldusername->getText(),
342 - $newusername->getText() ) . "</div><br style=\"clear:both\" />" );
 333+ $wgOut->wrapWikiMsg( "<div class=\"successbox\">$1</div><br style=\"clear:both\" />",
 334+ array( 'renameusersuccess', $oldusername->getText(), $newusername->getText() ) );
343335 }
344336
345337 function showLogExtract( $username, $type, &$out ) {

Status & tagging log