Index: trunk/extensions/FundraiserLandingPage/FundraiserLandingPage.php |
— | — | @@ -40,7 +40,8 @@ |
41 | 41 | $wgFundraiserLPDefaults = array( |
42 | 42 | 'template' => 'Lp-wrapper', |
43 | 43 | 'appeal' => 'Appeal-default', |
44 | | - 'form' => 'Form-default' |
| 44 | + 'form' => 'Form-default', |
| 45 | + 'country' => 'XX' // per Charles Barr |
45 | 46 | ); |
46 | 47 | |
47 | 48 | // Adding configurrable variable for caching time |
Index: trunk/extensions/FundraiserLandingPage/FundraiserLandingPage.body.php |
— | — | @@ -29,14 +29,29 @@ |
30 | 30 | $template = $this->make_safe( $request->getText( 'template', $wgFundraiserLPDefaults[ 'template' ] ) ); |
31 | 31 | $appeal = $this->make_safe( $request->getText( 'appeal', $wgFundraiserLPDefaults[ 'appeal' ] ) ); |
32 | 32 | $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 ); |
33 | 48 | |
34 | 49 | # 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"; |
36 | 51 | |
37 | 52 | # add any parameters passed in the querystring |
38 | 53 | foreach ( $request->getValues() as $k_unsafe => $v_unsafe ) { |
39 | 54 | # 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" ) { |
41 | 56 | continue; |
42 | 57 | } |
43 | 58 | # get the variables name and value |