Index: trunk/extensions/DonationInterface/payflowpro_gateway/validate_input.js |
— | — | @@ -39,6 +39,67 @@ |
40 | 40 | document.getElementById('payflowpro_gateway-form-submit-paypal').style.display = 'none'; |
41 | 41 | } |
42 | 42 | |
| 43 | +/* |
| 44 | + * Validates the personal information fields |
| 45 | + * |
| 46 | + * @input form The form containing the inputs to be checked |
| 47 | + * |
| 48 | + * @return boolean true if no errors, false otherwise (also uses an alert() to notify the user) |
| 49 | + */ |
| 50 | +function validate_personal( form ){ |
| 51 | + |
| 52 | + // TODO: this form should only report a single error for the email address? |
| 53 | + |
| 54 | + var output = ''; |
| 55 | + var currField = ''; |
| 56 | + var i = 0; |
| 57 | + var msg = [ 'EmailAdd', 'Fname', 'Lname', 'Street', 'City', 'Zip']; |
| 58 | + var fields = [ "emailAdd","fname","lname","street","city","zip" ], |
| 59 | + numFields = fields.length; |
| 60 | + for( i = 0; i < numFields; i++ ) { |
| 61 | + if( document.getElementById( fields[i] ).value == '' ) { |
| 62 | + currField = window['payflowproGatewayErrorMsg'+ msg[i]]; |
| 63 | + output += payflowproGatewayErrorMsgJs + ' ' + currField + '.\r\n'; |
| 64 | + } |
| 65 | + } |
| 66 | + var stateField = document.getElementById( 'state' ); |
| 67 | + var countryField = document.getElementById( 'country' ); |
| 68 | + if( stateField.options[stateField.selectedIndex].value == 'YY' ) { |
| 69 | + output += payflowproGatewayErrorMsgJs + ' ' + window['payflowproGatewayErrorMsgState'] + '.\r\n'; |
| 70 | + } |
| 71 | + |
| 72 | + if( countryField.type == "select" ){ // country is a dropdown select |
| 73 | + if( countryField.options[countryField.selectedIndex].value == '' ) { |
| 74 | + output += payflowproGatewayErrorMsgJs + ' ' + window['payflowproGatewayErrorMsgCountry'] + '.\r\n'; |
| 75 | + } |
| 76 | + } |
| 77 | + else{ // country is a hidden or text input |
| 78 | + if( countryField.value == '' ) { |
| 79 | + output += payflowproGatewayErrorMsgJs + ' ' + window['payflowproGatewayErrorMsgCountry'] + '.\r\n'; |
| 80 | + } |
| 81 | + } |
| 82 | + |
| 83 | + //set state to "outside us" |
| 84 | + if ( form.country.value != 'US' ) { |
| 85 | + form.state.value = 'XX'; |
| 86 | + } |
| 87 | + |
| 88 | + // validate email address |
| 89 | + var apos = form.emailAdd.value.indexOf("@"); |
| 90 | + var dotpos = form.emailAdd.value.lastIndexOf("."); |
| 91 | + |
| 92 | + if( apos < 1 || dotpos-apos < 2 ) { |
| 93 | + output += payflowproGatewayErrorMsgEmail; |
| 94 | + } |
| 95 | + |
| 96 | + if( output ) { |
| 97 | + alert( output ); |
| 98 | + return false; |
| 99 | + } |
| 100 | + |
| 101 | + return true; |
| 102 | +} |
| 103 | + |
43 | 104 | function validate_form( form ) { |
44 | 105 | if( form == null ){ |
45 | 106 | form = document.payment |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php |
— | — | @@ -79,6 +79,7 @@ |
80 | 80 | $wgOut->addScript( Skin::makeVariablesScript( $scriptVars ) ); |
81 | 81 | |
82 | 82 | // @fixme can this be moved into the form generators? |
| 83 | + // @fixme this is broken on MW 1.16, executes before jQuery load |
83 | 84 | $js = <<<EOT |
84 | 85 | <script type="text/javascript"> |
85 | 86 | jQuery(document).ready(function() { |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/RapidHtml.php |
— | — | @@ -39,7 +39,7 @@ |
40 | 40 | '@utm_source', // => self::getUtmSource(), |
41 | 41 | '@utm_medium', // => $wgRequest->getText( 'utm_medium' ), |
42 | 42 | '@utm_campaign', // => $wgRequest->getText( 'utm_campaign' ), |
43 | | - // try to honr the user-set language (uselang), otherwise the language set in the URL (language) |
| 43 | + // try to honor the user-set language (uselang), otherwise the language set in the URL (language) |
44 | 44 | '@language', // => $wgRequest->getText( 'uselang', $wgRequest->getText( 'language' ) ), |
45 | 45 | '@comment-option', // => $wgRequest->getText( 'comment-option' ), |
46 | 46 | '@comment', // => $wgRequest->getText( 'comment' ), |
— | — | @@ -147,9 +147,21 @@ |
148 | 148 | $form = str_replace( $token, $replace, $form ); |
149 | 149 | } |
150 | 150 | |
151 | | - // replace errors |
152 | | - $form = str_replace( $this->error_tokens, $this->form_errors, $form ); |
| 151 | + // @fixme why do some errors have HTML in them |
| 152 | + // replace errors|escape with escaped versions |
| 153 | + $escape_error_tokens = array(); |
| 154 | + foreach ( $this->error_tokens as $token ) { |
| 155 | + $escape_error_tokens[] = "$token|escape"; |
| 156 | + } |
| 157 | + $escape_errors = array(); |
| 158 | + foreach ( $this->form_errors as $error ) { |
| 159 | + $escape_errors[] = addslashes($error); |
| 160 | + } |
| 161 | + $form = str_replace($escape_error_tokens, $escape_errors, $form); |
153 | 162 | |
| 163 | + // replace standard errors |
| 164 | + $form = str_replace($this->error_tokens, $this->form_errors, $form); |
| 165 | + |
154 | 166 | // handle captcha |
155 | 167 | $form = str_replace( "@captcha", $this->getCaptchaHtml(), $form ); |
156 | 168 | |