Ejegg has uploaded a new change for review. https://gerrit.wikimedia.org/r/212457
Change subject: WIP add appeal to mustache data ...................................................................... WIP add appeal to mustache data Assumes transcluding a template, not a regular page Change-Id: I997c469bd0f9afd8c5f0418e248b6d474587e431 --- M DonationInterface.php M gateway_forms/Form.php M gateway_forms/Mustache.php M gateway_forms/RapidHtml.php 4 files changed, 40 insertions(+), 19 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface refs/changes/57/212457/1 diff --git a/DonationInterface.php b/DonationInterface.php index df4e677..aa374b3 100644 --- a/DonationInterface.php +++ b/DonationInterface.php @@ -134,6 +134,12 @@ */ $wgDonationInterfaceTemplate = __DIR__ . '/gateway_forms/mustache/index.html.mustache'; +/** + * Title to transclude in form template as {{{ appeal_text }}}. + * @appeal and @language will be substituted before transclusion + */ +$wgDonationInterfaceAppealWikiPage = 'LanguageSwitch|2011FR/@appeal/text|@language'; + //all of the following variables make sense to override directly, //or change "DonationInterface" to the gateway's id to override just for that gateway. //for instance: To override $wgDonationInterfaceUseSyslog just for GlobalCollect, add diff --git a/gateway_forms/Form.php b/gateway_forms/Form.php index e88b625..ed4ad65 100644 --- a/gateway_forms/Form.php +++ b/gateway_forms/Form.php @@ -153,4 +153,23 @@ protected static function getCountrySpecificMessage( $key, $country, $language ) { return DataValidator::wfLangSpecificFallback( $language, array( $key . '-' . strtolower( $country ), $key ) ); } + + /** + * This function limits the possible characters passed as template keys and + * values to letters, numbers, hyphens and underscores. The function also + * performs standard escaping of the passed values. + * + * @param string $string The unsafe string to escape and check for invalid characters + * @param string $default + * @return string $default A string matching the regex or an empty string + */ + function make_safe( $string, $default='' ) { + $num = preg_match( '([a-zA-Z0-9_-]+)', $string, $matches ); + + if ( $num == 1 ){ + # theoretically this is overkill, but better safe than sorry + return wfEscapeWikiText( htmlspecialchars( $matches[0] ) ); + } + return $default; + } } diff --git a/gateway_forms/Mustache.php b/gateway_forms/Mustache.php index 757d378..6b37c8e 100644 --- a/gateway_forms/Mustache.php +++ b/gateway_forms/Mustache.php @@ -36,6 +36,21 @@ $data = $this->gateway->getData_Unstaged_Escaped(); self::$language = $data['language']; self::$country = $data['country']; + + $context = RequestContext::getMain(); + $config = $context->getConfig(); + $output = $context->getOutput(); + $request = $context->getRequest(); + + $data['script_path'] = $config->get( 'ScriptPath' ); + $data['verisign_logo'] = $this->getSmallSecureLogo(); + $data['no_script'] = $this->getNoScript(); + + $appealWikiPage = $this->gateway->getGlobal( 'AppealWikiPage' ); + $appeal = $this->make_safe( $request->getText( 'appeal', 'Appeal-default' ) ); + $appealWikiPage = str_replace( '@appeal', $appeal, $appealWikiPage ); + $appealWikiPage = str_replace( '@language', $data['language'], $appealWikiPage ); + $data['appeal_text'] = $output->parse( '{{' . $appealWikiPage . '}}' ); $config = RequestContext::getMain()->getConfig(); diff --git a/gateway_forms/RapidHtml.php b/gateway_forms/RapidHtml.php index 3e526ae..2e6a63a 100644 --- a/gateway_forms/RapidHtml.php +++ b/gateway_forms/RapidHtml.php @@ -531,25 +531,6 @@ } /** - * This function limits the possible characters passed as template keys and - * values to letters, numbers, hyphens and underscores. The function also - * performs standard escaping of the passed values. - * - * @param string $string The unsafe string to escape and check for invalid characters - * @param string $default - * @return string $default A string matching the regex or an empty string - */ - function make_safe( $string, $default='' ) { - $num = preg_match( '([a-zA-Z0-9_-]+)', $string, $matches ); - - if ( $num == 1 ){ - # theoretically this is overkill, but better safe than sorry - return wfEscapeWikiText( htmlspecialchars( $matches[0] ) ); - } - return $default; - } - - /** * Gets a list of the supported countries from the parent class * and returns an option list representing all of those countries * in a translatable fashion. -- To view, visit https://gerrit.wikimedia.org/r/212457 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I997c469bd0f9afd8c5f0418e248b6d474587e431 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/DonationInterface Gerrit-Branch: master Gerrit-Owner: Ejegg <eeggles...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits