r47636 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47635‎ | r47636 | r47637 >
Date:22:19, 21 February 2009
Author:ashley
Status:resolved (Comments)
Tags:
Comment:
WhatIsMyIP:
*spacing tweaks
*doxygen doc tweaks
*special page group
*add message for Special:ListGroupRights
*bump version number
Modified paths:
  • /trunk/extensions/WhatIsMyIP/WhatIsMyIP.alias.php (modified) (history)
  • /trunk/extensions/WhatIsMyIP/WhatIsMyIP.i18n.php (modified) (history)
  • /trunk/extensions/WhatIsMyIP/WhatIsMyIP.php (modified) (history)
  • /trunk/extensions/WhatIsMyIP/WhatIsMyIP_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WhatIsMyIP/WhatIsMyIP_body.php
@@ -1,27 +1,35 @@
22 <?php
3 -
4 -if (!defined('MEDIAWIKI')) {
 3+/**
 4+ * Main class for WhatIsMyIP
 5+ * @file
 6+ * @ingroup Extensions
 7+ */
 8+if ( !defined( 'MEDIAWIKI' ) ) {
59 echo "This is a MediaWiki extension named WhatIsMyIP.\n";
6 - exit(1);
 10+ exit( 1 );
711 }
812
913 class WhatIsMyIP extends SpecialPage {
10 - function __construct() {
11 - parent::__construct('WhatIsMyIP' /*class*/);
12 - }
1314
14 - function WhatIsMyIP(){
15 - SpecialPage::SpecialPage( 'WhatIsMyIP', 'whatismyip' );
 15+ /**
 16+ * Constructor
 17+ */
 18+ public function __construct() {
 19+ parent::__construct( 'WhatIsMyIP'/*class*/, 'whatismyip'/*restriction*/ );
1620 }
1721
18 - function execute(){
 22+ /**
 23+ * Show the special page
 24+ *
 25+ * @param $par Mixed: parameter passed to the page or null
 26+ */
 27+ public function execute( $par ){
1928 global $wgOut;
2029
21 - wfLoadExtensionMessages('WhatIsMyIP');
 30+ wfLoadExtensionMessages( 'WhatIsMyIP' );
2231
23 - $wgOut->setPageTitle(wfMsg('whatismyip'));
24 - // $wgOut->addWikiText( wfMsg('whatismyip-username'). " $user" );
 32+ $wgOut->setPageTitle( wfMsg( 'whatismyip' ) );
2533 $ip = wfGetIP();
26 - $wgOut->addWikiText( wfMsg('whatismyip-out'). " $ip" );
 34+ $wgOut->addWikiText( wfMsg( 'whatismyip-out' ). " $ip" );
2735 }
28 -}
 36+}
\ No newline at end of file
Index: trunk/extensions/WhatIsMyIP/WhatIsMyIP.i18n.php
@@ -2,6 +2,7 @@
33 /**
44 * Internationalization file for WhatIsMyIP extension.
55 *
 6+ * @file
67 * @ingroup Extensions
78 */
89
@@ -14,6 +15,8 @@
1516 'whatismyip' => 'What is my IP',
1617 'whatismyip-desc' => 'Shows current user\'s IP address on [[Special:WhatIsMyIP]]',
1718 'whatismyip-out' => 'Your IP:',
 19+ // For Special:ListGroupRights
 20+ 'right-whatismyip' => 'View their own IP address on [[Special:WhatIsMyIP]]',
1821 );
1922
2023 /** Message documentation (Message documentation)
@@ -188,6 +191,7 @@
189192 'whatismyip' => 'Mikä IP-osoitteeni on',
190193 'whatismyip-desc' => 'Näyttää käyttäjän nykyisen IP-osoitteen sivulla [[Special:WhatIsMyIP]]',
191194 'whatismyip-out' => 'IP-osoitteesi:',
 195+ 'right-whatismyip' => 'Katsoa oman IP-osoitteensa sivulla [[Special:WhatIsMyIP]]',
192196 );
193197
194198 /** French (Français)
Index: trunk/extensions/WhatIsMyIP/WhatIsMyIP.php
@@ -16,25 +16,30 @@
1717 * require_once("$IP/extensions/WhatIsMyIP/WhatIsMyIP.php");
1818 */
1919
20 -if (!defined('MEDIAWIKI')) {
 20+if ( !defined('MEDIAWIKI') ) {
2121 echo "This is a MediaWiki extension named WhatIsMyIP.\n";
2222 exit( 1 );
2323 }
 24+
 25+// Extension credits that show up on Special:Version
2426 $wgExtensionCredits['specialpage'][] = array(
2527 'name' => 'WhatIsMyIP',
26 - 'version' => '1.1',
 28+ 'version' => '1.2',
2729 'description' => 'Shows current user\'s IP address on [[Special:WhatIsMyIP]]',
2830 'author' => 'Łukasz Galezewski',
2931 'url' => 'http://www.mediawiki.org/wiki/Extension:WhatIsMyIP',
3032 'descriptionmsg' => 'whatismyip-desc'
3133 );
3234
33 -global $wgAvailableRights, $wgGroupPermissions;
 35+// New user right, given to everyone by default (so even anonymous users can access the special page)
3436 $wgAvailableRights[] = 'whatismyip';
3537 $wgGroupPermissions['*']['whatismyip'] = true;
3638
 39+// Set up the special page
3740 $dir = dirname(__FILE__) . '/';
3841 $wgExtensionMessagesFiles['WhatIsMyIP'] = $dir . 'WhatIsMyIP.i18n.php';
3942 $wgExtensionAliasesFiles['WhatIsMyIP'] = $dir . 'WhatIsMyIP.alias.php';
4043 $wgAutoloadClasses['WhatIsMyIP'] = $dir. 'WhatIsMyIP_body.php';
4144 $wgSpecialPages['WhatIsMyIP'] = 'WhatIsMyIP';
 45+// Special page group for MediaWiki 1.13+
 46+$wgSpecialPageGroups['WhatIsMyIP'] = 'users';
\ No newline at end of file
Index: trunk/extensions/WhatIsMyIP/WhatIsMyIP.alias.php
@@ -1,11 +1,14 @@
22 <?php
33 /**
4 - * Aliases for special pages
 4+ * Aliases for WhatIsMyIP extension.
55 *
 6+ * @file
 7+ * @ingroup Extensions
68 */
79
810 $aliases = array();
911
 12+/** English */
1013 $aliases['en'] = array(
1114 'WhatIsMyIP' => array( 'WhatIsMyIP' ),
1215 );

Comments

#Comment by Siebrand (talk | contribs)   22:29, 21 February 2009

Few remarks on i18n, please fix:

  • 'whatismyip-out': should use "IP address" as proper term
  • 'right-whatismyip': special page links should have a link description
  • 'right-whatismyip': "view their IP address" appears gramatically incorrect to me
#Comment by 😂 (talk | contribs)   18:44, 10 March 2009

Done in r48272

Status & tagging log