r103829 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103828‎ | r103829 | r103830 >
Date:19:49, 21 November 2011
Author:kaldari
Status:ok
Tags:
Comment:
adding geoIP lookup to FundraiserLandingPage
Modified paths:
  • /trunk/extensions/FundraiserLandingPage/FundraiserLandingPage.body.php (modified) (history)
  • /trunk/extensions/FundraiserLandingPage/FundraiserLandingPage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FundraiserLandingPage/FundraiserLandingPage.php
@@ -40,7 +40,8 @@
4141 $wgFundraiserLPDefaults = array(
4242 'template' => 'Lp-wrapper',
4343 'appeal' => 'Appeal-default',
44 - 'form' => 'Form-default'
 44+ 'form' => 'Form-default',
 45+ 'country' => 'XX' // per Charles Barr
4546 );
4647
4748 // Adding configurrable variable for caching time
Index: trunk/extensions/FundraiserLandingPage/FundraiserLandingPage.body.php
@@ -29,14 +29,29 @@
3030 $template = $this->make_safe( $request->getText( 'template', $wgFundraiserLPDefaults[ 'template' ] ) );
3131 $appeal = $this->make_safe( $request->getText( 'appeal', $wgFundraiserLPDefaults[ 'appeal' ] ) );
3232 $form = $this->make_safe( $request->getText( 'form', $wgFundraiserLPDefaults[ 'form' ] ) );
 33+ $country = $request->getVal( 'country' );
 34+ // If no country was passed do a GeoIP lookup
 35+ if ( !$country ) {
 36+ if ( function_exists( 'geoip_country_code_by_name' ) ) {
 37+ $ip = wfGetIP();
 38+ if ( IP::isValid( $ip ) ) {
 39+ $country = geoip_country_code_by_name( $ip );
 40+ }
 41+ }
 42+ }
 43+ // If country still isn't set, set it to the default
 44+ if ( !$country ) {
 45+ $country = $wgFundraiserLPDefaults[ 'country' ];
 46+ }
 47+ $country = $this->make_safe( $country );
3348
3449 # begin generating the template call
35 - $output .= "{{ $template\n| appeal = $appeal\n| form = $form\n";
 50+ $output .= "{{ $template\n| appeal = $appeal\n| form = $form\n| country = $country\n";
3651
3752 # add any parameters passed in the querystring
3853 foreach ( $request->getValues() as $k_unsafe => $v_unsafe ) {
3954 # skip the required variables
40 - if ( $k_unsafe == "template" || $k_unsafe == "appeal" || $k_unsafe == "form" ) {
 55+ if ( $k_unsafe == "template" || $k_unsafe == "appeal" || $k_unsafe == "form" || $k_unsafe == "country" ) {
4156 continue;
4257 }
4358 # get the variables name and value

Follow-up revisions

RevisionCommit summaryAuthorDate
r103844MFT r103829awjrichards22:17, 21 November 2011

Status & tagging log