r79208 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79207‎ | r79208 | r79209 >
Date:21:37, 29 December 2010
Author:kaldari
Status:deferred
Tags:
Comment:
fixes for form validation
Modified paths:
  • /trunk/extensions/DonationInterface/payflowpro_gateway/forms/Form.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoStepTwoColumn.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoStepTwoColumnLetter3.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoStepTwoColumnLetterCA.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.i18n.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/validate_input.js (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/payflowpro_gateway/validate_input.js
@@ -40,20 +40,28 @@
4141 }
4242
4343 function validate_form( form ) {
44 - var msg = [ 'EmailAdd', 'Fname', 'Lname', 'Street', 'City', 'State', 'Zip', 'CardNum', 'Cvv' ];
45 -
46 - var fields = ["emailAdd","fname","lname","street","city","state","zip","card_num","cvv" ],
47 - numFields = fields.length,
48 - i,
49 - output = '',
50 - currField = '';
51 -
 44+ var output = '';
 45+ var currField = '';
 46+ var i = 0;
 47+ var msg = [ 'EmailAdd', 'Fname', 'Lname', 'Street', 'City', 'Zip', 'CardNum', 'Cvv' ];
 48+ var fields = ["emailAdd","fname","lname","street","city","zip","card_num","cvv" ],
 49+ numFields = fields.length;
5250 for( i = 0; i < numFields; i++ ) {
5351 if( document.getElementById( fields[i] ).value == '' ) {
5452 currField = window['payflowproGatewayErrorMsg'+ msg[i]];
5553 output += payflowproGatewayErrorMsgJs + ' ' + currField + '.\r\n';
5654 }
5755 }
 56+ var stateField = document.getElementById( 'state' );
 57+ var countryField = document.getElementById( 'country' );
 58+ if( stateField.options[stateField.selectedIndex].value == 'YY' ) {
 59+ output += payflowproGatewayErrorMsgJs + ' ' + window['payflowproGatewayErrorMsgState'] + '.\r\n';
 60+ }
 61+ if( countryField.options[countryField.selectedIndex].value == '' ) {
 62+ output += payflowproGatewayErrorMsgJs + ' ' + window['payflowproGatewayErrorMsgCountry'] + '.\r\n';
 63+ }
 64+ output += "State:" + stateField.options[stateField.selectedIndex].value + '.\r\n';
 65+ output += "Country:" + countryField.options[countryField.selectedIndex].value + '.\r\n';
5866
5967 //set state to "outside us"
6068 if ( document.payment.country.value != '840' ) {
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php
@@ -69,6 +69,7 @@
7070 'payflowproGatewayErrorMsgCity' => wfMsg( 'payflowpro_gateway-error-msg-city' ),
7171 'payflowproGatewayErrorMsgState' => wfMsg( 'payflowpro_gateway-error-msg-state' ),
7272 'payflowproGatewayErrorMsgZip' => wfMsg( 'payflowpro_gateway-error-msg-zip' ),
 73+ 'payflowproGatewayErrorMsgCountry' => wfMsg( 'payflowpro_gateway-error-msg-country' ),
7374 'payflowproGatewayErrorMsgCardNum' => wfMsg( 'payflowpro_gateway-error-msg-card_num' ),
7475 'payflowproGatewayErrorMsgExpiration' => wfMsg( 'payflowpro_gateway-error-msg-expiration' ),
7576 'payflowproGatewayErrorMsgCvv' => wfMsg( 'payflowpro_gateway-error-msg-cvv' ),
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoStepTwoColumnLetterCA.php
@@ -198,37 +198,4 @@
199199 return $state_menu;
200200 }
201201
202 - public function generateCountryDropdown( $defaultCountry = 124 ) {
203 - $country_options = '';
204 -
205 - // create a new array of countries with potentially translated country names for alphabetizing later
206 - foreach ( $this->getCountries() as $iso_value => $full_name ) {
207 - $countries[ $iso_value ] = wfMsg( 'payflowpro_gateway-country-dropdown-' . $iso_value );
208 - }
209 -
210 - // alphabetically sort the country names
211 - asort( $countries, SORT_STRING );
212 -
213 - // generate a dropdown option for each country
214 - foreach ( $countries as $iso_value => $full_name ) {
215 - if ( $this->form_data[ 'country' ] ) {
216 - $selected = ( $iso_value == $this->form_data[ 'country' ] ) ? true : false;
217 - } else {
218 - $selected = ( $iso_value == $defaultCountry ) ? true : false; // Select default
219 - }
220 - $country_options .= Xml::option( $full_name, $iso_value, $selected );
221 - }
222 -
223 - // build the actual select
224 - $country_menu = Xml::openElement(
225 - 'select',
226 - array(
227 - 'name' => 'country',
228 - 'id' => 'country'
229 - ) );
230 - $country_menu .= $country_options;
231 - $country_menu .= Xml::closeElement( 'select' );
232 -
233 - return $country_menu;
234 - }
235202 }
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/Form.php
@@ -137,7 +137,7 @@
138138 * (see http://us.php.net/asort)
139139 * @return string
140140 */
141 - public function generateCountryDropdown( $defaultCountry = 840 ) {
 141+ public function generateCountryDropdown( $defaultCountry = null ) {
142142 $country_options = '';
143143
144144 // create a new array of countries with potentially translated country names for alphabetizing later
@@ -163,9 +163,9 @@
164164 'select',
165165 array(
166166 'name' => 'country',
167 - 'id' => 'country',
168 - 'onchange' => 'return disableStates( this )'
 167+ 'id' => 'country'
169168 ) );
 169+ $country_menu .= Xml::option( wfMsg( 'payflowpro_gateway-select-country' ), '', false );
170170 $country_menu .= $country_options;
171171 $country_menu .= Xml::closeElement( 'select' );
172172
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoStepTwoColumn.php
@@ -36,9 +36,9 @@
3737 addEvent( window, 'load', loadPlaceholders );
3838
3939 function formCheck( ccform ) {
40 - var msg = [ 'EmailAdd', 'Fname', 'Lname', 'Street', 'City', 'State', 'Zip', 'CardNum', 'Cvv' ];
 40+ var msg = [ 'EmailAdd', 'Fname', 'Lname', 'Street', 'City', 'Zip', 'CardNum', 'Cvv' ];
4141
42 - var fields = ["emailAdd","fname","lname","street","city","state","zip","card_num","cvv" ],
 42+ var fields = ["emailAdd","fname","lname","street","city","zip","card_num","cvv" ],
4343 numFields = fields.length,
4444 i,
4545 output = '',
@@ -57,6 +57,14 @@
5858 if (document.getElementById('lname').value == '$last') {
5959 output += payflowproGatewayErrorMsgJs + ' last name.\\r\\n';
6060 }
 61+ var stateField = document.getElementById( 'state' );
 62+ if( stateField.options[stateField.selectedIndex].value == 'YY' ) {
 63+ output += payflowproGatewayErrorMsgJs + ' ' + window['payflowproGatewayErrorMsgState'] + '.\\r\\n';
 64+ }
 65+ var countryField = document.getElementById( 'country' );
 66+ if( countryField.options[countryField.selectedIndex].value == '' ) {
 67+ output += payflowproGatewayErrorMsgJs + ' ' + window['payflowproGatewayErrorMsgCountry'] + '.\\r\\n';
 68+ }
6169
6270 // validate email address
6371 var apos = document.payment.emailAdd.value.indexOf("@");
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoStepTwoColumnLetter3.php
@@ -58,9 +58,9 @@
5959 addEvent( window, 'load', loadPlaceholders );
6060
6161 function formCheck( ccform ) {
62 - var msg = [ 'EmailAdd', 'Fname', 'Lname', 'Street', 'City', 'State', 'Zip', 'CardNum', 'Cvv' ];
 62+ var msg = [ 'EmailAdd', 'Fname', 'Lname', 'Street', 'City', 'Zip', 'CardNum', 'Cvv' ];
6363
64 - var fields = ["emailAdd","fname","lname","street","city","state","zip","card_num","cvv" ],
 64+ var fields = ["emailAdd","fname","lname","street","city","zip","card_num","cvv" ],
6565 numFields = fields.length,
6666 i,
6767 output = '',
@@ -88,6 +88,11 @@
8989 if (document.getElementById('zip').value == '$zip') {
9090 output += payflowproGatewayErrorMsgJs + ' zip code.\\r\\n';
9191 }
 92+
 93+ var stateField = document.getElementById( 'state' );
 94+ if( stateField.options[stateField.selectedIndex].value == '' ) {
 95+ output += payflowproGatewayErrorMsgJs + ' ' + window['payflowproGatewayErrorMsgState'] + '.\\r\\n';
 96+ }
9297
9398 // validate email address
9499 var apos = document.payment.emailAdd.value.indexOf("@");
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.i18n.php
@@ -62,6 +62,7 @@
6363 'payflowpro_gateway-error-msg-city' => 'city',
6464 'payflowpro_gateway-error-msg-state' => 'state',
6565 'payflowpro_gateway-error-msg-zip' => 'postal code',
 66+ 'payflowpro_gateway-error-msg-country' => 'country',
6667 'payflowpro_gateway-error-msg-card_num' => 'credit card number',
6768 'payflowpro_gateway-error-msg-expiration' => "card's expiration date",
6869 'payflowpro_gateway-error-msg-cvv' => 'CVV from the back of your card',
@@ -142,7 +143,7 @@
143144 'payflowpro_gateway-zip-postal-code' => 'Zip/Postal code',
144145 'payflowpro_gateway-billing-code' => 'Billing zip',
145146 'payflowpro_gateway-country' => 'Country',
146 - 'payflowpro_gateway-select-country' => 'Select country',
 147+ 'payflowpro_gateway-select-country' => 'Select a country',
147148 'payflowpro_gateway-confirm-email' => 'Confirm e-mail',
148149 'payflowpro_gateway-phone' => 'Phone',
149150 'payflowpro_gateway-telephone' => 'Telephone',
@@ -217,7 +218,7 @@
218219 'payflowpro_gateway-on-the-back' => 'With this on the back:',
219220
220221 // For more USA states, see payflowpro_gateway.us-states.i18n.php.
221 - 'payflowpro_gateway-state-dropdown-YY' => 'Select a State',
 222+ 'payflowpro_gateway-state-dropdown-YY' => 'Select a state',
222223 'payflowpro_gateway-state-dropdown-XX' => 'Outside the U.S.',
223224 );
224225

Status & tagging log