Index: branches/wmf-deployment/extensions/GeoLite/GeoLite_body.php |
— | — | @@ -6,31 +6,33 @@ |
7 | 7 | * @ingroup Extensions |
8 | 8 | */ |
9 | 9 | |
10 | | -// Special page GeoLite |
11 | | - |
12 | 10 | class SpecialGeoLite extends UnlistedSpecialPage { |
13 | 11 | |
14 | | - /* Functions */ |
15 | | - |
16 | | - public function __construct() { |
17 | | - // Initialize special page |
18 | | - parent::__construct( 'GeoLite' ); |
19 | | - } |
20 | | - |
| 12 | + // Initialize special page |
| 13 | + public function __construct() { |
| 14 | + parent::__construct( 'GeoLite' ); |
| 15 | + } |
| 16 | + |
21 | 17 | public function execute( $sub ) { |
22 | | - global $wgOut, $wgRequest, $wgLandingPageBase, $wgChaptersPageBase, $wgChapterLandingPages; |
23 | | - |
| 18 | + global $wgOut, $wgRequest; |
| 19 | + global $wgLandingPageBase, $wgChaptersPageBase, $wgChapterLandingPages, $wgLandingPageDefaultTarget; |
| 20 | + |
24 | 21 | $lang = ( preg_match( '/^[A-Za-z-]+$/', $wgRequest->getVal( 'lang' ) ) ) ? $wgRequest->getVal( 'lang' ) : 'en' ; |
25 | 22 | $utm_source = $wgRequest->getVal( 'utm_source' ); |
26 | 23 | $utm_medium = $wgRequest->getVal( 'utm_medium' ); |
27 | 24 | $utm_campaign = $wgRequest->getVal( 'utm_campaign' ); |
28 | 25 | $referrer = $wgRequest->getHeader( 'referer' ); |
29 | | - |
| 26 | + $target = $wgRequest->getVal( 'target', null ); |
| 27 | + if ( !$target ) { |
| 28 | + $target = $wgLandingPageDefaultTarget; |
| 29 | + } |
| 30 | + |
30 | 31 | $tracking = '?' . wfArrayToCGI( array( |
31 | 32 | 'utm_source' => "$utm_source", |
32 | 33 | 'utm_medium' => "$utm_medium", |
33 | | - 'utm_campaign' => "$utm_campaign", |
| 34 | + 'utm_campaign' => "$utm_campaign", |
34 | 35 | 'referrer' => "$referrer", |
| 36 | + 'target' => "$target", |
35 | 37 | ) ); |
36 | 38 | |
37 | 39 | $ip = ( $wgRequest->getVal( 'ip') ) ? $wgRequest->getVal( 'ip' ) : wfGetIP(); |
— | — | @@ -38,14 +40,12 @@ |
39 | 41 | if ( IP::isValid( $ip ) ) { |
40 | 42 | $country = geoip_country_code_by_name( $ip ); |
41 | 43 | if ( is_string ( $country ) && array_key_exists( $country, $wgChapterLandingPages ) ) { |
42 | | - $wgOut->redirect( $wgChaptersPageBase . "/" . $wgChapterLandingPages[ $country ] . $tracking ); |
43 | | - } else { // Valid IP but no chapter page |
44 | | - $wgOut->redirect( $wgLandingPageBase . "/" . $lang . $tracking ); |
| 44 | + $wgOut->redirect( $wgChaptersPageBase . '/' . $wgChapterLandingPages[$country] . $tracking ); |
| 45 | + return; |
45 | 46 | } |
46 | | - } else { // No ip found so do the best we can |
47 | | - $wgOut->redirect( $wgLandingPageBase . "/" . $lang . $tracking ); |
48 | 47 | } |
| 48 | + // No valid IP or chapter page - let's just go for the general one |
| 49 | + $wgOut->redirect( $wgLandingPageBase . $target . '/' . $lang . $tracking ); |
49 | 50 | } |
50 | 51 | |
51 | | -} |
52 | | - |
| 52 | +} |
\ No newline at end of file |
Index: branches/wmf-deployment/extensions/GeoLite/GeoLite.php |
— | — | @@ -9,7 +9,9 @@ |
10 | 10 | exit( 1 ); |
11 | 11 | } |
12 | 12 | |
13 | | -$wgLandingPageBase = 'http://wikimediafoundation.org/wiki/Support_Wikipedia'; |
| 13 | +$wgChapterLandingPages = array(); |
| 14 | +$wgLandingPageBase = 'http://wikimediafoundation.org/wiki/'; |
| 15 | +$wgLandingPageDefaultTarget = 'Support_Wikipedia'; |
14 | 16 | $wgChaptersPageBase = 'http://wikimediafoundation.org/wiki/Global_Support'; |
15 | 17 | |
16 | 18 | //wgChapterLandingPages set which landing pages we know about |
Property changes on: branches/wmf-deployment/extensions/GeoLite |
___________________________________________________________________ |
Name: svn:mergeinfo |
17 | 19 | - /branches/REL1_15/phase3/extensions/GeoLite:51646 |
/trunk/extensions/ContributionTracking:58964 |
/trunk/extensions/GeoLite:56207,56209,56296,56333,56355,58964 |
/trunk/phase3/extensions/GeoLite:56213,56215-56216,56218,56325,56334-56336,56338,56340,56343,56345,56347,56350,57154-57447 |
18 | 20 | + /branches/REL1_15/phase3/extensions/GeoLite:51646 |
/trunk/extensions/ContributionTracking:58964 |
/trunk/extensions/GeoLite:56207,56209,56296,56333,56355,58964,59030 |
/trunk/phase3/extensions/GeoLite:56213,56215-56216,56218,56325,56334-56336,56338,56340,56343,56345,56347,56350,57154-57447 |