Index: branches/wmf/1.18wmf1/extensions/FundraiserLandingPage/FundraiserLandingPage.i18n.php |
— | — | @@ -0,0 +1,78 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +$messages = array(); |
| 5 | + |
| 6 | +$messages['en'] = array( |
| 7 | + 'fundraiserlandingpage-desc' => 'Takes URL parameters and passes them to the specified template as template variables', |
| 8 | +); |
| 9 | + |
| 10 | +/** Asturian (Asturianu) |
| 11 | + * @author Xuacu |
| 12 | + */ |
| 13 | +$messages['ast'] = array( |
| 14 | + 'fundraiserlandingpage-desc' => 'Toma los parámetros de la URL y los pasa como variables de plantía a la plantía especificada', |
| 15 | +); |
| 16 | + |
| 17 | +/** German (Deutsch) |
| 18 | + * @author Kghbln |
| 19 | + */ |
| 20 | +$messages['de'] = array( |
| 21 | + 'fundraiserlandingpage-desc' => 'Ermögliche die Nutzung von URL-Parametern als Vorlagenvariablen', |
| 22 | +); |
| 23 | + |
| 24 | +/** French (Français) |
| 25 | + * @author Gomoko |
| 26 | + */ |
| 27 | +$messages['fr'] = array( |
| 28 | + 'fundraiserlandingpage-desc' => "Prends les paramètres de l'URL et les passe au modèle spécifié comme variables de modèle", |
| 29 | +); |
| 30 | + |
| 31 | +/** Galician (Galego) |
| 32 | + * @author Toliño |
| 33 | + */ |
| 34 | +$messages['gl'] = array( |
| 35 | + 'fundraiserlandingpage-desc' => 'Toma parámetros URL e pásaos como variables de modelo a aquel modelo especificado', |
| 36 | +); |
| 37 | + |
| 38 | +/** Upper Sorbian (Hornjoserbsce) |
| 39 | + * @author Michawiki |
| 40 | + */ |
| 41 | +$messages['hsb'] = array( |
| 42 | + 'fundraiserlandingpage-desc' => 'Přepodawa URL-parametry na podatu předłohu jako wariable předłohi', |
| 43 | +); |
| 44 | + |
| 45 | +/** Interlingua (Interlingua) |
| 46 | + * @author McDutchie |
| 47 | + */ |
| 48 | +$messages['ia'] = array( |
| 49 | + 'fundraiserlandingpage-desc' => 'Prende parametros de URL e los passa al patrono specificate como variabiles de patrono', |
| 50 | +); |
| 51 | + |
| 52 | +/** Luxembourgish (Lëtzebuergesch) |
| 53 | + * @author Robby |
| 54 | + */ |
| 55 | +$messages['lb'] = array( |
| 56 | + 'fundraiserlandingpage-desc' => "Hëllt d'Parameter vun der URL a gëtt se un déi spezifizéiert Schabloun als Schabloune-Variabele weider", |
| 57 | +); |
| 58 | + |
| 59 | +/** Macedonian (Македонски) |
| 60 | + * @author Bjankuloski06 |
| 61 | + */ |
| 62 | +$messages['mk'] = array( |
| 63 | + 'fundraiserlandingpage-desc' => 'Зема параметри од URL-адреса и му ги дава на наведениот шаблон како негови променливи', |
| 64 | +); |
| 65 | + |
| 66 | +/** Dutch (Nederlands) |
| 67 | + * @author Siebrand |
| 68 | + */ |
| 69 | +$messages['nl'] = array( |
| 70 | + 'fundraiserlandingpage-desc' => 'Accepteert URL-parameters en geeft deze door aan het opgegeven sjabloon als sjabloonvariabelen', |
| 71 | +); |
| 72 | + |
| 73 | +/** Piedmontese (Piemontèis) |
| 74 | + * @author Dragonòt |
| 75 | + */ |
| 76 | +$messages['pms'] = array( |
| 77 | + 'fundraiserlandingpage-desc' => "A pija ij paràmetr d'anliura e a-j passa a lë stamp spessificà com variàbil dë stamp", |
| 78 | +); |
| 79 | + |
Property changes on: branches/wmf/1.18wmf1/extensions/FundraiserLandingPage/FundraiserLandingPage.i18n.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 80 | + native |
Index: branches/wmf/1.18wmf1/extensions/FundraiserLandingPage/FundraiserLandingPage.php |
— | — | @@ -0,0 +1,48 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/* |
| 5 | + * Extension:FundraiserLandingPage. This extension takes URL parameters in the |
| 6 | + * QueryString and passes them to the specified template as template variables. |
| 7 | + * |
| 8 | + * @author Peter Gehres <pgehres@wikimedia.org> |
| 9 | + */ |
| 10 | + |
| 11 | +// Alert the user that this is not a valid entry point to MediaWiki if they try to access the special pages file directly. |
| 12 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 13 | + echo <<<EOT |
| 14 | +To install the FundraiserLandingPage extension, put the following line in LocalSettings.php: |
| 15 | +require_once( "\$IP/extensions/FundraiserLandingPage/FundraiserLandingPage.php" ); |
| 16 | +EOT; |
| 17 | + exit( 1 ); |
| 18 | +} |
| 19 | + |
| 20 | +$wgExtensionCredits[ 'specialpage' ][ ] = array( |
| 21 | + 'path' => __FILE__, |
| 22 | + 'name' => 'FundraiserLandingPage', |
| 23 | + 'author' => 'Peter Gehres', |
| 24 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:FundraiserLandingPage', |
| 25 | + 'descriptionmsg' => 'fundraiserlandingpage-desc', |
| 26 | + 'version' => '1.0.0', |
| 27 | +); |
| 28 | + |
| 29 | +$dir = dirname( __FILE__ ) . '/'; |
| 30 | + |
| 31 | +$wgAutoloadClasses[ 'FundraiserLandingPage' ] = $dir . 'FundraiserLandingPage.body.php'; |
| 32 | + |
| 33 | +$wgExtensionMessagesFiles[ 'FundraiserLandingPage' ] = $dir . 'FundraiserLandingPage.i18n.php'; |
| 34 | + |
| 35 | +$wgSpecialPages[ 'FundraiserLandingPage' ] = 'FundraiserLandingPage'; |
| 36 | + |
| 37 | +/* |
| 38 | + * Defaults for the required fields. These fields will be included whether |
| 39 | + * or not they are passed through the querystring. |
| 40 | + */ |
| 41 | +$wgFundraiserLPDefaults = array( |
| 42 | + 'template' => 'Lp-wrapper', |
| 43 | + 'appeal' => 'Appeal-default', |
| 44 | + 'form' => 'Form-default' |
| 45 | +); |
| 46 | + |
| 47 | +// Adding configurrable variable for caching time |
| 48 | +$wgFundraiserLandingPageMaxAge = 300; //5 minutes |
| 49 | + |
Property changes on: branches/wmf/1.18wmf1/extensions/FundraiserLandingPage/FundraiserLandingPage.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 50 | + native |
Index: branches/wmf/1.18wmf1/extensions/FundraiserLandingPage/FundraiserLandingPage.alias.php |
— | — | @@ -0,0 +1,13 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +$specialPageAliases = array(); |
| 5 | + |
| 6 | +/** English */ |
| 7 | +$specialPageAliases[ 'en' ] = array( |
| 8 | + 'FundraiserLandingPage' => array( 'FundraiserLandingPage' ), |
| 9 | +); |
| 10 | + |
| 11 | +/** |
| 12 | + * For backwards compatibility with MediaWiki 1.15 and earlier. |
| 13 | + */ |
| 14 | +$aliases =& $specialPageAliases; |
\ No newline at end of file |
Property changes on: branches/wmf/1.18wmf1/extensions/FundraiserLandingPage/FundraiserLandingPage.alias.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 15 | + native |
Index: branches/wmf/1.18wmf1/extensions/FundraiserLandingPage/FundraiserLandingPage.body.php |
— | — | @@ -0,0 +1,71 @@ |
| 2 | +<?php |
| 3 | +/* |
| 4 | + * SpecialPage definition for FundraiserLandingPage. Extending UnlistedSpecialPage |
| 5 | + * since this page does not need to listed in Special:SpecialPages. |
| 6 | + * |
| 7 | + * @author Peter Gehres <pgehres@wikimedia.org> |
| 8 | + */ |
| 9 | +class FundraiserLandingPage extends UnlistedSpecialPage |
| 10 | +{ |
| 11 | + function __construct() { |
| 12 | + parent::__construct( 'FundraiserLandingPage' ); |
| 13 | + } |
| 14 | + |
| 15 | + function execute( $par ) { |
| 16 | + global $wgFundraiserLPDefaults, $wgOut, $wgFundraiserLandingPageMaxAge; |
| 17 | + |
| 18 | + #Set squid age |
| 19 | + $wgOut->setSquidMaxage( $wgFundraiserLandingPageMaxAge ); |
| 20 | + $request = $this->getRequest(); |
| 21 | + $this->setHeaders(); |
| 22 | + |
| 23 | + # clear output variable to be safe |
| 24 | + $output = ''; |
| 25 | + |
| 26 | + # get the required variables to use for the landing page |
| 27 | + $template = $this->make_safe( $request->getText( 'template', $wgFundraiserLPDefaults[ 'template' ] ) ); |
| 28 | + $appeal = $this->make_safe( $request->getText( 'appeal', $wgFundraiserLPDefaults[ 'appeal' ] ) ); |
| 29 | + $form = $this->make_safe( $request->getText( 'form', $wgFundraiserLPDefaults[ 'form' ] ) ); |
| 30 | + |
| 31 | + # begin generating the template call |
| 32 | + $output .= "{{ $template\n| appeal = $appeal\n| form = $form\n"; |
| 33 | + |
| 34 | + # add any parameters passed in the querystring |
| 35 | + foreach ( $request->getValues() as $k_unsafe => $v_unsafe ) { |
| 36 | + # skip the required variables |
| 37 | + if ( $k_unsafe == "template" || $k_unsafe == "appeal" || $k_unsafe == "form" ) { |
| 38 | + continue; |
| 39 | + } |
| 40 | + # get the variables name and value |
| 41 | + $key = $this->make_safe( $k_unsafe ); |
| 42 | + $val = $this->make_safe( $v_unsafe ); |
| 43 | + # print to the template in wiki-syntax |
| 44 | + $output .= "| $key = $val\n"; |
| 45 | + } |
| 46 | + # close the template call |
| 47 | + $output .= "}}"; |
| 48 | + |
| 49 | + # print the output to the page |
| 50 | + $this->getOutput()->addWikiText( $output ); |
| 51 | + } |
| 52 | + |
| 53 | + |
| 54 | + /** |
| 55 | + * This function limits the possible charactes passed as template keys and |
| 56 | + * values to letters, numbers, hypens and underscores. The function also |
| 57 | + * performs standard escaping of the passed values. |
| 58 | + * |
| 59 | + * @param $string The unsafe string to escape and check for invalid characters |
| 60 | + * @return mixed|String A string matching the regex or an empty string |
| 61 | + */ |
| 62 | + function make_safe( $string ) { |
| 63 | + $num = preg_match( '([a-zA-Z0-9_-]+)', $string, $matches ); |
| 64 | + |
| 65 | + if ( $num == 1 ){ |
| 66 | + # theoretically this is overkill, but better safe than sorry |
| 67 | + return wfEscapeWikiText( htmlspecialchars( $matches[0] ) ); |
| 68 | + } |
| 69 | + return ''; |
| 70 | + } |
| 71 | +} |
| 72 | + |
Property changes on: branches/wmf/1.18wmf1/extensions/FundraiserLandingPage/FundraiserLandingPage.body.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 73 | + native |