r95586 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95585‎ | r95586 | r95587 >
Date:23:47, 26 August 2011
Author:robin
Status:ok (Comments)
Tags:
Comment:
(bug 30566) Show error message if an IP is given on Special:ViewUserLang
Another slight change: use if() { return ..; } instead of if() { .. } else { .. }
Modified paths:
  • /trunk/extensions/WikimediaIncubator/SpecialViewUserLang.php (modified) (history)
  • /trunk/extensions/WikimediaIncubator/WikimediaIncubator.i18n.php (modified) (history)
  • /trunk/extensions/WikimediaIncubator/WikimediaIncubator.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WikimediaIncubator/WikimediaIncubator.i18n.php
@@ -42,6 +42,7 @@
4343 'wminc-viewuserlang-user' => 'Username:',
4444 'wminc-viewuserlang-go' => 'Go',
4545 'wminc-userdoesnotexist' => 'The user "$1" does not exist.',
 46+ 'wminc-ip' => '"$1" is an IP address.',
4647
4748 # User groups
4849 'right-viewuserlang' => 'View [[Special:ViewUserLang|user language and test wiki]]',
Index: trunk/extensions/WikimediaIncubator/WikimediaIncubator.php
@@ -14,7 +14,7 @@
1515 'path' => __FILE__,
1616 'name' => 'Wikimedia Incubator',
1717 'author' => 'SPQRobin',
18 - 'version' => '4.3',
 18+ 'version' => '4.3.1',
1919 'url' => 'http://www.mediawiki.org/wiki/Extension:WikimediaIncubator',
2020 'descriptionmsg' => 'wminc-desc',
2121 );
Index: trunk/extensions/WikimediaIncubator/SpecialViewUserLang.php
@@ -68,35 +68,38 @@
6969 */
7070 function showInfo( $target ) {
7171 global $wgOut, $wmincPref, $wmincProjectSite;
 72+ if( User::isIP( $target ) ) {
 73+ # show error if it is an IP address
 74+ return $wgOut->addHTML( Xml::span( wfMsg( 'wminc-ip', $target ), 'error' ) );
 75+ }
7276 $user = User::newFromName( $target );
7377 $name = $user->getName();
7478 $id = $user->getId();
7579 $langNames = Language::getLanguageNames();
7680 $linker = class_exists( 'DummyLinker' ) ? new DummyLinker : new Linker;
7781 if ( $user == null || $id == 0 ) {
78 - // show error if a user with that name does not exist
79 - $wgOut->addHTML( Xml::span( wfMsg( 'wminc-userdoesnotexist', $target ), 'error' ) );
 82+ # show error if a user with that name does not exist
 83+ return $wgOut->addHTML( Xml::span( wfMsg( 'wminc-userdoesnotexist', $target ), 'error' ) );
 84+ }
 85+ $userproject = $user->getOption( $wmincPref . '-project' );
 86+ $userproject = ( $userproject ? $userproject : 'none' );
 87+ $usercode = $user->getOption( $wmincPref . '-code' );
 88+ $prefix = IncubatorTest::displayPrefix( $userproject, $usercode );
 89+ if ( IncubatorTest::isContentProject( $userproject ) ) {
 90+ $testwiki = $linker->link( Title::newFromText( $prefix ) );
 91+ } elseif ( $prefix == $wmincProjectSite['short'] ) {
 92+ $testwiki = htmlspecialchars( $wmincProjectSite['name'] );
8093 } else {
81 - $userproject = $user->getOption( $wmincPref . '-project' );
82 - $userproject = ( $userproject ? $userproject : 'none' );
83 - $usercode = $user->getOption( $wmincPref . '-code' );
84 - $prefix = IncubatorTest::displayPrefix( $userproject, $usercode );
85 - if ( IncubatorTest::isContentProject( $userproject ) ) {
86 - $testwiki = $linker->link( Title::newFromText( $prefix ) );
87 - } elseif ( $prefix == $wmincProjectSite['short'] ) {
88 - $testwiki = htmlspecialchars( $wmincProjectSite['name'] );
89 - } else {
90 - $testwiki = wfMsgHtml( 'wminc-testwiki-none' );
91 - }
92 - $wgOut->addHtml(
93 - Xml::openElement( 'ul' ) .
94 - '<li>' . wfMsgHtml( 'username' ) . ' ' .
95 - $linker->userLink( $id, $name ) . $linker->userToolLinks( $id, $name, true ) . '</li>' .
96 - '<li>' . wfMsgHtml( 'loginlanguagelabel', $langNames[$user->getOption( 'language' )] .
97 - ' (' . $user->getOption( 'language' ) . ')' ) . '</li>' .
98 - '<li>' . wfMsgHtml( 'wminc-testwiki' ) . ' ' . $testwiki . '</li>' .
99 - Xml::closeElement( 'ul' )
100 - );
 94+ $testwiki = wfMsgHtml( 'wminc-testwiki-none' );
10195 }
 96+ $wgOut->addHtml(
 97+ Xml::openElement( 'ul' ) .
 98+ '<li>' . wfMsgHtml( 'username' ) . ' ' .
 99+ $linker->userLink( $id, $name ) . $linker->userToolLinks( $id, $name, true ) . '</li>' .
 100+ '<li>' . wfMsgHtml( 'loginlanguagelabel', $langNames[$user->getOption( 'language' )] .
 101+ ' (' . $user->getOption( 'language' ) . ')' ) . '</li>' .
 102+ '<li>' . wfMsgHtml( 'wminc-testwiki' ) . ' ' . $testwiki . '</li>' .
 103+ Xml::closeElement( 'ul' )
 104+ );
102105 }
103106 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r958911.17wmf1: MFT r95586, r95605catrope17:46, 31 August 2011

Comments

#Comment by SPQRobin (talk | contribs)   23:52, 26 August 2011

Note: the diff looks like I changed a lot in showInfo() but I only changed if( .. ) { .. } else { .. } to if( .. ) { return ..; } .. and changed indenting accordingly.

#Comment by Nikerabbit (talk | contribs)   07:05, 27 August 2011

$wgOut->wrapWikiMsg?

+return $wgOut->addHTML( Xml::span( wfMsg( 'wminc-ip', $target ), 'error' ) );
#Comment by SPQRobin (talk | contribs)   14:39, 27 August 2011

I know, but I prefer to do it this way :-)

Status & tagging log