r73128 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73127‎ | r73128 | r73129 >
Date:17:21, 16 September 2010
Author:awjrichards
Status:deferred
Tags:
Comment:
Added mechanism for variably displaying different credit card forms; Ported old CC form to use new mechanism; Added new credit card form and CSS; Updated payflowpro 'extras' to use new form generation mechanism where necessary
Modified paths:
  • /trunk/extensions/DonationInterface/payflowpro_gateway/extras/recaptcha/recaptcha.body.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/forms (added) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/forms/Form.php (added) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumn.php (added) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumnLetter.php (added) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/forms/css (added) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoColumnLetter.css (added) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php
@@ -23,6 +23,14 @@
2424 public $payflow_response = array();
2525
2626 /**
 27+ * A container for the form class
 28+ *
 29+ * Used to loard the form object to display the CC form
 30+ * @var object
 31+ */
 32+ public $form_class;
 33+
 34+ /**
2735 * Constructor - set up the new special page
2836 */
2937 public function __construct() {
@@ -166,8 +174,8 @@
167175 *
168176 * The message at the top of the form can be edited in the payflow_gateway.i18.php file
169177 */
170 - public function fnPayflowDisplayForm( $data, &$error ) {
171 - global $wgOut, $wgRequest, $wgPayflowGatewayDefaultForm;
 178+ public function fnPayflowDisplayForm( &$data, &$error ) {
 179+ global $wgOut;
172180
173181 // save contrib tracking id early to track abondonment
174182 if ( $data[ 'numAttempt' ] == '0' ) {
@@ -177,25 +185,52 @@
178186 }
179187 }
180188
181 - $form_class = ( strlen( $wgRequest->getText( 'form_name' ))) ? $wgRequest->getText( 'form_name' ) : $wgPayflowGatewayDefaultForm;
 189+ $form_class = $this->getFormClass();
 190+ $form_obj = new $form_class( $data, $error );
 191+ $form = $form_obj->generateFormBody();
 192+ $form .= $form_obj->generateFormSubmit();
 193+ $wgOut->addHTML( $form );
 194+ }
 195+
 196+ /**
 197+ * Set the form class to use to generate the CC form
 198+ *
 199+ * @param string $class_name The class name of the form to use
 200+ */
 201+ public function setFormClass( $class_name=NULL ) {
 202+ if ( !$class_name ) {
 203+ global $wgRequest, $wgPayflowGatewayDefaultForm;
 204+ $form_class = ( strlen( $wgRequest->getText( 'form_name' ))) ? $wgRequest->getText( 'form_name' ) : $wgPayflowGatewayDefaultForm;
182205
183 - // make sure our form class exists before going on, if not try loading default form class
184 - $class_name = "PayflowProGateway_Form_" . $form_class;
185 - if ( !class_exists( $class_name )) {
186 - $class_name_orig = $class_name;
187 - $class_name = "PayflowProGateway_Form_" . $wgPayflowGatewayDefaultForm;
 206+ // make sure our form class exists before going on, if not try loading default form class
 207+ $class_name = "PayflowProGateway_Form_" . $form_class;
188208 if ( !class_exists( $class_name )) {
189 - throw new MWException( 'Could not load form ' . $class_name_orig . ' nor default form ' . $class_name );
 209+ $class_name_orig = $class_name;
 210+ $class_name = "PayflowProGateway_Form_" . $wgPayflowGatewayDefaultForm;
 211+ if ( !class_exists( $class_name )) {
 212+ throw new MWException( 'Could not load form ' . $class_name_orig . ' nor default form ' . $class_name );
 213+ }
190214 }
191215 }
192216
193 - $form_obj = new $class_name( $data, $error );
194 - $form = $form_obj->generateFormBody();
195 - $form .= $form_obj->generateFormSubmit();
196 - $wgOut->addHTML( $form );
 217+ $this->form_class = $class_name;
197218 }
198219
199220 /**
 221+ * Get the currently set form class
 222+ *
 223+ * Will set the form class if the form class not already set
 224+ * Using logic in setFormClass()
 225+ * @return string
 226+ */
 227+ public function getFormClass( ) {
 228+ if ( !isset( $this->form_class )) {
 229+ $this->setFormClass();
 230+ }
 231+ return $this->form_class;
 232+ }
 233+
 234+ /**
200235 * Checks posted form data for errors and returns array of messages
201236 */
202237 private function fnPayflowValidateForm( $data, &$error ) {
Index: trunk/extensions/DonationInterface/payflowpro_gateway/extras/recaptcha/recaptcha.body.php
@@ -50,7 +50,9 @@
5151 $recap_err = ( $error[ 'recap_err' ] ) ? $error[ 'recap_err' ] : NULL;
5252
5353 global $wgOut;
54 - $form = $pfp_gateway_object->fnPayflowGenerateFormBody( $data, $error );
 54+ $form_class = $pfp_gateway_object->getFormClass();
 55+ $form_obj = new $form_class( $data, $error );
 56+ $form = $form_obj->generateFormBody( $data, $error );
5557 $form .= Xml::openElement( 'div', array( 'id' => 'mw-donate-captcha' ));
5658
5759 // get the captcha
@@ -59,7 +61,7 @@
6062 $form .= recaptcha_get_html( $wgPayflowRecaptchaPublicKey, $recap_err, $use_ssl );
6163 $form .= '<span class="creditcard-error-msg">' . wfMsg( 'payflowpro_gateway-error-msg-captcha-please') . '</span>';
6264 $form .= Xml::closeElement( 'div' );
63 - $form .= $pfp_gateway_object->fnPayflowGenerateFormSubmit( $data, $error );
 65+ $form .= $form_obj->generateFormSubmit( $data, $error );
6466 $wgOut->addHTML( $form );
6567 }
6668
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoColumnLetter.css
@@ -0,0 +1,23 @@
 2+.payflow-cc-form-section {
 3+ float: none;
 4+}
 5+
 6+#payflowpro_gateway-personal-info {
 7+ margin-right: 0em;
 8+ margin-bottom: 3em;
 9+}
 10+
 11+#payflowpro_gateway-cc_form_container {
 12+ width: 100%;
 13+}
 14+
 15+.payflowpro_gateway-cc_form_column {
 16+ float: left;
 17+}
 18+
 19+#payflowpro_gateway-cc_form_letter {
 20+ width: 40%;
 21+ margin-right: 5em;
 22+ padding-right: 5em;
 23+ border-right: 1px solid #BBBBBB;
 24+}
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/Form.php
@@ -0,0 +1,270 @@
 2+<?php
 3+
 4+abstract class PayflowProGateway_Form {
 5+
 6+ /**
 7+ * Defines if we are in test mode
 8+ * @var bool
 9+ */
 10+ public $test = false;
 11+
 12+ /**
 13+ * An array of hidden fields, name => value
 14+ * @var array
 15+ */
 16+ public $hidden_fields;
 17+
 18+ /**
 19+ * An array of form data, passed from the payflow pro object
 20+ * @var array
 21+ */
 22+ public $form_data;
 23+
 24+ /**
 25+ * An array of form errors, passed from the payflow pro object
 26+ * @var array
 27+ */
 28+ public $form_errors;
 29+
 30+ abstract public function generateFormBody();
 31+ abstract public function generateFormSubmit();
 32+
 33+ public function __construct( &$data, &$error ) {
 34+ global $wgPayflowGatewayTest;
 35+
 36+ $this->test = $wgPayflowGatewayTest;
 37+ $this->form_data =& $data;
 38+ $this->form_errors =& $error;
 39+ }
 40+
 41+ /**
 42+ * Fetch the array of iso country codes => country names
 43+ * @return array
 44+ */
 45+ public function getCountries() {
 46+ require_once( dirname( __FILE__ ) . '/../includes/countryCodes.inc' );
 47+ return countryCodes();
 48+ }
 49+
 50+ /**
 51+ * Generate the menu select of countries
 52+ * @return string
 53+ */
 54+ public function generateCountryDropdown() {
 55+ $country_options = '';
 56+
 57+ // generate a dropdown option for each country
 58+ foreach ( $this->getCountries() as $iso_value => $full_name ) {
 59+ $selected = ( $iso_value == $this->form_data[ 'country' ] ) ? true : false;
 60+ $country_options .= Xml::option( $full_name, $iso_value, $selected );
 61+ }
 62+
 63+ // build the actual select
 64+ $country_menu = Xml::openElement(
 65+ 'select',
 66+ array(
 67+ 'name' => 'country',
 68+ 'id' => 'country',
 69+ 'onchange' => 'return disableStates( this )'
 70+ ));
 71+ $country_menu .= $country_options;
 72+ $country_menu .= Xml::closeElement( 'select' );
 73+
 74+ return $country_menu;
 75+ }
 76+
 77+ /**
 78+ * Genereat the menu select of credit cards
 79+ *
 80+ * @fixme Abstract out the setting of avaiable cards
 81+ * @return string
 82+ */
 83+ public function generateCardDropdown() {
 84+ $available_cards = array(
 85+ 'visa' => wfMsg( 'payflow_gateway-card-name-visa' ),
 86+ 'mastercard' => wfMsg( 'payflow_gateway-card-name-mc' ),
 87+ 'american' => wfMsg( 'payflow_gateway-card-name-amex' ),
 88+ 'discover' => wfMsg( 'payflow_gateway-card-name-discover' ),
 89+ );
 90+
 91+ $card_options = '';
 92+
 93+ // generate a dropdown opt for each card
 94+ foreach ( $available_cards as $value => $card_name ) {
 95+ // only load the card value if we're in testing mode
 96+ $selected = ( $value == $this->form_data[ 'card' ] && $this->test ) ? true : false;
 97+ $card_options .= Xml::option( $card_name, $value, $selected );
 98+ }
 99+
 100+ // build the actual select
 101+ $card_menu = Xml::openElement(
 102+ 'select',
 103+ array(
 104+ 'name' => 'card',
 105+ 'id' => 'card'
 106+ ));
 107+ $card_menu .= $card_options;
 108+ $card_menu .= Xml::closeElement( 'select' );
 109+
 110+ return $card_menu;
 111+ }
 112+
 113+ public function generateExpiryMonthDropdown() {
 114+ global $wgLang;
 115+
 116+ // derive the previously set expiry month, if set
 117+ if ( $this->form_data[ 'expiration' ] ) {
 118+ $month = substr( $this->form_data[ 'expiration' ], 0, 2 );
 119+ }
 120+
 121+ $expiry_months = '';
 122+
 123+ // generate a dropdown opt for each month
 124+ for ( $i = 1; $i < 13; $i++ ) {
 125+ $selected = ( $i == $month && $this->test ) ? true : false;
 126+ $expiry_months .= Xml::option(
 127+ $wgLang->getMonthName( $i ),
 128+ str_pad( $i, 2, '0', STR_PAD_LEFT ),
 129+ $selected );
 130+ }
 131+
 132+ $expiry_month_menu = Xml::openElement(
 133+ 'select',
 134+ array(
 135+ 'name' => 'mos',
 136+ 'id' => 'expiration'
 137+ ));
 138+ $expiry_month_menu .= $expiry_months;
 139+ $expiry_month_menu .= Xml::closeElement( 'select' );
 140+ return $expiry_month_menu;
 141+ }
 142+
 143+ public function generateExpiryYearDropdown() {
 144+ // derive the previously set expiry year, if set
 145+ if ( $this->form_data[ 'expiration' ] ) {
 146+ $year = substr( $this->form_data[ 'expiration' ], 2, 2 );
 147+ }
 148+
 149+ $expiry_years = '';
 150+
 151+ // generate a dropdown of year opts
 152+ for ( $i = 0; $i < 11; $i++ ) {
 153+ $selected = ( date( 'Y' ) + $i == substr( date( 'Y' ), 0, 2 ) . $year
 154+ && $this->test ) ? true : false;
 155+ $expiry_years .= Xml::option( date( 'Y' ) + $i, date( 'Y' ) + $i, $selected );
 156+ }
 157+
 158+ $expiry_year_menu = Xml::openElement(
 159+ 'select',
 160+ array(
 161+ 'name' => 'year',
 162+ 'id' => 'year',
 163+ ));
 164+ $expiry_year_menu .= $expiry_years;
 165+ $expiry_year_menu .= Xml::closeElement( 'select' );
 166+ return $expiry_year_menu;
 167+ }
 168+
 169+ public function generateStateDropdown() {
 170+ require_once( dirname( __FILE__ ) . '/../includes/stateAbbreviations.inc' );
 171+
 172+ $states = statesMenuXML();
 173+
 174+ $state_opts = '';
 175+
 176+ // generate dropdown of state opts
 177+ foreach ( $states as $value => $state_name ) {
 178+ $selected = ( $this->form_data[ 'state' ] == $value ) ? true : false;
 179+ $state_opts .= Xml::option( $state_name, $value, $selected );
 180+ }
 181+
 182+ $state_menu = Xml::openElement(
 183+ 'select',
 184+ array(
 185+ 'name' => 'state',
 186+ 'id' => 'state'
 187+ ));
 188+ $state_menu .= $state_opts;
 189+ $state_menu .= Xml::closeElement( 'select' );
 190+
 191+ return $state_menu;
 192+ }
 193+
 194+ public function generateCurrencyDropdown() {
 195+ var_dump( $this->form_data );
 196+ $available_currencies = array(
 197+ 'GBP' => 'GBP: British Pound',
 198+ 'EUR' => 'EUR: Euro',
 199+ 'USD' => 'USD: U.S. Dollar',
 200+ 'AUD' => 'AUD: Australian Dollar',
 201+ 'CAD' => 'CAD: Canadian Dollar',
 202+ 'JPY' => 'JPY: Japanese Yen'
 203+ );
 204+
 205+ $currency_opts = '';
 206+
 207+ // generate dropdown of currency opts
 208+ foreach ( $available_currencies as $value => $currency_name ) {
 209+ $selected = ( $this->form_data[ 'currency' ] == $value ) ? true : false;
 210+ $currency_opts .= Xml::option( wfMsg( 'donate_interface-' . $value ), $value, $selected );
 211+ }
 212+
 213+ $currency_menu = Xml::openElement(
 214+ 'select',
 215+ array(
 216+ 'name' => 'currency_code',
 217+ 'id' => 'input_currency_code'
 218+ ));
 219+ $currency_menu .= $currency_opts;
 220+ $currency_menu .= Xml::closeElement( 'select' );
 221+
 222+ return $currency_menu;
 223+ }
 224+
 225+ /**
 226+ * Set the hidden field array
 227+ *
 228+ * If you pass nothing in, we'll set the fields for you.
 229+ * @param array $hidden_fields
 230+ */
 231+ public function setHiddenFields( $hidden_fields=NULL ) {
 232+ if ( !$hidden_fields ) {
 233+ global $wgRequest;
 234+
 235+ $hidden_fields = array(
 236+ 'utm_source' => $this->form_data[ 'utm_source' ] . $wgRequest->getText( 'utm_source_id' ),
 237+ 'utm_medium' => $this->form_data[ 'utm_medium' ],
 238+ 'utm_campaign' => $this->form_data[ 'utm_campaign' ],
 239+ 'language' => $this->form_data[ 'language' ],
 240+ 'referrer' => $this->form_data[ 'referrer' ],
 241+ 'comment' => $this->form_data[ 'comment' ],
 242+ 'comment-option' => $this->form_data[ 'anonymous' ],
 243+ 'email' => $this->form_data[ 'optout' ],
 244+ 'process' => 'CreditCard',
 245+ 'payment_method' => 'processed',
 246+ 'token' => $this->form_data[ 'token' ],
 247+ 'orderid' => $this->form_data[ 'order_id' ],
 248+ 'numAttempt' => $this->form_data[ 'numAttempt' ],
 249+ 'contribution_tracking_id' => $this->form_data[ 'contribution_tracking_id' ],
 250+ 'data_hash' => $this->form_data[ 'data_hash' ],
 251+ 'action' => $this->form_data[ 'action' ],
 252+ );
 253+ }
 254+
 255+ $this->hidden_fields = $hidden_fields;
 256+ }
 257+
 258+ /**
 259+ * Gets an array of the hidden fields for the form
 260+ *
 261+ * @return array
 262+ */
 263+ public function getHiddenFields() {
 264+ if ( !isset( $this->hidden_fields )) {
 265+ $this->setHiddenFields();
 266+ }
 267+ return $this->hidden_fields;
 268+ }
 269+
 270+
 271+}
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumn.php
@@ -0,0 +1,225 @@
 2+<?php
 3+
 4+class PayflowProGateway_Form_TwoColumn extends PayflowProGateway_Form {
 5+
 6+ public function __construct( &$form_data, &$form_errors ) {
 7+ parent::__construct( $form_data, $form_errors );
 8+ }
 9+
 10+ public function generateFormBody() {
 11+ global $wgPayflowGatewayHeader, $wgPayflwGatewayTest, $wgOut;
 12+
 13+ $form .= $this->generateBannerHeader();
 14+
 15+ $form .= $this->generatePersonalContainerTop();
 16+ $form .= $this->generatePersonalFields();
 17+
 18+ $form .= Xml::closeElement( 'table' );
 19+ $form .= Xml::closeElement( 'div' );
 20+
 21+ $form .= $this->generatePaymentContainerTop();
 22+ $form .= $this->generatePaymentFields();
 23+
 24+ $form .= Xml::closeElement( 'table' );
 25+ return $form;
 26+ }
 27+
 28+ public function generateFormSubmit() {
 29+ // submit button and close form
 30+ $form = Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-form-submit'));
 31+ $form .= Xml::openElement( 'div', array( 'id' => 'mw-donate-submit-button' )) .
 32+ Xml::submitButton( wfMsg( 'payflowpro_gateway-submit-button' ));
 33+ $form .= Xml::closeElement( 'div' );
 34+ $form .= Xml::openElement( 'div', array( 'class' => 'mw-donate-submessage', 'id' => 'payflowpro_gateway-donate-submessage' ) ) .
 35+ wfMsg( 'payflowpro_gateway-donate-click' );
 36+ $form .= Xml::closeElement( 'div' );
 37+ $form .= Xml::closeElement( 'div' );
 38+ $form .= Xml::closeElement( 'div' );
 39+ $form .= Xml::openElement( 'div', array( 'class' => 'payflow-cc-form-section', 'id' => 'payflowpro_gateway-donate-addl-info' ));
 40+ $form .= Xml::tags( 'p', array( 'class' => '' ),
 41+ wfMsg( 'payflowpro_gateway-credit-storage-processing' ) ) .
 42+ Xml::tags( 'p', array( 'class' => ''),
 43+ wfMsg( 'payflowpro_gateway-question-comment' ) );
 44+ $form .= Xml::closeElement( 'div' );
 45+
 46+ // add hidden fields
 47+ $hidden_fields = $this->getHiddenFields();
 48+ foreach ( $hidden_fields as $field => $value ) {
 49+ $form .= Xml::hidden( $field, $value );
 50+ }
 51+
 52+ $form .= Xml::closeElement( 'form' ) .
 53+ Xml::closeElement( 'div' ) .
 54+ Xml::closeElement( 'div' );
 55+ return $form;
 56+ }
 57+
 58+ protected function generateBannerHeader() {
 59+ global $wgPayflowGatewayHeader, $wgOut;
 60+ // intro text
 61+ if ( $wgPayflowGatewayHeader ) {
 62+ $header = str_replace( '@language', $this->form_data['language'], $wgPayflowGatewayHeader );
 63+ $wgOut->addHtml( $wgOut->parse( $header ));
 64+ }
 65+ }
 66+
 67+ protected function generatePersonalContainerTop() {
 68+ $form = Xml::openElement( 'div', array( 'id' => 'mw-creditcard' ) ); /*.
 69+ Xml::openElement( 'div', array( 'id' => 'mw-creditcard-intro' ) ) .
 70+ Xml::tags( 'p', array( 'class' => 'mw-creditcard-intro-msg' ), wfMsg( 'payflowpro_gateway-form-message' ) ) .
 71+ Xml::closeElement( 'div' );*/
 72+
 73+ // provide a place at the top of the form for displaying general messages
 74+ if ( $this->form_errors['general'] ) {
 75+ $form .= Xml::openElement( 'div', array( 'id' => 'mw-payflow-general-error' ));
 76+ if ( is_array( $this->form_errors['general'] )) {
 77+ foreach ( $this->form_errors['general'] as $this->form_errors_msg ) {
 78+ $form .= Xml::tags( 'p', array( 'class' => 'creditcard-error-msg' ), $this->form_errors_msg );
 79+ }
 80+ } else {
 81+ $form .= Xml::tags( 'p', array( 'class' => 'creditcard-error-msg' ), $this->form_errors_msg );
 82+ }
 83+ $form .= Xml::closeElement( 'div' );
 84+ }
 85+
 86+ // open form and table
 87+ $form .= Xml::openElement( 'div', array( 'id' => 'mw-creditcard-form' ) ) .
 88+ Xml::element( 'p', array( 'class' => 'creditcard-error-msg' ), $this->form_errors['retryMsg'] );
 89+ $form .= Xml::openElement( 'form', array( 'name' => 'payment', 'method' => 'post', 'action' => '', 'onsubmit' => 'return validate_form(this)', 'autocomplete' => 'off' ) );
 90+ $form .= Xml::openElement( 'div', array( 'class' => 'payflow-cc-form-section', 'id' => 'payflowpro_gateway-personal-info' )); ;
 91+ $form .= Xml::tags( 'h3', array( 'class' => 'payflow-cc-form-header','id' => 'payflow-cc-form-header-personal' ), wfMsg( 'payflowpro_gateway-cc-form-header-personal' ));
 92+ $form .= Xml::openElement( 'table', array( 'id' => 'payflow-table-donor' ) );
 93+
 94+ return $form;
 95+ }
 96+
 97+ protected function generatePersonalFields() {
 98+ // first name
 99+ $form .= '<tr>';
 100+ $form .= '<td>' . Xml::label( wfMsg( 'payflowpro_gateway-donor-fname' ), 'fname' ) . '</td>';
 101+ $form .= '<td>' . Xml::input( 'fname', '30', $this->form_data['fname'], array( 'maxlength' => '15', 'class' => 'required', 'id' => 'fname' ) ) .
 102+ '<span class="creditcard-error-msg">' . ' ' . $this->form_errors['fname'] . '</span></td>';
 103+ $form .= "</tr>";
 104+
 105+ /*// middle name
 106+ $form .= '<tr>';
 107+ $form .= '<td>' . Xml::label( wfMsg( 'payflowpro_gateway-donor-mname' ), 'mname' ) . '</td>';
 108+ $form .= '<td>' . Xml::input( 'mname', '30', $this->form_data['mname'], array( 'maxlength' => '15', 'id' => 'mname' ) ) . '</td>';
 109+ $form .= '</tr>';
 110+ */
 111+
 112+ // last name
 113+ $form .= '<tr>';
 114+ $form .= '<td>' . Xml::label( wfMsg( 'payflowpro_gateway-donor-lname' ), 'lname' ) . '</td>';
 115+ $form .= '<td>' . Xml::input( 'lname', '30', $this->form_data['lname'], array( 'maxlength' => '15', 'id' => 'lname' ) ) .
 116+ '<span class="creditcard-error-msg">' . ' ' . $this->form_errors['lname'] . '</span>' . '</td>';
 117+ $form .= '</tr>';
 118+
 119+ // country
 120+ $form .= '<tr>';
 121+ $form .= '<td>' . Xml::label( wfMsg( 'payflowpro_gateway-donor-country' ), 'country' ) . '</td>';
 122+ $form .= '<td>' . $this->generateCountryDropdown() . '<span class="creditcard-error-msg">' . ' ' . $this->form_errors['country'] . '</span></td>';
 123+ $form .= '</tr>';
 124+
 125+ // street
 126+ $form .= '<tr>';
 127+ $form .= '<td>' . Xml::label( wfMsg( 'payflowpro_gateway-donor-street' ), 'street' ) . '</td>';
 128+ $form .= '<td>' . Xml::input( 'street', '30', $this->form_data['street'], array( 'maxlength' => '30', 'id' => 'street' ) ) .
 129+ '<span class="creditcard-error-msg">' . ' ' . $this->form_errors['street'] . '</span></td>';
 130+ $form .= '</tr>';
 131+
 132+
 133+ // city
 134+ $form .= '<tr>';
 135+ $form .= '<td>' . Xml::label( wfMsg( 'payflowpro_gateway-donor-city' ), 'city' ) . '</td>';
 136+ $form .= '<td>' . Xml::input( 'city', '30', $this->form_data['city'], array( 'maxlength' => '20', 'id' => 'city' ) ) .
 137+ '<span class="creditcard-error-msg">' . ' ' . $this->form_errors['city'] . '</span></td>';
 138+ $form .= '</tr>';
 139+
 140+ // state
 141+ $form .= '<tr>';
 142+ $form .= '<td>' . Xml::label( wfMsg( 'payflowpro_gateway-donor-state' ), 'state' ) . '</td>';
 143+ $form .= '<td>' . $this->generateStateDropdown() . '<span class="creditcard-error-msg">' . ' ' . $this->form_errors['state'] . '</span></td>';
 144+ $form .= '</tr>';
 145+
 146+ // zip
 147+ $form .= '<tr>';
 148+ $form .= '<td>' . Xml::label( wfMsg( 'payflowpro_gateway-donor-postal' ), 'zip' ) . '</td>';
 149+ $form .= '<td>' . Xml::input( 'zip', '30', $this->form_data['zip'], array( 'maxlength' => '9', 'id' => 'zip' ) ) .
 150+ '<span class="creditcard-error-msg">' . ' ' . $this->form_errors['zip'] . '</span></td>';
 151+ $form .= '</tr>';
 152+
 153+ // email
 154+ $form .= '<tr>';
 155+ $form .= '<td>' . Xml::label( wfMsg( 'payflowpro_gateway-donor-email' ), 'emailAdd' ) . '</td>';
 156+ $form .= '<td>' . Xml::input( 'emailAdd', '30', $this->form_data['email'], array( 'maxlength' => '64', 'id' => 'emailAdd' ) ) .
 157+ '<span class="creditcard-error-msg">' . ' ' . $this->form_errors['emailAdd'] . '</span></td>';
 158+ $form .= '</tr>';
 159+
 160+ return $form;
 161+ }
 162+
 163+ protected function generatePaymentContainerTop() {
 164+ // credit card info
 165+ global $wgPayflowGatewayTest;
 166+ $card_num = ( $wgPayflowGatewayTest ) ? $this->form_data[ 'card_num' ] : '';
 167+ $cvv = ( $wgPayflowGatewayTest ) ? $this->form_data[ 'cvv' ] : '';
 168+ $form .= Xml::openElement( 'div', array( 'class' => 'payflow-cc-form-section', 'id' => 'payflowpro_gateway-payment-info' ));
 169+ $form .= Xml::tags( 'h3', array( 'class' => 'payflow-cc-form-header', 'id' => 'payflow-cc-form-header-payment' ), wfMsg( 'payflowpro_gateway-cc-form-header-payment' ));
 170+ $form .= Xml::openElement( 'table', array( 'id' => 'payflow-table-cc' ) );
 171+
 172+ return $form;
 173+ }
 174+
 175+ protected function generatePaymentFields() {
 176+ global $wgScriptPath;
 177+ // amount
 178+ $form .= '<tr>';
 179+ $form .= '<td>' . Xml::label(wfMsg( 'payflowpro_gateway-amount-legend' ), 'amount', array( 'maxlength' => '10' ) ) . '</td>';
 180+ $form .= '<td>' . Xml::input( 'amount', '7', $this->form_data['amount'], array( 'id' => 'amount' ) ) .
 181+ '<span class="creditcard-error-msg">' . ' ' . $this->form_errors['invalidamount'] . '</span>';
 182+ $form .= $this->generateCurrencyDropdown() . '</td>';
 183+ $form .= '</tr>';
 184+
 185+ // card logos
 186+ $form .= '<tr>';
 187+ $form .= '<td />';
 188+ $form .= '<td>' . Xml::openElement( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/credit_card_logos.gif" )) . '</td>';
 189+ $form .= '</tr>';
 190+
 191+ // credit card type
 192+ $form .= '<tr>';
 193+ $form .= '<td>' . Xml::label( wfMsg( 'payflowpro_gateway-donor-card' ), 'card' ) . '</td>';
 194+ $form .= '<td>' . $this->generateCardDropdown() . '</td>';
 195+ $form .= '</tr>';
 196+
 197+ // card number
 198+ $form .= '<tr>';
 199+ $form .= '<td>' . Xml::label( wfMsg( 'payflowpro_gateway-donor-card-num' ), 'card_num' ) . '</td>';
 200+ $form .= '<td>' . Xml::input( 'card_num', '30', $card_num, array( 'maxlength' => '100', 'id' => 'card_num', 'autocomplete' => 'off' ) ) .
 201+ '<span class="creditcard-error-msg">' . ' ' . $this->form_errors['card_num'] . '</span></td>';
 202+ $form .= '</tr>';
 203+
 204+ // card error
 205+ $form .= '<tr>';
 206+ $form .= '<td></td>';
 207+ $form .= '<td>' . '<span class="creditcard-error-msg">' . ' ' . $this->form_errors['card'] . '</span></td>';
 208+ $form .= '</tr>';
 209+
 210+ // expiry
 211+ $form .= '<tr>';
 212+ $form .= '<td>' . Xml::label( wfMsg( 'payflowpro_gateway-donor-expiration' ), 'expiration' ) . '</td>';
 213+ $form .= '<td>' . $this->generateExpiryMonthDropdown() . $this->generateExpiryYearDropdown() . '</td>';
 214+ $form .= '</tr>';
 215+
 216+ // cvv
 217+ $form .= '<tr>';
 218+ $form .= '<td>' . Xml::label( wfMsg( 'payflowpro_gateway-donor-security' ), 'cvv' ) . '</td>';
 219+ $form .= '<td>' . Xml::input( 'cvv', '5', $cvv, array( 'maxlength' => '10', 'id' => 'cvv', 'autocomplete' => 'off') ) .
 220+ '<a href="javascript:PopupCVV();">' . wfMsg( 'word-separator' ) . wfMsg( 'payflowpro_gateway-cvv-link' ) . '</a>' .
 221+ '<span class="creditcard-error-msg">' . ' ' . $this->form_errors['cvv'] . '</span></td>';
 222+ $form .= '</tr>';
 223+
 224+ return $form;
 225+ }
 226+}
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumnLetter.php
@@ -0,0 +1,44 @@
 2+<?php
 3+
 4+class PayflowProGateway_Form_TwoColumnLetter extends PayflowProGateway_Form_TwoColumn {
 5+
 6+ public function __construct( &$form_data, &$form_errors ) {
 7+ global $wgOut, $wgScriptPath;
 8+ parent::__construct( $form_data, $form_errors );
 9+
 10+ // add form-specific css
 11+ $wgOut->addExtensionStyle( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoColumnLetter.css');
 12+ }
 13+
 14+ public function generateFormBody() {
 15+ global $wgOut, $wgRequest;
 16+ $form = parent::generateBannerHeader();
 17+
 18+ $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-cc_form_container'));
 19+ $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-cc_form_letter', 'class' => 'payflowpro_gateway-cc_form_column'));
 20+
 21+ $text_template = $wgRequest->getText( 'text_template' );
 22+ if ( $wgRequest->getText( 'language' )) $text_template .= '/' . $wgRequest->getText( 'language' );
 23+
 24+ $form .= ( strlen( $text_template )) ? $wgOut->parse( '{{'.$text_template.'}}' ) : '';
 25+ $form .= Xml::closeElement( 'div' );
 26+
 27+ $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-cc_form_form', 'class' => 'payflowpro_gateway-cc_form_column'));
 28+ $form .= parent::generatePersonalContainerTop();
 29+ $form .= parent::generatePersonalFields();
 30+ $form .= Xml::closeElement( 'table' );
 31+ $form .= Xml::closeElement( 'div' );
 32+ $form .= parent::generatePaymentContainerTop();
 33+ $form .= parent::generatePaymentFields();
 34+ $form .= Xml::closeElement( 'table' );
 35+ return $form;
 36+ }
 37+
 38+ public function generateFormSubmit() {
 39+ $form .= parent::generateFormSubmit();
 40+
 41+ $form .=Xml::closeElement( 'div' );
 42+ $form .= Xml::closeElement( 'div' );
 43+ return $form;
 44+ }
 45+}
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.php
@@ -21,6 +21,9 @@
2222 // Set up the new special page
2323 $dir = dirname(__FILE__) . '/';
2424 $wgAutoloadClasses['PayflowProGateway'] = $dir . 'payflowpro_gateway.body.php';
 25+$wgAutoloadClasses[ 'PayflowProGateway_Form' ] = $dir . 'forms/Form.php';
 26+$wgAutoloadClasses[ 'PayflowProGateway_Form_TwoColumn' ] = $dir . 'forms/TwoColumn.php';
 27+$wgAutoloadClasses[ 'PayflowProGateway_Form_TwoColumnLetter' ] = $dir . 'forms/TwoColumnLetter.php';
2528 $wgExtensionMessagesFiles['PayflowProGateway'] = $dir . 'payflowpro_gateway.i18n.php';
2629 $wgExtensionAliasesFiles['PayflowProGateway'] = $dir . 'payflowpro_gateway.alias.php';
2730 $wgSpecialPages['PayflowProGateway'] = 'PayflowProGateway';
@@ -42,6 +45,11 @@
4346 $wgPayflowGatewayTest = FALSE;
4447
4548 /**
 49+ * The default form to use
 50+ */
 51+$wgPayflowGatewayDefaultForm = 'TwoColumn';
 52+
 53+/**
4654 * A string or array of strings for making tokens more secure
4755 *
4856 * Please set this! If you do not, tokens are easy to get around, which can

Status & tagging log