Index: trunk/extensions/GeoLite/GeoLite_body.php |
— | — | @@ -6,17 +6,13 @@ |
7 | 7 | * @ingroup Extensions |
8 | 8 | */ |
9 | 9 | |
10 | | -// Special page GeoLite |
11 | | - |
12 | 10 | class SpecialGeoLite extends UnlistedSpecialPage { |
13 | 11 | |
14 | | - /* Functions */ |
| 12 | + // Initialize special page |
| 13 | + public function __construct() { |
| 14 | + parent::__construct( 'GeoLite' ); |
| 15 | + } |
15 | 16 | |
16 | | - public function __construct() { |
17 | | - // Initialize special page |
18 | | - parent::__construct( 'GeoLite' ); |
19 | | - } |
20 | | - |
21 | 17 | public function execute( $sub ) { |
22 | 18 | global $wgOut, $wgRequest, $wgLandingPageBase, $wgChaptersPageBase, $wgChapterLandingPages; |
23 | 19 | |
— | — | @@ -29,23 +25,24 @@ |
30 | 26 | $tracking = '?' . wfArrayToCGI( array( |
31 | 27 | 'utm_source' => "$utm_source", |
32 | 28 | 'utm_medium' => "$utm_medium", |
33 | | - 'utm_campaign' => "$utm_campaign", |
| 29 | + 'utm_campaign' => "$utm_campaign", |
34 | 30 | 'referrer' => "$referrer", |
35 | 31 | ) ); |
36 | | - |
| 32 | + |
37 | 33 | $ip = ( $wgRequest->getVal( 'ip') ) ? $wgRequest->getVal( 'ip' ) : wfGetIP(); |
38 | | - |
| 34 | + |
39 | 35 | if ( IP::isValid( $ip ) ) { |
40 | 36 | $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 ); |
43 | 41 | } else { // Valid IP but no chapter page |
44 | | - $wgOut->redirect( $wgLandingPageBase . "/" . $lang . $tracking ); |
| 42 | + $wgOut->redirect( $wgLandingPageBase . '/' . $lang . $tracking ); |
45 | 43 | } |
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 ); |
48 | 46 | } |
49 | 47 | } |
50 | 48 | |
51 | | -} |
52 | | - |
| 49 | +} |
\ No newline at end of file |
Index: trunk/extensions/GeoLite/GeoLite.i18n.php |
— | — | @@ -13,7 +13,7 @@ |
14 | 14 | */ |
15 | 15 | $messages['en'] = array( |
16 | 16 | 'geolite-desc' => 'Lightweight GeoIp Redirection', |
17 | | - 'geolite' => 'GeoLite', |
| 17 | + 'geolite' => 'GeoLite', |
18 | 18 | ); |
19 | 19 | |
20 | 20 | /** Message documentation (Message documentation) |
Index: trunk/extensions/GeoLite/GeoLite.php |
— | — | @@ -2,29 +2,33 @@ |
3 | 3 | |
4 | 4 | # Alert the user that this is not a valid entry point to MediaWiki if they try to access the special pages file directly. |
5 | 5 | if ( !defined( 'MEDIAWIKI' ) ) { |
6 | | - echo <<<EOT |
| 6 | + echo <<<EOT |
7 | 7 | To install my extension, put the following line in LocalSettings.php: |
8 | 8 | require_once( "\$IP/extensions/GeoLite/GeoLite.php" ); |
9 | 9 | EOT; |
10 | | - exit( 1 ); |
| 10 | + exit( 1 ); |
11 | 11 | } |
12 | 12 | |
13 | 13 | $wgLandingPageBase = 'http://wikimediafoundation.org/wiki/Support_Wikipedia'; |
14 | 14 | $wgChaptersPageBase = 'http://wikimediafoundation.org/wiki/Global_Support'; |
15 | 15 | |
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 | +); |
22 | 24 | |
| 25 | +// Extension credits that will show up on Special:Version |
23 | 26 | $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', |
29 | 33 | ); |
30 | 34 | |
31 | 35 | $dir = dirname( __FILE__ ) . '/'; |
— | — | @@ -32,5 +36,4 @@ |
33 | 37 | $wgAutoloadClasses['SpecialGeoLite'] = $dir . 'GeoLite_body.php'; |
34 | 38 | $wgExtensionMessagesFiles['GeoLite'] = $dir . 'GeoLite.i18n.php'; |
35 | 39 | $wgSpecialPages['GeoLite'] = 'SpecialGeoLite'; |
36 | | -$wgSpecialPageGroups['GeoLite'] = 'contribution'; |
37 | | - |
| 40 | +$wgSpecialPageGroups['GeoLite'] = 'contribution'; |
\ No newline at end of file |