r59034 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59033‎ | r59034 | r59035 >
Date:22:01, 13 November 2009
Author:tomasz
Status:ok
Tags:
Comment:
picking up r59030
Modified paths:
  • /branches/wmf-deployment/extensions/GeoLite (modified) (history)
  • /branches/wmf-deployment/extensions/GeoLite/GeoLite.php (modified) (history)
  • /branches/wmf-deployment/extensions/GeoLite/GeoLite_body.php (modified) (history)

Diff [purge]

Index: branches/wmf-deployment/extensions/GeoLite/GeoLite_body.php
@@ -6,31 +6,33 @@
77 * @ingroup Extensions
88 */
99
10 -// Special page GeoLite
11 -
1210 class SpecialGeoLite extends UnlistedSpecialPage {
1311
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+
2117 public function execute( $sub ) {
22 - global $wgOut, $wgRequest, $wgLandingPageBase, $wgChaptersPageBase, $wgChapterLandingPages;
23 -
 18+ global $wgOut, $wgRequest;
 19+ global $wgLandingPageBase, $wgChaptersPageBase, $wgChapterLandingPages, $wgLandingPageDefaultTarget;
 20+
2421 $lang = ( preg_match( '/^[A-Za-z-]+$/', $wgRequest->getVal( 'lang' ) ) ) ? $wgRequest->getVal( 'lang' ) : 'en' ;
2522 $utm_source = $wgRequest->getVal( 'utm_source' );
2623 $utm_medium = $wgRequest->getVal( 'utm_medium' );
2724 $utm_campaign = $wgRequest->getVal( 'utm_campaign' );
2825 $referrer = $wgRequest->getHeader( 'referer' );
29 -
 26+ $target = $wgRequest->getVal( 'target', null );
 27+ if ( !$target ) {
 28+ $target = $wgLandingPageDefaultTarget;
 29+ }
 30+
3031 $tracking = '?' . wfArrayToCGI( array(
3132 'utm_source' => "$utm_source",
3233 'utm_medium' => "$utm_medium",
33 - 'utm_campaign' => "$utm_campaign",
 34+ 'utm_campaign' => "$utm_campaign",
3435 'referrer' => "$referrer",
 36+ 'target' => "$target",
3537 ) );
3638
3739 $ip = ( $wgRequest->getVal( 'ip') ) ? $wgRequest->getVal( 'ip' ) : wfGetIP();
@@ -38,14 +40,12 @@
3941 if ( IP::isValid( $ip ) ) {
4042 $country = geoip_country_code_by_name( $ip );
4143 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;
4546 }
46 - } else { // No ip found so do the best we can
47 - $wgOut->redirect( $wgLandingPageBase . "/" . $lang . $tracking );
4847 }
 48+ // No valid IP or chapter page - let's just go for the general one
 49+ $wgOut->redirect( $wgLandingPageBase . $target . '/' . $lang . $tracking );
4950 }
5051
51 -}
52 -
 52+}
\ No newline at end of file
Index: branches/wmf-deployment/extensions/GeoLite/GeoLite.php
@@ -9,7 +9,9 @@
1010 exit( 1 );
1111 }
1212
13 -$wgLandingPageBase = 'http://wikimediafoundation.org/wiki/Support_Wikipedia';
 13+$wgChapterLandingPages = array();
 14+$wgLandingPageBase = 'http://wikimediafoundation.org/wiki/';
 15+$wgLandingPageDefaultTarget = 'Support_Wikipedia';
1416 $wgChaptersPageBase = 'http://wikimediafoundation.org/wiki/Global_Support';
1517
1618 //wgChapterLandingPages set which landing pages we know about
Property changes on: branches/wmf-deployment/extensions/GeoLite
___________________________________________________________________
Name: svn:mergeinfo
1719 - /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
1820 + /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

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r59030Added support for target parameter.tparscal21:37, 13 November 2009

Status & tagging log