r74413 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74412‎ | r74413 | r74414 >
Date:02:56, 7 October 2010
Author:kaldari
Status:deferred
Tags:
Comment:
switch form to paypal only if needed, restore amount value if javascript off
Modified paths:
  • /trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumn.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumnLetter.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.css (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumn.php
@@ -274,8 +274,10 @@
275275
276276 protected function getAmountField() {
277277 $otherChecked = false;
 278+ $amount = -1;
278279 if ( $this->form_data['amount'] != 250 && $this->form_data['amount'] != 100 && $this->form_data['amount'] != 75 && $this->form_data['amount'] != 35 && $this->form_data['amountOther'] > 0 ) {
279280 $otherChecked = true;
 281+ $amount = $this->form_data['amountOther'];
280282 }
281283 $form = '<tr>';
282284 $form .= '<td colspan="2"><span class="creditcard-error-msg">' . $this->form_errors['invalidamount'] . '</span></td>';
@@ -290,7 +292,7 @@
291293 $form .= '</tr>';
292294 $form .= '<tr>';
293295 $form .= '<td class="label"></td>';
294 - $form .= '<td>' . Xml::radio( 'amount', -1, $otherChecked, array( 'id' => 'otherRadio' ) ) . Xml::input( 'amountOther', '7', $this->form_data['amountOther'], array( 'type' => 'text', 'onfocus' => 'clearField( this, "Other" )', 'onblur' => 'document.getElementById("otherRadio").value = this.value', 'maxlength' => '10', 'id' => 'amountOther' ) ) .
 296+ $form .= '<td>' . Xml::radio( 'amount', $amount, $otherChecked, array( 'id' => 'otherRadio' ) ) . Xml::input( 'amountOther', '7', $this->form_data['amountOther'], array( 'type' => 'text', 'onfocus' => 'clearField( this, "Other" )', 'onblur' => 'document.getElementById("otherRadio").value = this.value', 'maxlength' => '10', 'id' => 'amountOther' ) ) .
295297 ' ' . $this->generateCurrencyDropdown() . '</td>';
296298 $form .= '</tr>';
297299 return $form;
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumnLetter.php
@@ -1,6 +1,7 @@
22 <?php
33
44 class PayflowProGateway_Form_TwoColumnLetter extends PayflowProGateway_Form_TwoColumn {
 5+ public $paypal = false; // true for paypal only version
56
67 public function __construct( &$form_data, &$form_errors ) {
78 global $wgOut, $wgScriptPath;
@@ -18,6 +19,9 @@
1920
2021 public function generateFormStart() {
2122 global $wgOut, $wgRequest;
 23+
 24+ $this->paypal = $wgRequest->getBool( 'paypal', false );
 25+
2226 $form = parent::generateBannerHeader();
2327
2428 $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-cc_form_container'));
@@ -90,6 +94,7 @@
9195 protected function generateBillingFields() {
9296 global $wgScriptPath, $wgPayflowGatewayTest, $wgPayflowGatewayPaypalURL;
9397 $scriptPath = "$wgScriptPath/extensions/DonationInterface/payflowpro_gateway/includes";
 98+
9499 $form = '';
95100
96101 // name
@@ -133,59 +138,80 @@
134139 // amount
135140 $form .= $this->getAmountField();
136141
137 - // PayPal button
138 - // make sure we have a paypal url set to redirect the user to before displaying the button
139 - if ( strlen( $wgPayflowGatewayPaypalURL )) {
 142+ if ( !$this->paypal ) {
 143+ // PayPal button
 144+ // make sure we have a paypal url set to redirect the user to before displaying the button
 145+ if ( strlen( $wgPayflowGatewayPaypalURL )) {
 146+ $form .= '<tr>';
 147+ $form .= '<td class="paypal-button" colspan="2">';
 148+ $form .= Xml::hidden( 'PaypalRedirect', false );
 149+ $form .= Xml::tags( 'div',
 150+ array(),
 151+ '<a href="#" onclick="document.payment.PaypalRedirect.value=\'true\';document.payment.submit();"><img src="'.$scriptPath.'/donate_with_paypal.gif"/></a>'
 152+ );
 153+ $form .= '</td>';
 154+ $form .= '</tr>';
 155+ }
 156+
 157+ // card logos
140158 $form .= '<tr>';
141 - $form .= '<td class="paypal-button" colspan="2">';
142 - $form .= Xml::hidden( 'PaypalRedirect', false );
143 - $form .= Xml::tags( 'div',
144 - array(),
145 - '<a href="#" onclick="document.payment.PaypalRedirect.value=\'true\';document.payment.submit();"><img src="'.$scriptPath.'/donate_with_paypal.gif"/></a>'
146 - );
147 - $form .= '</td>';
 159+ $form .= '<td />';
 160+ $form .= '<td>' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/credit_card_logos.gif" )) . '</td>';
148161 $form .= '</tr>';
 162+
 163+ // card number
 164+ $form .= $this->getCardNumberField();
 165+
 166+ // cvv
 167+ $form .= $this->getCvvField();
 168+
 169+ // expiry
 170+ $form .= '<tr>';
 171+ $form .= '<td class="label">' . Xml::label( wfMsg( 'payflowpro_gateway-donor-expiration' ), 'expiration' ) . '</td>';
 172+ $form .= '<td>' . $this->generateExpiryMonthDropdown() . $this->generateExpiryYearDropdown() . '</td>';
 173+ $form .= '</tr>';
 174+
 175+ // street
 176+ $form .= $this->getStreetField();
 177+
 178+ // city
 179+ $form .= $this->getCityField();
 180+
 181+ // state
 182+ $form .= '<tr>';
 183+ $form .= '<td class="label">' . Xml::label( wfMsg( 'payflowpro_gateway-donor-state' ), 'state' ) . '</td>';
 184+ $form .= '<td>' . $this->generateStateDropdown() . ' ' . wfMsg( 'payflowpro_gateway-state-in-us' ) . '<span class="creditcard-error-msg">' . ' ' . $this->form_errors['state'] . '</span></td>';
 185+ $form .= '</tr>';
 186+
 187+ // zip
 188+ $form .= $this->getZipField();
 189+
 190+ // country
 191+ $form .= '<tr>';
 192+ $form .= '<td class="label">' . Xml::label( wfMsg( 'payflowpro_gateway-donor-country' ), 'country' ) . '</td>';
 193+ $form .= '<td>' . $this->generateCountryDropdown() . '<span class="creditcard-error-msg">' . ' ' . $this->form_errors['country'] . '</span></td>';
 194+ $form .= '</tr>';
149195 }
150 -
151 - // card logos
152 - $form .= '<tr>';
153 - $form .= '<td />';
154 - $form .= '<td>' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/credit_card_logos.gif" )) . '</td>';
155 - $form .= '</tr>';
156 -
157 - // card number
158 - $form .= $this->getCardNumberField();
159 -
160 - // cvv
161 - $form .= $this->getCvvField();
162 -
163 - // expiry
164 - $form .= '<tr>';
165 - $form .= '<td class="label">' . Xml::label( wfMsg( 'payflowpro_gateway-donor-expiration' ), 'expiration' ) . '</td>';
166 - $form .= '<td>' . $this->generateExpiryMonthDropdown() . $this->generateExpiryYearDropdown() . '</td>';
167 - $form .= '</tr>';
168196
169 - // street
170 - $form .= $this->getStreetField();
171 -
172 - // city
173 - $form .= $this->getCityField();
174 -
175 - // state
176 - $form .= '<tr>';
177 - $form .= '<td class="label">' . Xml::label( wfMsg( 'payflowpro_gateway-donor-state' ), 'state' ) . '</td>';
178 - $form .= '<td>' . $this->generateStateDropdown() . ' ' . wfMsg( 'payflowpro_gateway-state-in-us' ) . '<span class="creditcard-error-msg">' . ' ' . $this->form_errors['state'] . '</span></td>';
179 - $form .= '</tr>';
180 -
181 - // zip
182 - $form .= $this->getZipField();
 197+ return $form;
 198+ }
 199+
 200+ public function generateFormSubmit() {
 201+ // submit button
 202+ $form = Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-form-submit'));
 203+ $form .= Xml::openElement( 'div', array( 'id' => 'mw-donate-submit-button' ));
 204+ if ( $this->paypal ) {
 205+ $form .= Xml::hidden( 'PaypalRedirect', false );
 206+ $form .= Xml::element( 'input', array( 'class' => 'input-button button-navyblue', 'value' => wfMsg( 'payflowpro_gateway-submit-button'), 'onclick' => 'document.payment.PaypalRedirect.value=\'true\';document.payment.submit();', 'type' => 'submit'));
 207+ } else {
 208+ $form .= Xml::element( 'input', array( 'class' => 'input-button button-navyblue', 'value' => wfMsg( 'payflowpro_gateway-submit-button'), 'onclick' => 'submit_form( this )', 'type' => 'submit'));
 209+ $form .= Xml::closeElement( 'div' ); // close div#mw-donate-submit-button
 210+ $form .= Xml::openElement( 'div', array( 'class' => 'mw-donate-submessage', 'id' => 'payflowpro_gateway-donate-submessage' ) ) .
 211+ wfMsg( 'payflowpro_gateway-donate-click' );
 212+ }
 213+ $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-donate-submessage
 214+ $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-form-submit
183215
184 - // country
185 - $form .= '<tr>';
186 - $form .= '<td class="label">' . Xml::label( wfMsg( 'payflowpro_gateway-donor-country' ), 'country' ) . '</td>';
187 - $form .= '<td>' . $this->generateCountryDropdown() . '<span class="creditcard-error-msg">' . ' ' . $this->form_errors['country'] . '</span></td>';
188 - $form .= '</tr>';
189 -
190216 return $form;
191217 }
192218
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.css
@@ -69,6 +69,7 @@
7070 .button-navyblue {
7171 background-image:url("https://payments.wikimedia.org/images/0/06/Button-wavy-blue.png");
7272 color:#FFFFFF;
 73+ cursor:pointer;
7374 }
7475
7576 .input-button {

Status & tagging log