Index: trunk/extensions/FundraiserLandingPage/FundraiserLandingPage.i18n.php |
Property changes on: trunk/extensions/FundraiserLandingPage/FundraiserLandingPage.i18n.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 1 | + native |
Index: trunk/extensions/FundraiserLandingPage/FundraiserLandingPage.php |
— | — | @@ -0,0 +1,44 @@ |
| 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 | + 'name' => 'FundraiserLandingPage', |
| 22 | + 'author' => 'Peter Gehres', |
| 23 | + 'url' => '', |
| 24 | + 'description' => '', |
| 25 | + 'descriptionmsg' => '', |
| 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' => 'LandingPage', |
| 43 | + 'appeal' => 'appeal-brandon-1', |
| 44 | + 'form' => 'lp-form-US7amounts-extrainfo-noppval' |
| 45 | +); |
\ No newline at end of file |
Property changes on: trunk/extensions/FundraiserLandingPage/FundraiserLandingPage.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 46 | + native |
Index: trunk/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: trunk/extensions/FundraiserLandingPage/FundraiserLandingPage.alias.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 15 | + native |
Index: trunk/extensions/FundraiserLandingPage/FundraiserLandingPage.body.php |
— | — | @@ -0,0 +1,53 @@ |
| 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 $wgRequest, $wgOut, $wgFundraiserLPDefaults; |
| 17 | + |
| 18 | + $this->setHeaders(); |
| 19 | + |
| 20 | + # load the querystring variables |
| 21 | + $values = $wgRequest->getValues(); |
| 22 | + |
| 23 | + # clear output variable to be safe |
| 24 | + $output = ""; |
| 25 | + |
| 26 | + # get the required variables to use for the landing page |
| 27 | + # (escaping with both htmlspecialchars and wfEscapeWikiText since the |
| 28 | + # parameters are intending to reference templates) |
| 29 | + $template = wfEscapeWikiText( htmlspecialchars( $wgRequest->getText( 'template', $wgFundraiserLPDefaults[ 'template' ] ) ) ); |
| 30 | + $appeal = wfEscapeWikiText( htmlspecialchars( $wgRequest->getText( 'appeal', $wgFundraiserLPDefaults[ 'appeal' ] ) ) ); |
| 31 | + $form = wfEscapeWikiText( htmlspecialchars( $wgRequest->getText( 'form', $wgFundraiserLPDefaults[ 'form' ] ) ) ); |
| 32 | + |
| 33 | + # begin generating the template call |
| 34 | + $output .= "{{ $template\n| appeal = $appeal\n| form = $form\n"; |
| 35 | + |
| 36 | + # add any parameters passed in the querystring |
| 37 | + foreach ( $values as $k=>$v){ |
| 38 | + # skip the required variables |
| 39 | + if ( $k == "template" || $k == "appeal" || $k == "form" ){ |
| 40 | + continue; |
| 41 | + } |
| 42 | + # get the variables name and value |
| 43 | + $key = wfEscapeWikiText( htmlspecialchars( $k ) ); |
| 44 | + $val = wfEscapeWikiText( htmlspecialchars( $v ) ); |
| 45 | + # print to the template in wiki-syntax |
| 46 | + $output .= "| $key = $val\n"; |
| 47 | + } |
| 48 | + # close the template call |
| 49 | + $output .= "}}"; |
| 50 | + |
| 51 | + # print the output to the page |
| 52 | + $wgOut->addWikiText( $output ); |
| 53 | + } |
| 54 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/FundraiserLandingPage/FundraiserLandingPage.body.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 55 | + native |