Katie Horn has uploaded a new change for review.
https://gerrit.wikimedia.org/r/214273
Change subject: WIP - Local Dev Mode. DO NOT MERGE
......................................................................
WIP - Local Dev Mode. DO NOT MERGE
Got the endpoint added, did some other stuff.
Wired up the endpoint so now we talk to ourselves in two exciting
new ways!
TODO: Something more robust than the proof-of-concept total
hackjob I made of the new local endpoint.
However: Keep it simple (for now)!
Change-Id: I9b033e838e6e496c4631dd2d21381da6dc8cba4f
---
M DonationInterface.alias.php
M DonationInterface.php
M gateway_common/GatewayPage.php
M gateway_common/gateway.adapter.php
A modules/devmode.js
A special/DevModeEndpoint.php
M special/GatewayFormChooser.php
7 files changed, 88 insertions(+), 5 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface
refs/changes/73/214273/1
diff --git a/DonationInterface.alias.php b/DonationInterface.alias.php
index e25a172..c83f1df 100644
--- a/DonationInterface.alias.php
+++ b/DonationInterface.alias.php
@@ -6,4 +6,5 @@
$specialPageAliases['en'] = array(
'GatewayFormChooser' => array( 'GatewayFormChooser' ),
'SystemStatus' => array( 'SystemStatus' ),
+ 'DevModeEndpoint' => array( 'DevModeEndpoint' ),
);
diff --git a/DonationInterface.php b/DonationInterface.php
index 2da8083..3c52a4f 100644
--- a/DonationInterface.php
+++ b/DonationInterface.php
@@ -33,6 +33,9 @@
$wgDonationInterfaceTestMode = false;
}
+//Enter Local Dev Mode! Rawr.
+$wgDonationInterfaceDevMode = false;
+
/**
* CLASSES
@@ -119,6 +122,7 @@
$wgAutoloadClasses['Gateway_Extras_SessionVelocityFilter'] = __DIR__ .
'/extras/session_velocity/session_velocity.body.php';
$wgAutoloadClasses['GatewayFormChooser'] = __DIR__ .
'/special/GatewayFormChooser.php';
$wgAutoloadClasses['SystemStatus'] = __DIR__ . '/special/SystemStatus.php';
+$wgAutoloadClasses['DevModeEndpoint'] = __DIR__ .
'/special/DevModeEndpoint.php';
/**
* GLOBALS
@@ -744,6 +748,7 @@
$wgSpecialPages['GatewayFormChooser'] = 'GatewayFormChooser';
$wgSpecialPages['SystemStatus'] = 'SystemStatus';
+$wgSpecialPages['DevModeEndpoint'] = 'DevModeEndpoint';
$wgSpecialPages['GlobalCollectGateway'] = 'GlobalCollectGateway';
$wgSpecialPages['GlobalCollectGatewayResult'] = 'GlobalCollectGatewayResult';
@@ -835,7 +840,11 @@
$wgResourceModules['jquery.payment'] = array(
'scripts' => 'jquery.payment/jquery.payment.js',
-) + $wgResourceTemplate;;
+) + $wgResourceTemplate;
+
+$wgResourceModules['donationInterface.devmode'] = array(
+ 'scripts' => 'devmode.js',
+) + $wgResourceTemplate;
// load any rapidhtml related resources
require_once( __DIR__ . '/gateway_forms/rapidhtml/RapidHtmlResources.php' );
diff --git a/gateway_common/GatewayPage.php b/gateway_common/GatewayPage.php
index 0c7e7d0..1ae6536 100644
--- a/gateway_common/GatewayPage.php
+++ b/gateway_common/GatewayPage.php
@@ -50,6 +50,10 @@
$this->logger = DonationLoggerFactory::getLogger(
$this->adapter );
$this->getOutput()->addModules(
'donationInterface.skinOverride' );
+ if ($this->adapter->getGlobal('DevMode') === true){
+ $this->getOutput()->addModules(
'donationInterface.devmode' );
+ }
+
$me = get_called_class();
parent::__construct( $me );
}
@@ -70,7 +74,7 @@
$wgLang = RequestContext::getMain()->getLanguage();
}
- if ( $this->adapter->getGlobal( 'Enabled' ) !== true ) {
+ if ( $this->adapter->getGlobal( 'Enabled' ) !== true &&
$this->adapter->getGlobal( 'DevMode' ) !== true ) {
throw new BadTitleError();
}
diff --git a/gateway_common/gateway.adapter.php
b/gateway_common/gateway.adapter.php
index 0b38941..93a7f2d 100644
--- a/gateway_common/gateway.adapter.php
+++ b/gateway_common/gateway.adapter.php
@@ -1480,6 +1480,14 @@
* CURLOPT_RETURNTRANSFER is set or not). False on total failure.
*/
protected function curl_exec( $ch ) {
+ if ( $this->getGlobal( 'DevMode' ) === true ) {
+ $opts = array(
+ CURLOPT_URL =>
'http://localhost/index.php/Special:DevModeEndpoint?gateway=' .
$this->getIdentifier(),
+ CURLOPT_SSL_VERIFYPEER => 0,
+ CURLOPT_SSL_VERIFYHOST => 0,
+ );
+ curl_setopt_array( $ch, $opts );
+ }
return curl_exec( $ch );
}
diff --git a/modules/devmode.js b/modules/devmode.js
new file mode 100644
index 0000000..660cc92
--- /dev/null
+++ b/modules/devmode.js
@@ -0,0 +1,4 @@
+var d = document.createElement( 'div' );
+d.style.background = '#ff7700';
+d.innerHTML = 'Welcome to the Jungle! And by that I mean Local Dev Mode.';
+document.getElementById('appeal').appendChild(d);
\ No newline at end of file
diff --git a/special/DevModeEndpoint.php b/special/DevModeEndpoint.php
new file mode 100644
index 0000000..9930d4c
--- /dev/null
+++ b/special/DevModeEndpoint.php
@@ -0,0 +1,57 @@
+<?php
+
+class DevModeEndpoint extends UnlistedSpecialPage {
+
+ function __construct() {
+ parent::__construct( 'DevModeEndpoint' );
+ }
+
+ function execute( $par ) {
+ global $wgDonationInterfaceDevMode, $wgRequest;
+
+ if ( !$wgDonationInterfaceDevMode ) {
+ throw new BadTitleError();
+ }
+
+ $xmlDoc = new DomDocument( '1.0', 'UTF-8' );
+ $node = $xmlDoc->createElement( 'XML' );
+ $response = $xmlDoc->createElement( 'RESPONSE', '' );
+ $node->appendChild( $response );
+ $row = $xmlDoc->createElement( 'ROW', '' );
+ $response->appendChild( $row );
+
+
+ $gateway = $wgRequest->getText( 'gateway' );
+ switch ( $gateway ) {
+ case 'globalcollect' :
+ $temp = $xmlDoc->createElement( 'RESULT', 'OK'
);
+ $response->appendChild( $temp );
+ $responsenodes = array(
+ 'ORDER_ID' => '1123581321',
+ 'FORMACTION' =>
'http://localhost/index.php/Special:DevModeEndpoint',
+ 'STATUSID' => '20',
+ );
+ foreach ( $responsenodes as $rnode =>
$rnodevalue ) {
+ $temp = $xmlDoc->createElement( $rnode,
$rnodevalue );
+ $row->appendChild( $temp );
+ }
+ break;
+ case '':
+ $temp = $xmlDoc->createElement( 'error', 'No
gateway defined. How did you even.' );
+ $response->appendChild( $temp );
+ break;
+ default :
+ $temp = $xmlDoc->createElement( 'error', 'No
dummy behavior configured for gateway ' . $gateway );
+ $response->appendChild( $temp );
+ }
+
+ $xmlDoc->appendChild( $node );
+ $out = $xmlDoc->saveXML();
+
+ echo $out;
+
+ die();
+
+ }
+
+}
diff --git a/special/GatewayFormChooser.php b/special/GatewayFormChooser.php
index a964e8a..d17ba9b 100644
--- a/special/GatewayFormChooser.php
+++ b/special/GatewayFormChooser.php
@@ -176,7 +176,7 @@
static function getAllValidForms( $country = null, $currency = null,
$payment_method = null,
$payment_submethod = null, $recurring = false, $gateway = null
) {
- global $wgDonationInterfaceAllowedHtmlForms;
+ global $wgDonationInterfaceAllowedHtmlForms,
$wgDonationInterfaceDevMode;
$forms = $wgDonationInterfaceAllowedHtmlForms;
//Destroy all optional params that have no values and should be
null.
@@ -196,7 +196,7 @@
// First get all the valid and enabled gateways capable of
processing shtuff
$valid_gateways = self::getAllEnabledGateways();
- if ( $gateway !== null ) {
+ if ( $gateway !== null && $wgDonationInterfaceDevMode !== true
) {
if ( in_array( $gateway, $valid_gateways ) ) {
$valid_gateways = array( $gateway );
} else {
@@ -227,7 +227,7 @@
}
// filter on enabled gateways
- if ( !DataValidator::value_appears_in(
$meta['gateway'], $valid_gateways ) ) {
+ if ( !DataValidator::value_appears_in(
$meta['gateway'], $valid_gateways ) && $wgDonationInterfaceDevMode !== true ) {
unset( $forms[$name] );
continue;
}
--
To view, visit https://gerrit.wikimedia.org/r/214273
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9b033e838e6e496c4631dd2d21381da6dc8cba4f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Katie Horn <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits