r58875 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r58874‎ | r58875 | r58876 >
Date:21:08, 10 November 2009
Author:ashley
Status:ok
Tags:
Comment:
GeoLite:
*add version number to extension credits
*use tabs for indentation instead of spaces
*break a long line
Modified paths:
  • /trunk/extensions/GeoLite/GeoLite.i18n.php (modified) (history)
  • /trunk/extensions/GeoLite/GeoLite.php (modified) (history)
  • /trunk/extensions/GeoLite/GeoLite_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/GeoLite/GeoLite_body.php
@@ -6,17 +6,13 @@
77 * @ingroup Extensions
88 */
99
10 -// Special page GeoLite
11 -
1210 class SpecialGeoLite extends UnlistedSpecialPage {
1311
14 - /* Functions */
 12+ // Initialize special page
 13+ public function __construct() {
 14+ parent::__construct( 'GeoLite' );
 15+ }
1516
16 - public function __construct() {
17 - // Initialize special page
18 - parent::__construct( 'GeoLite' );
19 - }
20 -
2117 public function execute( $sub ) {
2218 global $wgOut, $wgRequest, $wgLandingPageBase, $wgChaptersPageBase, $wgChapterLandingPages;
2319
@@ -29,23 +25,24 @@
3026 $tracking = '?' . wfArrayToCGI( array(
3127 'utm_source' => "$utm_source",
3228 'utm_medium' => "$utm_medium",
33 - 'utm_campaign' => "$utm_campaign",
 29+ 'utm_campaign' => "$utm_campaign",
3430 'referrer' => "$referrer",
3531 ) );
36 -
 32+
3733 $ip = ( $wgRequest->getVal( 'ip') ) ? $wgRequest->getVal( 'ip' ) : wfGetIP();
38 -
 34+
3935 if ( IP::isValid( $ip ) ) {
4036 $country = geoip_country_code_by_name( $ip );
41 - if ( is_string ( $country ) && array_key_exists( $country, $wgChapterLandingPages ) ) {
42 - $wgOut->redirect( $wgChaptersPageBase . "/" . $wgChapterLandingPages[ $country ] . $tracking );
 37+ if ( is_string ( $country ) &&
 38+ array_key_exists( $country, $wgChapterLandingPages )
 39+ ) {
 40+ $wgOut->redirect( $wgChaptersPageBase . '/' . $wgChapterLandingPages[$country] . $tracking );
4341 } else { // Valid IP but no chapter page
44 - $wgOut->redirect( $wgLandingPageBase . "/" . $lang . $tracking );
 42+ $wgOut->redirect( $wgLandingPageBase . '/' . $lang . $tracking );
4543 }
46 - } else { // No ip found so do the best we can
47 - $wgOut->redirect( $wgLandingPageBase . "/" . $lang . $tracking );
 44+ } else { // No IP found so do the best we can
 45+ $wgOut->redirect( $wgLandingPageBase . '/' . $lang . $tracking );
4846 }
4947 }
5048
51 -}
52 -
 49+}
\ No newline at end of file
Index: trunk/extensions/GeoLite/GeoLite.i18n.php
@@ -13,7 +13,7 @@
1414 */
1515 $messages['en'] = array(
1616 'geolite-desc' => 'Lightweight GeoIp Redirection',
17 - 'geolite' => 'GeoLite',
 17+ 'geolite' => 'GeoLite',
1818 );
1919
2020 /** Message documentation (Message documentation)
Index: trunk/extensions/GeoLite/GeoLite.php
@@ -2,29 +2,33 @@
33
44 # Alert the user that this is not a valid entry point to MediaWiki if they try to access the special pages file directly.
55 if ( !defined( 'MEDIAWIKI' ) ) {
6 - echo <<<EOT
 6+ echo <<<EOT
77 To install my extension, put the following line in LocalSettings.php:
88 require_once( "\$IP/extensions/GeoLite/GeoLite.php" );
99 EOT;
10 - exit( 1 );
 10+ exit( 1 );
1111 }
1212
1313 $wgLandingPageBase = 'http://wikimediafoundation.org/wiki/Support_Wikipedia';
1414 $wgChaptersPageBase = 'http://wikimediafoundation.org/wiki/Global_Support';
1515
16 -$wgChapterLandingPages = array( 'HK' => 'hk',
17 - 'DE' => 'de',
18 - 'UK' => 'uk',
19 - 'FR' => 'fr',
20 - 'CH' => 'ch',
21 - ); # Which Chapters actually have landing pages
 16+# Which Chapters actually have landing pages
 17+$wgChapterLandingPages = array(
 18+ 'HK' => 'hk',
 19+ 'DE' => 'de',
 20+ 'UK' => 'uk',
 21+ 'FR' => 'fr',
 22+ 'CH' => 'ch',
 23+);
2224
 25+// Extension credits that will show up on Special:Version
2326 $wgExtensionCredits['specialpage'][] = array(
24 - 'path' => __FILE__,
25 - 'name' => 'GeoLite',
26 - 'url' => 'http://www.mediawiki.org/wiki/Extension:GeoLite',
27 - 'author' => array( 'Tomasz Finc' ),
28 - 'descriptionmsg' => 'geolite-desc',
 27+ 'path' => __FILE__,
 28+ 'name' => 'GeoLite',
 29+ 'version' => '1.0',
 30+ 'url' => 'http://www.mediawiki.org/wiki/Extension:GeoLite',
 31+ 'author' => 'Tomasz Finc',
 32+ 'descriptionmsg' => 'geolite-desc',
2933 );
3034
3135 $dir = dirname( __FILE__ ) . '/';
@@ -32,5 +36,4 @@
3337 $wgAutoloadClasses['SpecialGeoLite'] = $dir . 'GeoLite_body.php';
3438 $wgExtensionMessagesFiles['GeoLite'] = $dir . 'GeoLite.i18n.php';
3539 $wgSpecialPages['GeoLite'] = 'SpecialGeoLite';
36 -$wgSpecialPageGroups['GeoLite'] = 'contribution';
37 -
 40+$wgSpecialPageGroups['GeoLite'] = 'contribution';
\ No newline at end of file

Status & tagging log