r104942 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104941‎ | r104942 | r104943 >
Date:02:09, 2 December 2011
Author:kaldari
Status:ok
Tags:
Comment:
new defaults and better template construction
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,9 +40,11 @@
4141 * or not they are passed through the querystring.
4242 */
4343 $wgFundraiserLPDefaults = array(
44 - 'template' => 'Lp-wrapper',
 44+ 'template' => 'Lp-layout-default',
4545 'appeal' => 'Appeal-default',
46 - 'form' => 'Form-default',
 46+ 'appeal-template' => 'Appeal-template-default',
 47+ 'form-template' => 'Form-template-default',
 48+ 'form-countryspecific' => 'Form-countryspecific-control',
4749 'country' => 'XX' // per Charles Barr
4850 );
4951
Index: trunk/extensions/FundraiserLandingPage/FundraiserLandingPage.body.php
@@ -23,11 +23,27 @@
2424
2525 # clear output variable to be safe
2626 $output = '';
 27+
 28+ # begin generating the template call
 29+ $template = $this->make_safe( $wgRequest->getText( 'template', $wgFundraiserLPDefaults[ 'template' ] ) );
 30+ $output .= "{{ $template\n";
 31+
 32+ # get the required variables (except template and country) to use for the landing page
 33+ $requiredParams = array(
 34+ 'appeal',
 35+ 'appeal-template',
 36+ 'form-template',
 37+ 'form-countryspecific'
 38+ );
 39+ foreach( $requiredParams as $requiredParam ) {
 40+ $param = $this->make_safe(
 41+ $wgRequest->getText( $requiredParam, $wgFundraiserLPDefaults[$requiredParam] )
 42+ );
 43+ // Add them to the template call
 44+ $output .= "| $requiredParam = $param\n";
 45+ }
2746
28 - # get the required variables to use for the landing page
29 - $template = $this->make_safe( $wgRequest->getText( 'template', $wgFundraiserLPDefaults[ 'template' ] ) );
30 - $appeal = $this->make_safe( $wgRequest->getText( 'appeal', $wgFundraiserLPDefaults[ 'appeal' ] ) );
31 - $form = $this->make_safe( $wgRequest->getText( 'form', $wgFundraiserLPDefaults[ 'form' ] ) );
 47+ # get the country code
3248 $country = $wgRequest->getVal( 'country' );
3349 // If no country was passed do a GeoIP lookup
3450 if ( !$country ) {
@@ -43,17 +59,17 @@
4460 $country = $wgFundraiserLPDefaults[ 'country' ];
4561 }
4662 $country = $this->make_safe( $country );
 63+ $output .= "| country = $country\n";
4764
48 - # begin generating the template call
49 - $output .= "{{ $template\n| appeal = $appeal\n| form = $form\n| country = $country\n";
50 -
51 - # add any parameters passed in the querystring
 65+ $excludeKeys = $requiredParams + array( 'template', 'country', 'title' );
 66+
 67+ # add any other parameters passed in the querystring
5268 foreach ( $wgRequest->getValues() as $k_unsafe => $v_unsafe ) {
5369 # skip the required variables
54 - if ( $k_unsafe == "template" || $k_unsafe == "appeal" || $k_unsafe == "form" || $k_unsafe == "country" ) {
 70+ if ( in_array( $k_unsafe, $excludeKeys ) ) {
5571 continue;
5672 }
57 - # get the variables name and value
 73+ # get the variable's name and value
5874 $key = $this->make_safe( $k_unsafe );
5975 $val = $this->make_safe( $v_unsafe );
6076 # print to the template in wiki-syntax

Follow-up revisions

RevisionCommit summaryAuthorDate
r105248MFT r104829, r104886, r104942, r104984, r105001, r105124, r105237awjrichards23:36, 5 December 2011

Status & tagging log