r100163 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100162‎ | r100163 | r100164 >
Date:21:21, 18 October 2011
Author:khorn
Status:ok
Tags:fundraising 
Comment:
Merging the fundraising branch of DonationInterface back into trunk.
This round handles merging the content of all the form classes.
As this is a mid-merge commit, the extension will be broken until the merge is completed.
Modified paths:
  • /trunk/extensions/DonationInterface/gateway_forms (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_forms/Form.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_forms/OneStepTwoColumn.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_forms/RapidHtml.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_forms/SingleColumn.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_forms/TwoColumnLetter.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_forms/TwoColumnLetter2.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_forms/TwoColumnLetter3.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_forms/TwoColumnLetter4.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_forms/TwoColumnLetter5.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_forms/TwoColumnLetter6.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_forms/TwoColumnLetter7.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_forms/TwoColumnPayPal.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_forms/TwoStepAmount.php (added) (history)
  • /trunk/extensions/DonationInterface/gateway_forms/TwoStepTwoColumn.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnLetter.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnLetter2.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnLetter3.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnLetterCA.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnPremium.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnPremiumUS.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/gateway_forms/TwoColumnLetter2.php
@@ -3,7 +3,7 @@
44 class PayflowProGateway_Form_TwoColumnLetter2 extends PayflowProGateway_Form_OneStepTwoColumn {
55 public $paypal = false; // true for paypal only version
66
7 - public function __construct( &$form_data, &$form_errors ) {
 7+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
88 global $wgScriptPath;
99
1010 // set the path to css, before the parent constructor is called, checking to make sure some child class hasn't already set this
@@ -11,7 +11,7 @@
1212 $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoColumnLetter.css' );
1313 }
1414
15 - parent::__construct( $form_data, $form_errors );
 15+ parent::__construct( $form_data, $form_errors, $gateway );
1616 }
1717
1818 public function generateFormStart() {
@@ -82,7 +82,7 @@
8383 }
8484
8585 protected function generateBillingFields() {
86 - global $wgScriptPath, $wgPayflowGatewayPaypalURL, $wgRequest;
 86+ global $wgScriptPath, $wgRequest;
8787 $scriptPath = "$wgScriptPath/extensions/DonationInterface/payflowpro_gateway/includes";
8888
8989 $form = '';
@@ -107,7 +107,7 @@
108108 if ( !$this->paypal ) {
109109 // PayPal button
110110 // make sure we have a paypal url set to redirect the user to before displaying the button
111 - if ( strlen( $wgPayflowGatewayPaypalURL ) ) {
 111+ if ( strlen( $this->gateway->getGlobal( "PaypalURL" ) ) ) {
112112 $form .= '<tr>';
113113 $form .= '<td class="label"></td>';
114114 $form .= '<td>';
Index: trunk/extensions/DonationInterface/gateway_forms/TwoStepAmount.php
@@ -0,0 +1,262 @@
 2+<?php
 3+/**
 4+ * Wikimedia Foundation
 5+ *
 6+ * LICENSE
 7+ *
 8+ * This program is free software; you can redistribute it and/or modify
 9+ * it under the terms of the GNU General Public License as published by
 10+ * the Free Software Foundation; either version 2 of the License, or
 11+ * (at your option) any later version.
 12+ *
 13+ * This program is distributed in the hope that it will be useful,
 14+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
 15+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 16+ * GNU General Public License for more details.
 17+ *
 18+ * @since r98249
 19+ * @author Jeremy Postlethwaite <jpostlethwaite@wikimedia.org>
 20+ */
 21+
 22+/**
 23+ * This form is designed for bank transfers
 24+ */
 25+class Gateway_Form_TwoStepAmount extends Gateway_Form {
 26+
 27+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
 28+ global $wgOut;
 29+
 30+ $form_data['transaction_type'] = 'BANK_TRANSFER';
 31+ $form_data['process'] = 'BANK_TRANSFER';
 32+ parent::__construct( $form_data, $form_errors, $gateway );
 33+
 34+ // we only want to load this JS if the form is being rendered
 35+ $this->loadValidateJs(); // validation JS
 36+
 37+ $this->loadPlaceholders();
 38+ }
 39+
 40+ public function loadPlaceholders() {
 41+ global $wgOut;
 42+ // form placeholder values
 43+ $first = wfMsg( 'payflowpro_gateway-donor-fname' );
 44+ $last = wfMsg( 'payflowpro_gateway-donor-lname' );
 45+ $js = <<<EOT
 46+<script type="text/javascript">
 47+function loadPlaceholders() {
 48+ var fname = document.getElementById('fname');
 49+ var lname = document.getElementById('lname');
 50+ var amountOther = document.getElementById('amountOther');
 51+ if (fname.value == '') {
 52+ fname.style.color = '#999999';
 53+ fname.value = '$first';
 54+ }
 55+ if (lname.value == '') {
 56+ lname.style.color = '#999999';
 57+ lname.value = '$last';
 58+ }
 59+}
 60+addEvent( window, 'load', loadPlaceholders );
 61+
 62+function formCheck( ccform ) {
 63+ var msg = [ 'EmailAdd', 'Fname', 'Lname', 'Street', 'City', 'Zip' ];
 64+
 65+ var fields = ["emailAdd","fname","lname","street","city","zip" ],
 66+ numFields = fields.length,
 67+ i,
 68+ output = '',
 69+ currField = '';
 70+
 71+ for( i = 0; i < numFields; i++ ) {
 72+ if( document.getElementById( fields[i] ).value == '' ) {
 73+ currField = window['payflowproGatewayErrorMsg'+ msg[i]];
 74+ output += payflowproGatewayErrorMsgJs + ' ' + currField + '.\\r\\n';
 75+ }
 76+ }
 77+
 78+ if (document.getElementById('fname').value == '$first') {
 79+ output += payflowproGatewayErrorMsgJs + ' first name.\\r\\n';
 80+ }
 81+ if (document.getElementById('lname').value == '$last') {
 82+ output += payflowproGatewayErrorMsgJs + ' last name.\\r\\n';
 83+ }
 84+ var countryField = document.getElementById( 'country' );
 85+ if( countryField.options[countryField.selectedIndex].value == '' ) {
 86+ output += payflowproGatewayErrorMsgJs + ' ' + window['payflowproGatewayErrorMsgCountry'] + '.\\r\\n';
 87+ }
 88+
 89+ // validate email address
 90+ var apos = document.payment.emailAdd.value.indexOf("@");
 91+ var dotpos = document.payment.emailAdd.value.lastIndexOf(".");
 92+
 93+ if( apos < 1 || dotpos-apos < 2 ) {
 94+ output += payflowproGatewayErrorMsgEmail;
 95+ }
 96+
 97+ if( output ) {
 98+ alert( output );
 99+ return false;
 100+ } else {
 101+ return true;
 102+ }
 103+}
 104+</script>
 105+EOT;
 106+ $wgOut->addHeadItem( 'placeholders', $js );
 107+ }
 108+
 109+ /**
 110+ * Required method for constructing the entire form
 111+ *
 112+ * This can of course be overloaded by a child class.
 113+ * @return string The entire form HTML
 114+ */
 115+ public function getForm() {
 116+ $form = $this->generateFormStart();
 117+ $form .= $this->getCaptchaHTML();
 118+ $form .= $this->generateFormEnd();
 119+ return $form;
 120+ }
 121+
 122+ public function generateFormStart() {
 123+ $form = $this->generateBannerHeader();
 124+
 125+ $form .= Xml::openElement( 'div', array( 'id' => 'mw-creditcard' ) );
 126+
 127+ // provide a place at the top of the form for displaying general messages
 128+ if ( $this->form_errors['general'] ) {
 129+ $form .= Xml::openElement( 'div', array( 'id' => 'mw-payflow-general-error' ) );
 130+ if ( is_array( $this->form_errors['general'] ) ) {
 131+ foreach ( $this->form_errors['general'] as $this->form_errors_msg ) {
 132+ $form .= Xml::tags( 'p', array( 'class' => 'creditcard-error-msg' ), $this->form_errors_msg );
 133+ }
 134+ } else {
 135+ $form .= Xml::tags( 'p', array( 'class' => 'creditcard-error-msg' ), $this->form_errors_msg );
 136+ }
 137+ $form .= Xml::closeElement( 'div' );
 138+ }
 139+
 140+ // add noscript tags for javascript disabled browsers
 141+ $form .= $this->getNoScript();
 142+
 143+ // open form
 144+ $form .= Xml::openElement( 'div', array( 'id' => 'mw-creditcard-form' ) );
 145+
 146+ // Xml::element seems to convert html to htmlentities
 147+ $form .= "<p class='creditcard-error-msg'>" . $this->form_errors['retryMsg'] . "</p>";
 148+ $form .= Xml::openElement( 'form', array( 'name' => 'payment', 'method' => 'post', 'action' => $this->getNoCacheAction(), 'onsubmit' => 'return formCheck(this)', 'autocomplete' => 'off' ) );
 149+
 150+ $form .= Xml::openElement( 'div', array( 'id' => 'left-column', 'class' => 'payflow-cc-form-section' ) );
 151+ $form .= $this->generatePersonalContainer();
 152+ $form .= $this->generatePaymentContainer();
 153+ $form .= $this->generateFormSubmit();
 154+ $form .= Xml::closeElement( 'div' ); // close div#left-column
 155+
 156+ //$form .= Xml::openElement( 'div', array( 'id' => 'right-column', 'class' => 'payflow-cc-form-section' ) );
 157+
 158+ return $form;
 159+ }
 160+
 161+ public function generateFormSubmit() {
 162+ // submit button
 163+ $form = Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-form-submit' ) );
 164+ $form .= Xml::openElement( 'div', array( 'id' => 'mw-donate-submit-button' ) );
 165+ // $form .= Xml::submitButton( wfMsg( 'payflowpro_gateway-submit-button' ));
 166+ $form .= Xml::element( 'input', array( 'class' => 'button-plain', 'value' => wfMsg( 'payflowpro_gateway-cc-button' ), 'type' => 'submit' ) );
 167+ $form .= Xml::closeElement( 'div' ); // close div#mw-donate-submit-button
 168+ $form .= Xml::openElement( 'div', array( 'class' => 'mw-donate-submessage', 'id' => 'payflowpro_gateway-donate-submessage' ) ) .
 169+ wfMsg( 'payflowpro_gateway-donate-click' );
 170+ $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-donate-submessage
 171+ $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-form-submit
 172+ return $form;
 173+ }
 174+
 175+ public function generateFormEnd() {
 176+ $form = '';
 177+ // add hidden fields
 178+ $hidden_fields = $this->getHiddenFields();
 179+ foreach ( $hidden_fields as $field => $value ) {
 180+ $form .= Html::hidden( $field, $value );
 181+ }
 182+
 183+ $value = 'BANK_TRANSFER';
 184+ //$form .= Html::hidden( $field, $value );
 185+ //$form .= Xml::closeElement( 'div' ); // close div#right-column
 186+ $form .= Xml::closeElement( 'form' );
 187+ $form .= Xml::closeElement( 'div' ); // close div#mw-creditcard-form
 188+ $form .= $this->generateDonationFooter();
 189+ $form .= Xml::closeElement( 'div' ); // div#close mw-creditcard
 190+ return $form;
 191+ }
 192+
 193+ protected function generatePersonalContainer() {
 194+ $form = '';
 195+ $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-personal-info' ) ); ;
 196+ //$form .= Xml::tags( 'h3', array( 'class' => 'payflow-cc-form-header', 'id' => 'payflow-cc-form-header-personal' ), wfMsg( 'payflowpro_gateway-cc-form-header-personal' ) );
 197+ $form .= Xml::openElement( 'table', array( 'id' => 'payflow-table-donor' ) );
 198+
 199+ $form .= $this->generatePersonalFields();
 200+
 201+ $form .= Xml::closeElement( 'table' ); // close table#payflow-table-donor
 202+ $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-personal-info
 203+
 204+ return $form;
 205+ }
 206+
 207+ protected function generatePersonalFields() {
 208+ // first name
 209+ $form = $this->getNameField();
 210+
 211+ // country
 212+ $form .= $this->getCountryField();
 213+
 214+ // street
 215+ $form .= $this->getStreetField();
 216+
 217+
 218+ // city
 219+ $form .= $this->getCityField();
 220+
 221+ // state
 222+ $form .= $this->getStateField();
 223+
 224+ // zip
 225+ $form .= $this->getZipField();
 226+
 227+ // email
 228+ $form .= $this->getEmailField();
 229+
 230+ return $form;
 231+ }
 232+
 233+ protected function generatePaymentContainer() {
 234+ $form = '';
 235+ // credit card info
 236+ $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-payment-info' ) );
 237+ //$form .= Xml::tags( 'h3', array( 'class' => 'payflow-cc-form-header', 'id' => 'payflow-cc-form-header-payment' ), wfMsg( 'payflowpro_gateway-cc-form-header-payment' ) );
 238+ $form .= Xml::openElement( 'table', array( 'id' => 'payflow-table-cc' ) );
 239+
 240+ $form .= $this->generatePaymentFields();
 241+
 242+ $form .= Xml::closeElement( 'table' ); // close table#payflow-table-cc
 243+ $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-payment-info
 244+
 245+ return $form;
 246+ }
 247+
 248+ protected function generatePaymentFields() {
 249+ global $wgScriptPath;
 250+
 251+ // amount
 252+ $form = '<tr>';
 253+ $form .= '<td colspan="2"><span class="creditcard-error-msg">' . $this->form_errors['invalidamount'] . '</span></td>';
 254+ $form .= '</tr>';
 255+ $form .= '<tr>';
 256+ $form .= '<td class="label">' . Xml::label( wfMsg( 'payflowpro_gateway-donor-amount' ), 'amount' ) . '</td>';
 257+ $form .= '<td>' . Xml::input( 'amount', '7', $this->form_data['amount'], array( 'type' => 'text', 'maxlength' => '10', 'id' => 'amount' ) ) .
 258+ ' ' . $this->generateCurrencyDropdown() . '</td>';
 259+ $form .= '</tr>';
 260+
 261+ return $form;
 262+ }
 263+}
Property changes on: trunk/extensions/DonationInterface/gateway_forms/TwoStepAmount.php
___________________________________________________________________
Added: svn:mergeinfo
1264 Merged /trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoStepAmount.php:r95445-96492
2265 Merged /branches/fundraising/extensions/DonationInterface/gateway_forms/TwoStepAmount.php:r95724-100157
Added: svn:eol-style
3266 + native
Added: svn:mime-type
4267 + text/plain
Added: svn:keywords
5268 + Author Date HeadURL Header Id Revision
Index: trunk/extensions/DonationInterface/gateway_forms/TwoColumnLetter3.php
@@ -3,7 +3,7 @@
44 class PayflowProGateway_Form_TwoColumnLetter3 extends PayflowProGateway_Form_OneStepTwoColumn {
55 public $paypal = false; // true for paypal only version
66
7 - public function __construct( &$form_data, &$form_errors ) {
 7+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
88 global $wgScriptPath;
99
1010 // set the path to css, before the parent constructor is called, checking to make sure some child class hasn't already set this
@@ -11,7 +11,7 @@
1212 $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoColumnLetter.css' );
1313 }
1414
15 - parent::__construct( $form_data, $form_errors );
 15+ parent::__construct( $form_data, $form_errors, $gateway );
1616 }
1717
1818 public function generateFormStart() {
@@ -82,7 +82,7 @@
8383 }
8484
8585 protected function generateBillingFields() {
86 - global $wgScriptPath, $wgPayflowGatewayPaypalURL, $wgRequest;
 86+ global $wgScriptPath, $wgRequest;
8787 $scriptPath = "$wgScriptPath/extensions/DonationInterface/payflowpro_gateway/includes";
8888
8989 $form = '';
@@ -107,7 +107,7 @@
108108 if ( !$this->paypal ) {
109109 // PayPal button
110110 // make sure we have a paypal url set to redirect the user to before displaying the button
111 - if ( strlen( $wgPayflowGatewayPaypalURL ) ) {
 111+ if ( strlen( $this->gateway->getGlobal( "PaypalURL" ) ) ) {
112112 $form .= '<tr>';
113113 $form .= '<td class="label"></td>';
114114 $form .= '<td>';
Index: trunk/extensions/DonationInterface/gateway_forms/TwoColumnLetter4.php
@@ -3,7 +3,7 @@
44 class PayflowProGateway_Form_TwoColumnLetter4 extends PayflowProGateway_Form_OneStepTwoColumn {
55 public $paypal = false; // true for paypal only version
66
7 - public function __construct( &$form_data, &$form_errors ) {
 7+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
88 global $wgScriptPath;
99
1010 // set the path to css, before the parent constructor is called, checking to make sure some child class hasn't already set this
@@ -11,7 +11,7 @@
1212 $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoColumnLetter4.css' );
1313 }
1414
15 - parent::__construct( $form_data, $form_errors );
 15+ parent::__construct( $form_data, $form_errors, $gateway );
1616 }
1717
1818 public function generateFormStart() {
@@ -82,7 +82,7 @@
8383 }
8484
8585 protected function generateBillingFields() {
86 - global $wgScriptPath, $wgPayflowGatewayPaypalURL, $wgRequest;
 86+ global $wgScriptPath, $wgRequest;
8787 $scriptPath = "$wgScriptPath/extensions/DonationInterface/payflowpro_gateway/includes";
8888
8989 $form = '';
@@ -107,7 +107,7 @@
108108 if ( !$this->paypal ) {
109109 // PayPal button
110110 // make sure we have a paypal url set to redirect the user to before displaying the button
111 - if ( strlen( $wgPayflowGatewayPaypalURL ) ) {
 111+ if ( strlen( $this->gateway->getGlobal( "PaypalURL" ) ) ) {
112112 $form .= '<tr>';
113113 $form .= '<td class="label"></td>';
114114 $form .= '<td>';
Index: trunk/extensions/DonationInterface/gateway_forms/TwoColumnLetter5.php
@@ -2,7 +2,7 @@
33
44 class PayflowProGateway_Form_TwoColumnLetter5 extends PayflowProGateway_Form_OneStepTwoColumn {
55
6 - public function __construct( &$form_data, &$form_errors ) {
 6+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
77 global $wgScriptPath;
88
99 // set the path to css, before the parent constructor is called, checking to make sure some child class hasn't already set this
@@ -10,7 +10,7 @@
1111 $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoColumnLetter5.css' );
1212 }
1313
14 - parent::__construct( $form_data, $form_errors );
 14+ parent::__construct( $form_data, $form_errors, $gateway );
1515 }
1616
1717 public function generateFormStart() {
@@ -79,7 +79,7 @@
8080 }
8181
8282 protected function generateBillingFields() {
83 - global $wgScriptPath, $wgPayflowGatewayPaypalURL, $wgRequest;
 83+ global $wgScriptPath, $wgRequest;
8484 $scriptPath = "$wgScriptPath/extensions/DonationInterface/payflowpro_gateway/includes";
8585
8686 $form = '';
@@ -136,11 +136,11 @@
137137 $form .= '<tr>';
138138 $form .= '<td class="label">' . wfMsg( 'payflowpro_gateway-payment-type' ) . '</td>';
139139 $form .= '<td>' .
140 - Xml::radio( 'card', 'cc1', $this->form_data['card'] == 'cc1', array( 'id' => 'cc1radio', 'onclick' => 'switchToCreditCard()' ) ) . '<label for="cc1radio">' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-visa.png" ) ). '</label>' .
141 - Xml::radio( 'card', 'cc2', $this->form_data['card'] == 'cc2', array( 'id' => 'cc2radio', 'onclick' => 'switchToCreditCard()' ) ) . '<label for="cc2radio">' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-mastercard.png" ) ). '</label>' .
142 - Xml::radio( 'card', 'cc3', $this->form_data['card'] == 'cc3', array( 'id' => 'cc3radio', 'onclick' => 'switchToCreditCard()' ) ) . '<label for="cc3radio">' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-amex.png" ) ). '</label>' .
143 - Xml::radio( 'card', 'cc4', $this->form_data['card'] == 'cc4', array( 'id' => 'cc4radio', 'onclick' => 'switchToCreditCard()' ) ) . '<label for="cc4radio">' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-discover.png" ) ). '</label>' .
144 - Xml::radio( 'card', 'pp', $this->form_data['card'] == 'pp', array( 'id' => 'ppradio', 'onclick' => 'switchToPayPal()' ) ) . '<label for="ppradio">' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-paypal.png" ) ) . '</label>' .
 140+ Xml::radio( 'card_type', 'cc1', $this->form_data['card_type'] == 'cc1', array( 'id' => 'cc1radio', 'onclick' => 'switchToCreditCard()' ) ) . '<label for="cc1radio">' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-visa.png" ) ). '</label>' .
 141+ Xml::radio( 'card_type', 'cc2', $this->form_data['card_type'] == 'cc2', array( 'id' => 'cc2radio', 'onclick' => 'switchToCreditCard()' ) ) . '<label for="cc2radio">' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-mastercard.png" ) ). '</label>' .
 142+ Xml::radio( 'card_type', 'cc3', $this->form_data['card_type'] == 'cc3', array( 'id' => 'cc3radio', 'onclick' => 'switchToCreditCard()' ) ) . '<label for="cc3radio">' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-amex.png" ) ). '</label>' .
 143+ Xml::radio( 'card_type', 'cc4', $this->form_data['card_type'] == 'cc4', array( 'id' => 'cc4radio', 'onclick' => 'switchToCreditCard()' ) ) . '<label for="cc4radio">' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-discover.png" ) ). '</label>' .
 144+ Xml::radio( 'card_type', 'pp', $this->form_data['card_type'] == 'pp', array( 'id' => 'ppradio', 'onclick' => 'switchToPayPal()' ) ) . '<label for="ppradio">' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-paypal.png" ) ) . '</label>' .
145145 '</td>';
146146 $form .= '</tr>';
147147
Index: trunk/extensions/DonationInterface/gateway_forms/TwoColumnLetter6.php
@@ -2,7 +2,7 @@
33
44 class PayflowProGateway_Form_TwoColumnLetter6 extends PayflowProGateway_Form_OneStepTwoColumn {
55
6 - public function __construct( &$form_data, &$form_errors ) {
 6+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
77 global $wgScriptPath;
88
99 // set the path to css, before the parent constructor is called, checking to make sure some child class hasn't already set this
@@ -10,7 +10,7 @@
1111 $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoColumnLetter6.css' );
1212 }
1313
14 - parent::__construct( $form_data, $form_errors );
 14+ parent::__construct( $form_data, $form_errors, $gateway );
1515 }
1616
1717 public function generateFormStart() {
@@ -79,7 +79,7 @@
8080 }
8181
8282 protected function generateBillingFields() {
83 - global $wgScriptPath, $wgPayflowGatewayPaypalURL, $wgRequest;
 83+ global $wgScriptPath, $wgRequest;
8484 $scriptPath = "$wgScriptPath/extensions/DonationInterface/payflowpro_gateway/includes";
8585
8686 $form = '';
@@ -130,17 +130,17 @@
131131 $form .= '<tr>';
132132 $form .= '<td class="label">' . wfMsg( 'payflowpro_gateway-payment-type' ) . '</td>';
133133 $form .= '<td>' .
134 - Xml::radio( 'card', 'cc1', $this->form_data['card'] == 'cc1', array( 'id' => 'cc1radio', 'onclick' => 'switchToCreditCard()' ) ) . '<label for="cc1radio">' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-visa.png" ) ). '</label>' .
135 - Xml::radio( 'card', 'cc2', $this->form_data['card'] == 'cc2', array( 'id' => 'cc2radio', 'onclick' => 'switchToCreditCard()' ) ) . '<label for="cc2radio">' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-mastercard.png" ) ). '</label>' .
136 - Xml::radio( 'card', 'cc3', $this->form_data['card'] == 'cc3', array( 'id' => 'cc3radio', 'onclick' => 'switchToCreditCard()' ) ) . '<label for="cc3radio">' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-amex.png" ) ). '</label>' .
137 - Xml::radio( 'card', 'cc4', $this->form_data['card'] == 'cc4', array( 'id' => 'cc4radio', 'onclick' => 'switchToCreditCard()' ) ) . '<label for="cc4radio">' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-discover.png" ) ). '</label>' .
138 - Xml::radio( 'card', 'pp', $this->form_data['card'] == 'pp', array( 'id' => 'ppradio', 'onclick' => 'switchToPayPal()' ) ) . '<label for="ppradio">' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-paypal.png" ) ) . '</label>' .
 134+ Xml::radio( 'card_type', 'cc1', $this->form_data['card_type'] == 'cc1', array( 'id' => 'cc1radio', 'onclick' => 'switchToCreditCard()' ) ) . '<label for="cc1radio">' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-visa.png" ) ). '</label>' .
 135+ Xml::radio( 'card_type', 'cc2', $this->form_data['card_type'] == 'cc2', array( 'id' => 'cc2radio', 'onclick' => 'switchToCreditCard()' ) ) . '<label for="cc2radio">' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-mastercard.png" ) ). '</label>' .
 136+ Xml::radio( 'card_type', 'cc3', $this->form_data['card_type'] == 'cc3', array( 'id' => 'cc3radio', 'onclick' => 'switchToCreditCard()' ) ) . '<label for="cc3radio">' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-amex.png" ) ). '</label>' .
 137+ Xml::radio( 'card_type', 'cc4', $this->form_data['card_type'] == 'cc4', array( 'id' => 'cc4radio', 'onclick' => 'switchToCreditCard()' ) ) . '<label for="cc4radio">' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-discover.png" ) ). '</label>' .
 138+ Xml::radio( 'card_type', 'pp', $this->form_data['card_type'] == 'pp', array( 'id' => 'ppradio', 'onclick' => 'switchToPayPal()' ) ) . '<label for="ppradio">' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-paypal.png" ) ) . '</label>' .
139139 '</td>';
140140 $form .= '</tr>';
141141
142142 $form .= '</table>';
143143
144 - if ( $this->form_data['card'] == 'cc1' || $this->form_data['card'] == 'cc2' || $this->form_data['card'] == 'cc3' || $this->form_data['card'] == 'cc4' ) {
 144+ if ( $this->form_data['card_type'] == 'cc1' || $this->form_data['card_type'] == 'cc2' || $this->form_data['card_type'] == 'cc3' || $this->form_data['card_type'] == 'cc4' ) {
145145 $form .= Xml::openElement( 'table', array( 'id' => 'payflow-table-cc' ) );
146146 } else {
147147 $form .= Xml::openElement( 'table', array( 'id' => 'payflow-table-cc', 'style' => 'display: none;' ) );
@@ -202,7 +202,7 @@
203203 public function generateFormSubmit() {
204204
205205 // cc submit button
206 - if ( $this->form_data['card'] == 'cc1' || $this->form_data['card'] == 'cc2' || $this->form_data['card'] == 'cc3' || $this->form_data['card'] == 'cc4' ) {
 206+ if ( $this->form_data['card_type'] == 'cc1' || $this->form_data['card_type'] == 'cc2' || $this->form_data['card_type'] == 'cc3' || $this->form_data['card_type'] == 'cc4' ) {
207207 $form = Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-form-submit' ) );
208208 } else {
209209 $form = Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-form-submit', 'style' => 'display: none;' ) );
@@ -216,7 +216,7 @@
217217 $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-form-submit
218218
219219 // paypal submit button
220 - if ( $this->form_data['card'] == 'cc1' || $this->form_data['card'] == 'cc2' || $this->form_data['card'] == 'cc3' || $this->form_data['card'] == 'cc4' ) {
 220+ if ( $this->form_data['card_type'] == 'cc1' || $this->form_data['card_type'] == 'cc2' || $this->form_data['card_type'] == 'cc3' || $this->form_data['card_type'] == 'cc4' ) {
221221 $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-form-submit-paypal', 'style' => 'display: none;' ) );
222222 } else {
223223 $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-form-submit-paypal' ) );
Index: trunk/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnLetter.php
@@ -1,7 +1,7 @@
22 <?php
33
44 class PayflowProGateway_Form_TwoStepTwoColumnLetter extends PayflowProGateway_Form_TwoStepTwoColumn {
5 - public function __construct( &$form_data, &$form_errors ) {
 5+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
66 global $wgScriptPath;
77
88 // set the path to css, before the parent constructor is called, checking to make sure some child class hasn't already set this
@@ -9,7 +9,7 @@
1010 $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoStepTwoColumnLetter.css' );
1111 }
1212
13 - parent::__construct( $form_data, $form_errors );
 13+ parent::__construct( $form_data, $form_errors, $gateway );
1414 }
1515
1616 public function generateFormStart() {
Index: trunk/extensions/DonationInterface/gateway_forms/TwoColumnLetter7.php
@@ -2,7 +2,7 @@
33
44 class PayflowProGateway_Form_TwoColumnLetter7 extends PayflowProGateway_Form_OneStepTwoColumn {
55
6 - public function __construct( &$form_data, &$form_errors ) {
 6+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
77 global $wgScriptPath;
88
99 // set the path to css, before the parent constructor is called, checking to make sure some child class hasn't already set this
@@ -10,7 +10,7 @@
1111 $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoColumnLetter7.css' );
1212 }
1313
14 - parent::__construct( $form_data, $form_errors );
 14+ parent::__construct( $form_data, $form_errors, $gateway );
1515 }
1616
1717 public function loadPlaceholders() {
@@ -192,7 +192,7 @@
193193 }
194194
195195 protected function generateBillingFields() {
196 - global $wgScriptPath, $wgPayflowGatewayPaypalURL, $wgRequest;
 196+ global $wgScriptPath, $wgRequest;
197197 $scriptPath = "$wgScriptPath/extensions/DonationInterface/payflowpro_gateway/includes";
198198
199199 $form = '';
@@ -249,20 +249,20 @@
250250 $form .= '<td class="label""><div style="padding-top:9px;">' . wfMsg( 'payflowpro_gateway-payment-type' ) . '</div></td>';
251251 $form .= '<td>' .
252252 '<p style="border: 1px solid rgb(187, 187, 187); float: left; -moz-border-radius: 5px 5px 5px 5px; margin: 0 8px 0 0; padding: 5px 5px 5px 3px; white-space: nowrap;">'.
253 - Xml::radio( 'card', 'cc1', $this->form_data['card'] == 'cc1', array( 'id' => 'cc1radio', 'onclick' => 'switchToCreditCard()' ) ) . '<label for="cc1radio">' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-visa.png" ) ). '</label>' .
 253+ Xml::radio( 'card_type', 'cc1', $this->form_data['card_type'] == 'cc1', array( 'id' => 'cc1radio', 'onclick' => 'switchToCreditCard()' ) ) . '<label for="cc1radio">' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-visa.png" ) ). '</label>' .
254254 '&#160;<label for="cc1radio">' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-mastercard.png" ) ). '</label>' .
255255 '&#160;<label for="cc1radio">' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-amex.png" ) ). '</label>' .
256256 '&#160;<label for="cc1radio">' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-discover.png" ) ). '</label>' .
257257 '</p>'.
258258 '<p style="border: 1px solid transparent; float: left; -moz-border-radius: 5px 5px 5px 5px; margin: 0; padding: 5px 5px 5px 3px; white-space: nowrap;">'.
259 - Xml::radio( 'card', 'pp', $this->form_data['card'] == 'pp', array( 'id' => 'ppradio', 'onclick' => 'switchToPayPal()' ) ) . '<label for="ppradio">' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-paypal.png" ) ) . '</label>' .
 259+ Xml::radio( 'card_type', 'pp', $this->form_data['card_type'] == 'pp', array( 'id' => 'ppradio', 'onclick' => 'switchToPayPal()' ) ) . '<label for="ppradio">' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-paypal.png" ) ) . '</label>' .
260260 '</p>'.
261261 '</td>';
262262 $form .= '</tr>';
263263
264264 $form .= '</table>';
265265
266 - if ( $this->form_data['card'] == 'cc1' || $this->form_data['card'] == 'cc2' || $this->form_data['card'] == 'cc3' || $this->form_data['card'] == 'cc4' ) {
 266+ if ( $this->form_data['card_type'] == 'cc1' || $this->form_data['card_type'] == 'cc2' || $this->form_data['card_type'] == 'cc3' || $this->form_data['card_type'] == 'cc4' ) {
267267 $form .= Xml::openElement( 'table', array( 'id' => 'payflow-table-cc' ) );
268268 } else {
269269 $form .= Xml::openElement( 'table', array( 'id' => 'payflow-table-cc', 'style' => 'display: none;' ) );
@@ -360,7 +360,7 @@
361361 global $wgScriptPath;
362362
363363 // cc submit button
364 - if ( $this->form_data['card'] == 'cc1' || $this->form_data['card'] == 'cc2' || $this->form_data['card'] == 'cc3' || $this->form_data['card'] == 'cc4' ) {
 364+ if ( $this->form_data['card_type'] == 'cc1' || $this->form_data['card_type'] == 'cc2' || $this->form_data['card_type'] == 'cc3' || $this->form_data['card_type'] == 'cc4' ) {
365365 $form = Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-form-submit' ) );
366366 } else {
367367 $form = Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-form-submit', 'style' => 'display: none;' ) );
@@ -374,7 +374,7 @@
375375 $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-form-submit
376376
377377 // paypal submit button
378 - if ( $this->form_data['card'] == 'cc1' || $this->form_data['card'] == 'cc2' || $this->form_data['card'] == 'cc3' || $this->form_data['card'] == 'cc4' ) {
 378+ if ( $this->form_data['card_type'] == 'cc1' || $this->form_data['card_type'] == 'cc2' || $this->form_data['card_type'] == 'cc3' || $this->form_data['card_type'] == 'cc4' ) {
379379 $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-form-submit-paypal', 'style' => 'display: none;' ) );
380380 } else {
381381 $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-form-submit-paypal' ) );
Index: trunk/extensions/DonationInterface/gateway_forms/TwoColumnPayPal.php
@@ -1,8 +1,8 @@
22 <?php
33
44 class PayflowProGateway_Form_TwoColumnPayPal extends PayflowProGateway_Form_OneStepTwoColumn {
5 - public function __construct( &$form_data, &$form_errors ) {
6 - parent::__construct( $form_data, $form_errors );
 5+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
 6+ parent::__construct( $form_data, $form_errors, $gateway );
77 }
88
99 public function generateFormStart() {
@@ -58,7 +58,6 @@
5959 }
6060
6161 protected function generatePersonalFields() {
62 - global $wgPayflowGatewayPaypalURL;
6362 $form = '';
6463
6564 // name
@@ -83,7 +82,7 @@
8483 $form .= $this->getAmountField();
8584
8685 // PayPal button
87 - if ( strlen( $wgPayflowGatewayPaypalURL ) ) {
 86+ if ( strlen( $this->gateway->getGlobal( "PaypalURL" ) ) ) {
8887 $form .= $this->getPaypalButton();
8988 }
9089
Index: trunk/extensions/DonationInterface/gateway_forms/SingleColumn.php
@@ -2,7 +2,7 @@
33
44 class PayflowProGateway_Form_SingleColumn extends PayflowProGateway_Form_TwoColumnLetter {
55
6 - public function __construct( &$form_data, &$form_errors ) {
 6+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
77 global $wgScriptPath;
88
99 // set the path to css, before the parent constructor is called, checking to make sure some child class hasn't already set this
@@ -10,7 +10,7 @@
1111 $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/SingleColumn.css' );
1212 }
1313
14 - parent::__construct( $form_data, $form_errors );
 14+ parent::__construct( $form_data, $form_errors, $gateway );
1515 }
1616
1717 public function generateFormEnd() {
Index: trunk/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnLetterCA.php
@@ -1,7 +1,7 @@
22 <?php
33
44 class PayflowProGateway_Form_TwoStepTwoColumnLetterCA extends PayflowProGateway_Form_TwoStepTwoColumn {
5 - public function __construct( &$form_data, &$form_errors ) {
 5+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
66 global $wgScriptPath;
77
88 // set the path to css, before the parent constructor is called, checking to make sure some child class hasn't already set this
@@ -9,7 +9,7 @@
1010 $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoStepTwoColumnLetter.css' );
1111 }
1212
13 - parent::__construct( $form_data, $form_errors );
 13+ parent::__construct( $form_data, $form_errors, $gateway );
1414 }
1515
1616 public function generateFormStart() {
Index: trunk/extensions/DonationInterface/gateway_forms/Form.php
@@ -49,12 +49,13 @@
5050 */
5151 abstract function getForm();
5252
53 - public function __construct( &$data, &$error ) {
54 - global $wgPayflowGatewayTest, $wgOut;
 53+ public function __construct( &$data, &$error, &$gateway ) {
 54+ global $wgOut;
5555
56 - $this->test = $wgPayflowGatewayTest;
57 - $this->form_data =& $data;
58 - $this->form_errors =& $error;
 56+ $this->gateway = & $gateway;
 57+ $this->test = $this->gateway->getGlobal( "Test" );
 58+ $this->form_data = & $data;
 59+ $this->form_errors = & $error;
5960
6061 /**
6162 * add form-specific css - the path can be set in child classes
@@ -72,7 +73,7 @@
7374 * We do this here (rather than in individual forms) because if OWA is
7475 * enabled, we ALWAYS want to make sure it gets included.
7576 */
76 - if(defined('OWA')){
 77+ if ( defined( 'OWA' ) ) {
7778 $this->loadOwaJs();
7879 }
7980
@@ -100,7 +101,7 @@
101102 global $wgScriptPath;
102103 if ( !$style_path ) {
103104 // load the default form CSS if the style path not explicitly set
104 - $style_path = $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/Form.css';
 105+ $style_path = $wgScriptPath . '/extensions/DonationInterface/gateway_forms/css/Form.css';
105106 }
106107 $this->style_path = $style_path;
107108 }
@@ -134,14 +135,6 @@
135136 }
136137
137138 /**
138 - * Fetch the array of iso country codes => country names
139 - * @return array
140 - */
141 - public function getCountries() {
142 - return PayflowProGateway::getCountries();
143 - }
144 -
145 - /**
146139 * Generate the menu select of countries
147140 * @fixme It would be great if we could default the country to the user's locale
148141 * @fixme We should also do a locale-based asort on the country dropdown
@@ -152,8 +145,8 @@
153146 $country_options = '';
154147
155148 // create a new array of countries with potentially translated country names for alphabetizing later
156 - foreach ( $this->getCountries() as $iso_value => $full_name ) {
157 - $countries[ $iso_value ] = wfMsg( 'payflowpro_gateway-country-dropdown-' . $iso_value );
 149+ foreach ( GatewayForm::getCountries() as $iso_value => $full_name ) {
 150+ $countries[$iso_value] = wfMsg( 'payflowpro_gateway-country-dropdown-' . $iso_value );
158151 }
159152
160153 // alphabetically sort the country names
@@ -161,8 +154,8 @@
162155
163156 // generate a dropdown option for each country
164157 foreach ( $countries as $iso_value => $full_name ) {
165 - if ( $this->form_data[ 'country' ] ) {
166 - $selected = ( $iso_value == $this->form_data[ 'country' ] ) ? true : false;
 158+ if ( $this->form_data['country'] ) {
 159+ $selected = ( $iso_value == $this->form_data['country'] ) ? true : false;
167160 } else {
168161 $selected = ( $iso_value == $defaultCountry ) ? true : false; // Select default
169162 }
@@ -202,7 +195,7 @@
203196 // generate a dropdown opt for each card
204197 foreach ( $available_cards as $value => $card_name ) {
205198 // only load the card value if we're in testing mode
206 - $selected = ( $value == $this->form_data[ 'card' ] && $this->test ) ? true : false;
 199+ $selected = ( $value == $this->form_data['card_type'] && $this->test ) ? true : false;
207200 $card_options .= Xml::option( $card_name, $value, $selected );
208201 }
209202
@@ -224,8 +217,8 @@
225218
226219 // derive the previously set expiry month, if set
227220 $month = NULL;
228 - if ( $this->form_data[ 'expiration' ] ) {
229 - $month = substr( $this->form_data[ 'expiration' ], 0, 2 );
 221+ if ( $this->form_data['expiration'] ) {
 222+ $month = substr( $this->form_data['expiration'], 0, 2 );
230223 }
231224
232225 $expiry_months = '';
@@ -253,8 +246,8 @@
254247 public function generateExpiryYearDropdown() {
255248 // derive the previously set expiry year, if set
256249 $year = NULL;
257 - if ( $this->form_data[ 'expiration' ] ) {
258 - $year = substr( $this->form_data[ 'expiration' ], 2, 2 );
 250+ if ( $this->form_data['expiration'] ) {
 251+ $year = substr( $this->form_data['expiration'], 2, 2 );
259252 }
260253
261254 $expiry_years = '';
@@ -292,7 +285,7 @@
293286
294287 // generate dropdown of state opts
295288 foreach ( $states as $value => $state_name ) {
296 - $selected = ( $this->form_data[ 'state' ] == $value ) ? true : false;
 289+ $selected = ( $this->form_data['state'] == $value ) ? true : false;
297290 $state_opts .= Xml::option( wfMsg( 'payflowpro_gateway-state-dropdown-' . $value ), $value, $selected );
298291 }
299292
@@ -330,7 +323,7 @@
331324
332325 // generate dropdown of currency opts
333326 foreach ( $available_currencies as $value => $currency_name ) {
334 - $selected = ( $this->form_data[ 'currency' ] == $value ) ? true : false;
 327+ $selected = ( $this->form_data['currency'] == $value ) ? true : false;
335328 $currency_opts .= Xml::option( wfMsg( 'donate_interface-' . $value ), $value, $selected );
336329 }
337330
@@ -355,28 +348,29 @@
356349 */
357350 public function setHiddenFields( $hidden_fields = NULL ) {
358351 if ( !$hidden_fields ) {
359 - $hidden_fields = array(
360 - 'utm_source' => $this->form_data[ 'utm_source' ],
361 - 'utm_medium' => $this->form_data[ 'utm_medium' ],
362 - 'utm_campaign' => $this->form_data[ 'utm_campaign' ],
363 - 'language' => $this->form_data[ 'language' ],
364 - 'referrer' => $this->form_data[ 'referrer' ],
365 - 'comment' => $this->form_data[ 'comment' ],
366 - 'comment-option' => $this->form_data[ 'comment-option' ],
367 - 'email-opt' => $this->form_data[ 'email-opt' ],
368 - 'size' => $this->form_data[ 'size' ],
369 - 'premium_language' => $this->form_data[ 'premium_language' ],
370 - 'process' => 'CreditCard',
 352+ $hidden_fields = array(
 353+ 'utm_source' => $this->form_data['utm_source'],
 354+ 'utm_medium' => $this->form_data['utm_medium'],
 355+ 'utm_campaign' => $this->form_data['utm_campaign'],
 356+ 'language' => $this->form_data['language'],
 357+ 'referrer' => $this->form_data['referrer'],
 358+ 'comment' => $this->form_data['comment'],
 359+ 'comment-option' => $this->form_data['comment-option'],
 360+ 'email-opt' => $this->form_data['email-opt'],
 361+ 'size' => $this->form_data['size'],
 362+ 'premium_language' => $this->form_data['premium_language'],
 363+ 'process' => isset( $this->form_data['process'] ) ? $this->form_data['process'] : 'CreditCard',
371364 'payment_method' => 'processed',
372 - 'token' => $this->form_data[ 'token' ],
373 - 'order_id' => $this->form_data[ 'order_id' ],
374 - 'i_order_id' => $this->form_data[ 'i_order_id' ],
375 - 'numAttempt' => $this->form_data[ 'numAttempt' ],
376 - 'contribution_tracking_id' => $this->form_data[ 'contribution_tracking_id' ],
377 - 'data_hash' => $this->form_data[ 'data_hash' ],
378 - 'action' => $this->form_data[ 'action' ],
379 - 'owa_session' => $this->form_data[ 'owa_session' ],
380 - 'owa_ref' => $this->form_data[ 'owa_ref' ],
 365+ 'token' => $this->form_data['token'],
 366+ 'order_id' => $this->form_data['order_id'],
 367+ 'i_order_id' => $this->form_data['i_order_id'],
 368+ 'numAttempt' => $this->form_data['numAttempt'],
 369+ 'contribution_tracking_id' => $this->form_data['contribution_tracking_id'],
 370+ 'data_hash' => $this->form_data['data_hash'],
 371+ 'action' => $this->form_data['action'],
 372+ 'owa_session' => $this->form_data['owa_session'],
 373+ 'owa_ref' => $this->form_data['owa_ref'],
 374+ 'transaction_type' => isset( $this->form_data['transaction_type'] ) ? $this->form_data['transaction_type'] : '',
381375 );
382376 }
383377
@@ -422,15 +416,17 @@
423417 }
424418
425419 protected function generateBannerHeader() {
426 - global $wgPayflowGatewayHeader, $wgOut, $wgRequest;
 420+ global $wgOut, $wgRequest;
 421+ $g = $this->gateway;
 422+ $header = $g::getGlobal( 'Header' );
427423
428424 $template = '';
429425
430426 // intro text
431427 if ( $wgRequest->getText( 'masthead', false ) ) {
432 - $template = $wgOut->parse( '{{' . $wgRequest->getText( 'masthead' ) . '/' . $this->form_data[ 'language' ] . '}}' );
433 - } elseif ( $wgPayflowGatewayHeader ) {
434 - $header = str_replace( '@language', $this->form_data[ 'language' ], $wgPayflowGatewayHeader );
 428+ $template = $wgOut->parse( '{{' . $wgRequest->getText( 'masthead' ) . '/' . $this->form_data['language'] . '}}' );
 429+ } elseif ( $header ) {
 430+ $header = str_replace( '@language', $this->form_data['language'], $header );
435431 $template = $wgOut->parse( $header );
436432 }
437433
@@ -467,30 +463,29 @@
468464 $form .= '<td class="label">' . Xml::label( wfMsg( 'payflowpro_gateway-donor-amount' ), 'amount' ) . '</td>';
469465 $form .= '<td>' . Xml::radio( 'amount', 100, $this->form_data['amount'] == 100 ) . '100 ' .
470466 Xml::radio( 'amount', 50, $this->form_data['amount'] == 50 ) . '50 ' .
471 - Xml::radio( 'amount', 35, $this->form_data['amount'] == 35 ) . '35 ' .
 467+ Xml::radio( 'amount', 35, $this->form_data['amount'] == 35 ) . '35 ' .
472468 Xml::radio( 'amount', 20, $this->form_data['amount'] == 20 ) . '20 ' .
473469 '</td>';
474470 $form .= '</tr>';
475471 $form .= '<tr>';
476472 $form .= '<td class="label"></td>';
477 - $form .= '<td>' . Xml::radio( 'amount', $amount, $otherChecked, array( 'id' => 'otherRadio' ) ) . Xml::input( 'amountOther', '7', $this->form_data['amountOther'], array( 'type' => 'text', 'onfocus' => 'clearField( this, \''.wfMsg( 'payflowpro_gateway-other' ).'\' )', 'onblur' => 'document.getElementById("otherRadio").value = this.value;if (this.value > 0) document.getElementById("otherRadio").checked=true;', 'maxlength' => '10', 'id' => 'amountOther' ) ) .
 473+ $form .= '<td>' . Xml::radio( 'amount', $amount, $otherChecked, array( 'id' => 'otherRadio' ) ) . Xml::input( 'amountOther', '7', $this->form_data['amountOther'], array( 'type' => 'text', 'onfocus' => 'clearField( this, \'' . wfMsg( 'payflowpro_gateway-other' ) . '\' )', 'onblur' => 'document.getElementById("otherRadio").value = this.value;if (this.value > 0) document.getElementById("otherRadio").checked=true;', 'maxlength' => '10', 'id' => 'amountOther' ) ) .
478474 ' ' . $this->generateCurrencyDropdown() . '</td>';
479475 $form .= '</tr>';
480476 return $form;
481477 }
482478
483479 protected function getCardnumberField() {
484 - global $wgPayflowGatewayTest;
485 - $card_num = ( $wgPayflowGatewayTest ) ? $this->form_data[ 'card_num' ] : '';
 480+ $card_num = ( $this->gateway->getGlobal( "Test" ) ) ? $this->form_data['card_num'] : '';
486481 $form = '';
487482 if ( $this->form_errors['card_num'] ) {
488483 $form .= '<tr>';
489484 $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['card_num'] . '</span></td>';
490485 $form .= '</tr>';
491486 }
492 - if ( $this->form_errors['card'] ) {
 487+ if ( $this->form_errors['card_type'] ) {
493488 $form .= '<tr>';
494 - $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['card'] . '</span></td>';
 489+ $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['card_type'] . '</span></td>';
495490 $form .= '</tr>';
496491 }
497492 $form .= '<tr>';
@@ -502,8 +497,7 @@
503498 }
504499
505500 protected function getCvvField() {
506 - global $wgPayflowGatewayTest;
507 - $cvv = ( $wgPayflowGatewayTest ) ? $this->form_data[ 'cvv' ] : '';
 501+ $cvv = ( $this->gateway->getGlobal( "Test" ) ) ? $this->form_data['cvv'] : '';
508502
509503 $form = '<tr>';
510504 $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['cvv'] . '</span></td>';
@@ -561,8 +555,8 @@
562556 $form .= '</tr>';
563557 $form .= '<tr>';
564558 $form .= '<td class="label">' . Xml::label( wfMsg( 'payflowpro_gateway-donor-name' ), 'fname' ) . '</td>';
565 - $form .= '<td>' . Xml::input( 'fname', '30', $this->form_data['fname'], array( 'type' => 'text', 'onfocus' => 'clearField( this, \''.wfMsg( 'payflowpro_gateway-donor-fname' ).'\' )', 'maxlength' => '25', 'class' => 'required', 'id' => 'fname' ) ) .
566 - Xml::input( 'lname', '30', $this->form_data['lname'], array( 'type' => 'text', 'onfocus' => 'clearField( this, \''.wfMsg( 'payflowpro_gateway-donor-lname' ).'\' )', 'maxlength' => '25', 'id' => 'lname' ) ) . '</td>';
 559+ $form .= '<td>' . Xml::input( 'fname', '30', $this->form_data['fname'], array( 'type' => 'text', 'onfocus' => 'clearField( this, \'' . wfMsg( 'payflowpro_gateway-donor-fname' ) . '\' )', 'maxlength' => '25', 'class' => 'required', 'id' => 'fname' ) ) .
 560+ Xml::input( 'lname', '30', $this->form_data['lname'], array( 'type' => 'text', 'onfocus' => 'clearField( this, \'' . wfMsg( 'payflowpro_gateway-donor-lname' ) . '\' )', 'maxlength' => '25', 'id' => 'lname' ) ) . '</td>';
567561 $form .= "</tr>";
568562 return $form;
569563 }
@@ -570,7 +564,7 @@
571565 protected function getCommentMessageField() {
572566 $form = '<tr>';
573567 $form .= '<td colspan="2">';
574 - $form .= Xml::tags( 'p', array(), wfMsg( 'donate_interface-comment-message' ) );
 568+ $form .= Xml::tags( 'p', array( ), wfMsg( 'donate_interface-comment-message' ) );
575569 $form .= '</td>';
576570 $form .= '</tr>';
577571 return $form;
@@ -579,14 +573,14 @@
580574 protected function getCommentField() {
581575 $form = '<tr>';
582576 $form .= '<td class="label">' . Xml::label( wfMsg( 'payflowpro_gateway-comment' ), 'comment' ) . '</td>';
583 - $form .= '<td>' . Xml::input( 'comment', '30', $this->form_data[ 'comment' ], array( 'type' => 'text', 'maxlength' => '200', 'class' => 'fullwidth' ) ) . '</td>';
 577+ $form .= '<td>' . Xml::input( 'comment', '30', $this->form_data['comment'], array( 'type' => 'text', 'maxlength' => '200', 'class' => 'fullwidth' ) ) . '</td>';
584578 $form .= '</tr>';
585579 return $form;
586580 }
587581
588582 protected function getCommentOptionField() {
589583 global $wgRequest;
590 - $comment_opt_value = ( $wgRequest->wasPosted() ) ? $this->form_data[ 'comment-option' ] : true;
 584+ $comment_opt_value = ( $wgRequest->wasPosted() ) ? $this->form_data['comment-option'] : true;
591585 $form = '<tr>';
592586 $form .= '<td class="check-option" colspan="2">' . Xml::check( 'comment-option', $comment_opt_value );
593587 $form .= ' ' . Xml::label( wfMsg( 'donate_interface-anon-message' ), 'comment-option' ) . '</td>';
@@ -596,7 +590,7 @@
597591
598592 protected function getEmailOptField() {
599593 global $wgRequest;
600 - $email_opt_value = ( $wgRequest->wasPosted() ) ? $this->form_data[ 'email-opt' ] : true;
 594+ $email_opt_value = ( $wgRequest->wasPosted() ) ? $this->form_data['email-opt'] : true;
601595 $form = '<tr>';
602596 $form .= '<td class="check-option" colspan="2">' . Xml::check( 'email-opt', $email_opt_value );
603597 $form .= ' ';
@@ -616,10 +610,8 @@
617611 $form = '<tr>';
618612 $form .= '<td class="paypal-button" colspan="2">';
619613 $form .= Html::hidden( 'PaypalRedirect', false );
620 - $form .= Xml::tags( 'div',
621 - array(),
622 - '<a href="#" onclick="document.payment.PaypalRedirect.value=\'true\';document.payment.submit();"><img src="' . $scriptPath . '/donate_with_paypal.gif"/></a>'
623 - );
 614+ $form .= Xml::tags( 'div', array( ), '<a href="#" onclick="document.payment.PaypalRedirect.value=\'true\';document.payment.submit();"><img src="' . $scriptPath . '/donate_with_paypal.gif"/></a>'
 615+ );
624616 $form .= '</td>';
625617 $form .= '</tr>';
626618 return $form;
@@ -643,13 +635,13 @@
644636 $form .= '<tr>';
645637 $form .= '<td class="label">' . Xml::label( wfMsg( 'payflowpro_gateway-donor-country' ), 'country' ) . '</td>';
646638 $form .= '<td>' . $this->generateCountryDropdown( $defaultCountry ) . '</td>';
647 - $form .= '</tr>';
648 - return $form;
 639+ $form .= '</tr>';
 640+ return $form;
649641 }
650642
651643 protected function getCreditCardTypeField() {
652644 $form = '<tr>';
653 - $form .= '<td class="label">' . Xml::label( wfMsg( 'payflowpro_gateway-donor-card' ), 'card' ) . '</td>';
 645+ $form .= '<td class="label">' . Xml::label( wfMsg( 'payflowpro_gateway-donor-card' ), 'card_type' ) . '</td>';
654646 $form .= '<td>' . $this->generateCardDropdown() . '</td>';
655647 $form .= '</tr>';
656648 return $form;
@@ -675,32 +667,31 @@
676668
677669 protected function loadOwaJs() {
678670 global $wgOut, $wgScriptPath;
679 - $wgOut->addHeadItem('owa_tracker', '<script type="text/javascript" src="https://owa.wikimedia.org/owa/modules/base/js/owa.tracker-combined-min.js"></script>');
680 -
 671+ $wgOut->addHeadItem( 'owa_tracker', '<script type="text/javascript" src="https://owa.wikimedia.org/owa/modules/base/js/owa.tracker-combined-min.js"></script>' );
 672+
681673 $wgOut->addHeadItem( 'owa_get_info', '<script type="text/javascript" src="' .
682 - $wgScriptPath .
683 - '/extensions/DonationInterface/payflowpro_gateway/owa_get_info.js?284"></script>' );
 674+ $wgScriptPath .
 675+ '/extensions/DonationInterface/payflowpro_gateway/owa_get_info.js?284"></script>' );
684676 $wgOut->addHeadItem( 'owa_tracker_init', '<script type="text/javascript" src="' .
685 - $wgScriptPath .
686 - '/extensions/DonationInterface/payflowpro_gateway/owa.tracker-combined-min.js?284"></script>' );
687 -
 677+ $wgScriptPath .
 678+ '/extensions/DonationInterface/payflowpro_gateway/owa.tracker-combined-min.js?284"></script>' );
688679 }
689680
690 -
691681 /**
692682 * Generate HTML for <noscript> tags
693683 *
694684 * For displaying when a user does not have Javascript enabled in their browser.
695685 */
696686 protected function getNoScript() {
697 - global $wgPayflowGatewayNoScriptRedirect;
 687+ $g = $this->gateway;
 688+ $noScriptRedirect = $g::getGlobal( 'NoScriptRedirect' );
698689
699690 $form = '<noscript>';
700691 $form .= '<div id="noscript">';
701692 $form .= '<p id="noscript-msg">' . wfMsg( 'payflowpro_gateway-noscript-msg' ) . '</p>';
702 - if ( $wgPayflowGatewayNoScriptRedirect ) {
 693+ if ( $noScriptRedirect ) {
703694 $form .= '<p id="noscript-redirect-msg">' . wfMsg( 'payflowpro_gateway-noscript-redirect-msg' ) . '</p>';
704 - $form .= '<p id="noscript-redirect-link"><a href="' . $wgPayflowGatewayNoScriptRedirect . '">' . $wgPayflowGatewayNoScriptRedirect . '</a></p>';
 695+ $form .= '<p id="noscript-redirect-link"><a href="' . $noScriptRedirect . '">' . $noScriptRedirect . '</a></p>';
705696 }
706697 $form .= '</div>';
707698 $form .= '</noscript>';
@@ -720,21 +711,22 @@
721712
722713 $url = $wgRequest->getFullRequestURL();
723714 $url_parts = wfParseUrl( $url );
724 - if ( isset( $url_parts[ 'query' ] ) ) {
725 - $query_array = wfCgiToArray( $url_parts[ 'query' ] );
 715+ if ( isset( $url_parts['query'] ) ) {
 716+ $query_array = wfCgiToArray( $url_parts['query'] );
726717 } else {
727 - $query_array = array();
 718+ $query_array = array( );
728719 }
729720
730721 // ensure that _cache_ does not get set in the URL
731 - unset( $query_array[ '_cache_' ] );
 722+ unset( $query_array['_cache_'] );
732723
733724 // make sure no other data that might overwrite posted data makes it into the URL
734725 foreach ( $this->form_data as $key => $value ) {
735 - unset( $query_array[ $key ] );
 726+ unset( $query_array[$key] );
736727 }
737728
738729 // construct the submission url
739730 return wfAppendQuery( $wgTitle->getLocalURL(), $query_array );
740731 }
 732+
741733 }
Index: trunk/extensions/DonationInterface/gateway_forms/TwoColumnLetter.php
@@ -3,7 +3,7 @@
44 class PayflowProGateway_Form_TwoColumnLetter extends PayflowProGateway_Form_OneStepTwoColumn {
55 public $paypal = false; // true for paypal only version
66
7 - public function __construct( &$form_data, &$form_errors ) {
 7+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
88 global $wgScriptPath;
99
1010 // set the path to css, before the parent constructor is called, checking to make sure some child class hasn't already set this
@@ -11,7 +11,7 @@
1212 $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoColumnLetter.css' );
1313 }
1414
15 - parent::__construct( $form_data, $form_errors );
 15+ parent::__construct( $form_data, $form_errors, $gateway );
1616 }
1717
1818 public function generateFormStart() {
@@ -82,7 +82,7 @@
8383 }
8484
8585 protected function generateBillingFields() {
86 - global $wgScriptPath, $wgPayflowGatewayPaypalURL;
 86+ global $wgScriptPath;
8787 $scriptPath = "$wgScriptPath/extensions/DonationInterface/payflowpro_gateway/includes";
8888
8989 $form = '';
@@ -111,7 +111,7 @@
112112 if ( !$this->paypal ) {
113113 // PayPal button
114114 // make sure we have a paypal url set to redirect the user to before displaying the button
115 - if ( strlen( $wgPayflowGatewayPaypalURL ) ) {
 115+ if ( strlen( $this->gateway->getGlobal( "PaypalURL" ) ) ) {
116116 $form .= '<tr>';
117117 $form .= '<td class="label"></td>';
118118 $form .= '<td class="paypal-button">';
Index: trunk/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnPremium.php
@@ -1,7 +1,7 @@
22 <?php
33
44 class PayflowProGateway_Form_TwoStepTwoColumnPremium extends PayflowProGateway_Form_TwoStepTwoColumn {
5 - public function __construct( &$form_data, &$form_errors ) {
 5+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
66 global $wgScriptPath;
77
88 // set the path to css, before the parent constructor is called, checking to make sure some child class hasn't already set this
@@ -9,7 +9,7 @@
1010 $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoStepTwoColumnPremium.css' );
1111 }
1212
13 - parent::__construct( $form_data, $form_errors );
 13+ parent::__construct( $form_data, $form_errors, $gateway );
1414 }
1515
1616 public function generateFormStart() {
Index: trunk/extensions/DonationInterface/gateway_forms/TwoStepTwoColumn.php
@@ -2,13 +2,12 @@
33
44 class PayflowProGateway_Form_TwoStepTwoColumn extends PayflowProGateway_Form {
55
6 - public function __construct( &$form_data, &$form_errors ) {
 6+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
77 global $wgOut;
88
 9+ parent::__construct( $form_data, $form_errors, $gateway );
910 // load validation and placeholder JS
1011 $this->loadPlaceholders();
11 -
12 - parent::__construct( $form_data, $form_errors );
1312 }
1413
1514 public function loadPlaceholders() {
Index: trunk/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnLetter2.php
@@ -1,7 +1,7 @@
22 <?php
33
44 class PayflowProGateway_Form_TwoStepTwoColumnLetter2 extends PayflowProGateway_Form_TwoStepTwoColumnLetter {
5 - public function __construct( &$form_data, &$form_errors ) {
 5+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
66 global $wgScriptPath;
77
88 // set the path to css, before the parent constructor is called, checking to make sure some child class hasn't already set this
@@ -9,6 +9,6 @@
1010 $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoStepTwoColumnLetter2.css' );
1111 }
1212
13 - parent::__construct( $form_data, $form_errors );
 13+ parent::__construct( $form_data, $form_errors, $gateway );
1414 }
1515 }
Index: trunk/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnLetter3.php
@@ -1,15 +1,15 @@
22 <?php
33
44 class PayflowProGateway_Form_TwoStepTwoColumnLetter3 extends PayflowProGateway_Form_TwoStepTwoColumn {
5 - public function __construct( &$form_data, &$form_errors ) {
6 - global $wgScriptPath;
 5+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
 6+ global $wgExtensionAssetsPath;
77
88 // set the path to css, before the parent constructor is called, checking to make sure some child class hasn't already set this
99 if ( !strlen( $this->getStylePath() ) ) {
10 - $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoStepTwoColumnLetter3.css' );
 10+ $this->setStylePath( $wgExtensionAssetsPath . '/DonationInterface/gateway_forms/css/TwoStepTwoColumnLetter3.css' );
1111 }
1212 $this->loadvalidateJs();
13 - parent::__construct( $form_data, $form_errors );
 13+ parent::__construct( $form_data, $form_errors, $gateway );
1414 }
1515
1616 public function loadPlaceholders() {
@@ -189,7 +189,7 @@
190190 }
191191
192192 protected function generateBillingFields() {
193 - global $wgScriptPath, $wgPayflowGatewayTest;
 193+ global $wgScriptPath;
194194
195195 $form = '';
196196
@@ -234,16 +234,16 @@
235235 $form .= '</tr>';
236236
237237 // card number
238 - $card_num = ( $wgPayflowGatewayTest ) ? $this->form_data[ 'card_num' ] : '';
 238+ $card_num = ( $this->gateway->getGlobal( "Test" ) ) ? $this->form_data[ 'card_num' ] : '';
239239 $form .= '';
240240 if ( $this->form_errors['card_num'] ) {
241241 $form .= '<tr>';
242242 $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['card_num'] . '</span></td>';
243243 $form .= '</tr>';
244244 }
245 - if ( $this->form_errors['card'] ) {
 245+ if ( $this->form_errors['card_type'] ) {
246246 $form .= '<tr>';
247 - $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['card'] . '</span></td>';
 247+ $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['card_type'] . '</span></td>';
248248 $form .= '</tr>';
249249 }
250250 $form .= '<tr>';
@@ -355,7 +355,7 @@
356356 }
357357
358358 public function generateStateDropdown() {
359 - require_once( dirname( __FILE__ ) . '/../includes/stateAbbreviations.inc' );
 359+ require_once( dirname( __FILE__ ) . '/includes/stateAbbreviations.inc' );
360360
361361 $states = statesMenuXML();
362362
Index: trunk/extensions/DonationInterface/gateway_forms/RapidHtml.php
@@ -1,13 +1,13 @@
22 <?php
33
44 class PayflowProGateway_Form_RapidHtml extends PayflowProGateway_Form {
5 -
 5+
66 /**
77 * Full path of HTML form to load
88 * @var string
99 */
1010 protected $html_file_path = '';
11 -
 11+
1212 /**
1313 * Tokens used in HTML form for data replacement
1414 *
@@ -28,7 +28,7 @@
2929 '@zip', // => $wgRequest->getText( 'zip' ),
3030 '@country', // => $wgRequest->getText( 'country' ),
3131 '@card_num', // => str_replace( ' ', '', $wgRequest->getText( 'card_num' ) ),
32 - '@card', // => $wgRequest->getText( 'card' ),
 32+ '@card_type', // => $wgRequest->getText( 'card_type' ),
3333 '@expiration', // => $wgRequest->getText( 'mos' ) . substr( $wgRequest->getText( 'year' ), 2, 2 ),
3434 '@cvv', // => $wgRequest->getText( 'cvv' ),
3535 '@currency_code', //'currency' => $wgRequest->getText( 'currency_code' ),
@@ -57,7 +57,7 @@
5858 // @script_path -> maps to $wgScriptPath
5959 // @action -> generate correct form action for this form
6060 );
61 -
 61+
6262 /**
6363 * Error field names used as tokens
6464 * @var array
@@ -67,7 +67,7 @@
6868 '#retryMsg',
6969 '#amount',
7070 '#card_num',
71 - '#card',
 71+ '#card_type',
7272 '#cvv',
7373 '#fname',
7474 '#lname',
@@ -78,10 +78,10 @@
7979 '#zip',
8080 '#emailAdd',
8181 );
82 -
83 - public function __construct( &$form_data, &$form_errors ) {
 82+
 83+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
8484 global $wgRequest;
85 - parent::__construct( $form_data, $form_errors );
 85+ parent::__construct( $form_data, $form_errors, $gateway );
8686
8787 $country = $wgRequest->getText( 'country', '' );
8888
@@ -100,18 +100,18 @@
101101 }
102102
103103 // fix general form error messages so it's not an array of msgs
104 - if ( is_array( $form_errors[ 'general' ] ) && count( $form_errors[ 'general' ] )) {
 104+ if ( is_array( $form_errors['general'] ) && count( $form_errors['general'] ) ) {
105105 $general_errors = "";
106 - foreach ( $form_errors[ 'general' ] as $general_error ) {
 106+ foreach ( $form_errors['general'] as $general_error ) {
107107 $general_errors .= "<p class='creditcard'>$general_error</p>";
108108 }
109 - $form_errors[ 'general' ] = $general_errors;
 109+ $form_errors['general'] = $general_errors;
110110 }
111111
112112 // if this form needs to support squid cacheing, handle the magic
113113 $this->handle_cacheability();
114114 }
115 -
 115+
116116 /**
117117 * Return the HTML form with data added
118118 */
@@ -119,7 +119,7 @@
120120 $html = $this->load_html();
121121 return $this->add_data( $html );
122122 }
123 -
 123+
124124 /**
125125 * Load the HTML form from a file into a string
126126 * @return string
@@ -127,7 +127,7 @@
128128 public function load_html() {
129129 return file_get_contents( $this->html_file_path );
130130 }
131 -
 131+
132132 /**
133133 * Add data into the HTML form
134134 *
@@ -175,12 +175,12 @@
176176
177177 // handle captcha
178178 $form = str_replace( "@captcha", $this->getCaptchaHtml(), $form );
179 -
 179+
180180 // handle script path
181181 $form = str_replace( "@script_path", $wgScriptPath, $form );
182 -
 182+
183183 $form = $this->fix_dropdowns( $form );
184 -
 184+
185185 return $form;
186186 }
187187
@@ -196,84 +196,78 @@
197197 // currency code
198198 $start = strpos( $html, 'name="currency_code"' );
199199 if ( $start ) {
200 - $currency_code = $this->form_data[ 'currency' ];
 200+ $currency_code = $this->form_data['currency'];
201201 $end = strpos( $html, '</select>', $start );
202 - $str = substr( $html, $start, ( $end - $start ));
 202+ $str = substr( $html, $start, ( $end - $start ) );
203203 $str = str_replace( 'value="' . $currency_code . '"', 'value="' . $currency_code . '" selected="selected"', $str );
204 - $html = substr_replace( $html, $str, $start, $end-$start );
 204+ $html = substr_replace( $html, $str, $start, $end - $start );
205205 }
206 -
 206+
207207 // mos
208 - $month = substr( $this->form_data[ 'expiration' ], 0, 2 );
 208+ $month = substr( $this->form_data['expiration'], 0, 2 );
209209 $start = strpos( $html, 'name="mos"' );
210210 if ( $start ) {
211211 $end = strpos( $html, '</select>', $start );
212 - $str = substr( $html, $start, ( $end - $start ));
 212+ $str = substr( $html, $start, ( $end - $start ) );
213213 $str = str_replace( 'value="' . $month . '"', 'value="' . $month . '" selected="selected"', $str );
214 - $html = substr_replace( $html, $str, $start, $end-$start );
 214+ $html = substr_replace( $html, $str, $start, $end - $start );
215215 }
216 -
 216+
217217 // year
218 - $year = substr( $this->form_data[ 'expiration' ], 2, 2 );
 218+ $year = substr( $this->form_data['expiration'], 2, 2 );
219219 $start = strpos( $html, 'name="year"' );
220 - if ( $start ) {
 220+ if ( $start ) {
221221 $end = strpos( $html, '</select>', $start );
222 - $str = substr( $html, $start, ( $end - $start ));
 222+ $str = substr( $html, $start, ( $end - $start ) );
223223 // dbl extra huge hack alert! note the '20' prefix...
224224 $str = str_replace( 'value="20' . $year . '"', 'value="20' . $year . '" selected="selected"', $str );
225 - $html = substr_replace( $html, $str, $start, $end-$start );
 225+ $html = substr_replace( $html, $str, $start, $end - $start );
226226 }
227 -
 227+
228228 // state
229 - $state = $this->form_data[ 'state' ];
 229+ $state = $this->form_data['state'];
230230 $start = strpos( $html, 'name="state"' );
231231 if ( $start ) {
232232 $end = strpos( $html, '</select>', $start );
233 - $str = substr( $html, $start, ( $end - $start ));
 233+ $str = substr( $html, $start, ( $end - $start ) );
234234 $str = str_replace( 'value="' . $state . '"', 'value="' . $state . '" selected="selected"', $str );
235 - $html = substr_replace( $html, $str, $start, $end-$start );
 235+ $html = substr_replace( $html, $str, $start, $end - $start );
236236 }
237 -
 237+
238238 //country
239 - $country = $this->form_data[ 'country' ];
 239+ $country = $this->form_data['country'];
240240 $start = strpos( $html, 'name="country"' );
241241 if ( $start ) {
242242 $end = strpos( $html, '</select>', $start );
243 - $str = substr( $html, $start, ( $end - $start ));
 243+ $str = substr( $html, $start, ( $end - $start ) );
244244 $str = str_replace( 'value="' . $country . '"', 'value="' . $country . '" selected="selected"', $str );
245 - $html = substr_replace( $html, $str, $start, $end-$start );
 245+ $html = substr_replace( $html, $str, $start, $end - $start );
246246 }
247 -
 247+
248248 return $html;
249249 }
250 -
 250+
251251 /**
252252 * Validate and set the path to the HTML file
253253 *
254254 * @param string $file_name
255255 */
256256 public function set_html_file_path( $file_name ) {
257 - global $wgPayflowHtmlFormDir, $wgPayflowAllowedHtmlForms;
 257+ //This ONE TIME, this is okay, because we actually want to compare to the default HTML form dir as well.
 258+ global $wgDonationInterfaceHtmlFormDir;
258259
259 - // Get the dirname - the "/." helps ensure we get a consistent path name with no trailing slash
260 - $html_dir = dirname( $wgPayflowHtmlFormDir . "/." );
261 -
262 - if ( !is_dir( $html_dir )) {
263 - throw new MWException( 'Requested form directory does not exist.' );
264 - }
265 -
266 - // make sure our file name is clean - strip extension and any other cruft like relpaths, dirs, etc
267 - $file_info = pathinfo( $file_name );
268 - $file_name = $file_info[ 'filename' ];
269 -
270 - $full_path = $html_dir . '/' . $file_name . '.html';
271 -
272 - // ensure that the full file path is actually whitelisted and exists
273 - if ( !in_array( $full_path, $wgPayflowAllowedHtmlForms ) || !file_exists( $full_path ) ) {
 260+ $g = $this->gateway;
 261+ $gatewayFormDir = $g::getGlobal( 'HtmlFormDir' );
 262+ $allowedForms = $g::getGlobal( 'AllowedHtmlForms' );
 263+
 264+ if ( !array_key_exists( $file_name, $allowedForms ) ||
 265+ ((strpos( $allowedForms[$file_name], $gatewayFormDir ) === false) && (strpos( $allowedForms[$file_name], $wgDonationInterfaceHtmlFormDir ) === false)) ||
 266+ (!file_exists( $allowedForms[$file_name] )) ) {
 267+
274268 throw new MWException( 'Requested an unavailable or non-existent form.' );
275269 }
276 -
277 - $this->html_file_path = $full_path;
 270+
 271+ $this->html_file_path = $allowedForms[$file_name];
278272 }
279273
280274 /**
Index: trunk/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnPremiumUS.php
@@ -1,7 +1,7 @@
22 <?php
33
44 class PayflowProGateway_Form_TwoStepTwoColumnPremiumUS extends PayflowProGateway_Form_TwoStepTwoColumn {
5 - public function __construct( &$form_data, &$form_errors ) {
 5+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
66 global $wgScriptPath;
77
88 // set the path to css, before the parent constructor is called, checking to make sure some child class hasn't already set this
@@ -9,7 +9,7 @@
1010 $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoStepTwoColumnPremiumUS.css' );
1111 }
1212
13 - parent::__construct( $form_data, $form_errors );
 13+ parent::__construct( $form_data, $form_errors, $gateway );
1414 }
1515
1616 public function loadPlaceholders() {
@@ -174,7 +174,7 @@
175175 }
176176
177177 protected function generateBillingFields() {
178 - global $wgScriptPath, $wgPayflowGatewayTest;
 178+ global $wgScriptPath;
179179
180180 $form = '';
181181
@@ -216,16 +216,16 @@
217217 $form .= '</tr>';
218218
219219 // card number
220 - $card_num = ( $wgPayflowGatewayTest ) ? $this->form_data[ 'card_num' ] : '';
 220+ $card_num = ( $this->gateway->getGlobal( "Test" ) ) ? $this->form_data[ 'card_num' ] : '';
221221 $form .= '';
222222 if ( $this->form_errors['card_num'] ) {
223223 $form .= '<tr>';
224224 $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['card_num'] . '</span></td>';
225225 $form .= '</tr>';
226226 }
227 - if ( $this->form_errors['card'] ) {
 227+ if ( $this->form_errors['card_type'] ) {
228228 $form .= '<tr>';
229 - $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['card'] . '</span></td>';
 229+ $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['card_type'] . '</span></td>';
230230 $form .= '</tr>';
231231 }
232232 $form .= '<tr>';
Index: trunk/extensions/DonationInterface/gateway_forms/OneStepTwoColumn.php
@@ -3,10 +3,10 @@
44 class PayflowProGateway_Form_OneStepTwoColumn extends PayflowProGateway_Form {
55 public $paypal = false; // true for paypal only version
66
7 - public function __construct( &$form_data, &$form_errors ) {
 7+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
88 global $wgOut;
99
10 - parent::__construct( $form_data, $form_errors );
 10+ parent::__construct( $form_data, $form_errors, $gateway );
1111
1212 // update the list of hidden fields we need to use in this form.
1313 $this->updateHiddenFields();
@@ -192,14 +192,14 @@
193193 }
194194
195195 protected function generateBannerHeader() {
196 - global $wgPayflowGatewayHeader, $wgOut, $wgRequest;
 196+ global $wgOut, $wgRequest;
197197 $template = '';
198198
199199 // intro text
200200 if ( $wgRequest->getText( 'masthead', false ) ) {
201201 $template = $wgOut->parse( '{{' . $wgRequest->getText( 'masthead' ) . '/' . $this->form_data[ 'language' ] . '}}' );
202 - } elseif ( $wgPayflowGatewayHeader ) {
203 - $header = str_replace( '@language', $this->form_data[ 'language' ], $wgPayflowGatewayHeader );
 202+ } elseif ( $this->gateway->getGlobal( "Header" ) ) {
 203+ $header = str_replace( '@language', $this->form_data[ 'language' ], $this->gateway->getGlobal( "Header" ) );
204204 $template = $wgOut->parse( $header );
205205 }
206206
Property changes on: trunk/extensions/DonationInterface/gateway_forms
___________________________________________________________________
Added: svn:mergeinfo
207207 Merged /branches/fundraising/extensions/DonationInterface/gateway_forms:r95724-100157

Status & tagging log