r76847 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76846‎ | r76847 | r76848 >
Date:23:20, 16 November 2010
Author:kaldari
Status:deferred
Tags:
Comment:
fix for placeholder bug
Modified paths:
  • /trunk/extensions/DonationInterface/payflowpro_gateway/forms/OneStepTwoColumn.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoStepTwoColumn.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.i18n.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoStepTwoColumn.php
@@ -34,6 +34,43 @@
3535 }
3636 }
3737 addEvent( window, 'load', loadPlaceholders );
 38+
 39+function formCheck( ccform ) {
 40+ var msg = [ 'EmailAdd', 'Fname', 'Lname', 'Street', 'City', 'State', 'Zip', 'CardNum', 'Cvv' ];
 41+
 42+ var fields = ["emailAdd","fname","lname","street","city","state","zip","card_num","cvv" ],
 43+ numFields = fields.length,
 44+ i,
 45+ output = '',
 46+ currField = '';
 47+
 48+ for( i = 0; i < numFields; i++ ) {
 49+ if( document.getElementById( fields[i] ).value == '' ) {
 50+ currField = window['payflowproGatewayErrorMsg'+ msg[i]];
 51+ output += payflowproGatewayErrorMsgJs + ' ' + currField + '.\\r\\n';
 52+ }
 53+ }
 54+
 55+ if (document.getElementById('fname').value == '$first') {
 56+ output += payflowproGatewayErrorMsgJs + ' first name.\\r\\n';
 57+ }
 58+ if (document.getElementById('lname').value == '$last') {
 59+ output += payflowproGatewayErrorMsgJs + ' last name.\\r\\n';
 60+ }
 61+
 62+ // validate email address
 63+ var apos = document.payment.emailAdd.value.indexOf("@");
 64+ var dotpos = document.payment.emailAdd.value.lastIndexOf(".");
 65+
 66+ if( apos < 1 || dotpos-apos < 2 ) {
 67+ output += payflowproGatewayErrorMsgEmail;
 68+ }
 69+
 70+ if( output ) {
 71+ alert( output );
 72+ return false;
 73+ }
 74+}
3875 </script>
3976 EOT;
4077 $wgOut->addHeadItem( 'placeholders', $js );
@@ -79,7 +116,7 @@
80117
81118 // Xml::element seems to convert html to htmlentities
82119 $form .= "<p class='creditcard-error-msg'>" . $this->form_errors['retryMsg'] . "</p>";
83 - $form .= Xml::openElement( 'form', array( 'name' => 'payment', 'method' => 'post', 'action' => $this->getNoCacheAction(), 'onsubmit' => 'return validate_form(this)', 'autocomplete' => 'off' ) );
 120+ $form .= Xml::openElement( 'form', array( 'name' => 'payment', 'method' => 'post', 'action' => $this->getNoCacheAction(), 'onsubmit' => 'return formCheck(this)', 'autocomplete' => 'off' ) );
84121
85122 $form .= Xml::openElement( 'div', array( 'id' => 'left-column', 'class' => 'payflow-cc-form-section' ) );
86123 $form .= $this->generatePersonalContainer();
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/OneStepTwoColumn.php
@@ -16,6 +16,11 @@
1717
1818 $this->loadApiJs(); // API/Ajax JS
1919
 20+ $this->loadPlaceholders();
 21+ }
 22+
 23+ public function loadPlaceholders() {
 24+ global $wgOut;
2025 // form placeholder values
2126 $first = wfMsg( 'payflowpro_gateway-first' );
2227 $last = wfMsg( 'payflowpro_gateway-last' );
@@ -41,6 +46,43 @@
4247 }
4348 }
4449 addEvent( window, 'load', loadPlaceholders );
 50+
 51+function formCheck( ccform ) {
 52+ var msg = [ 'EmailAdd', 'Fname', 'Lname', 'Street', 'City', 'State', 'Zip', 'CardNum', 'Cvv' ];
 53+
 54+ var fields = ["emailAdd","fname","lname","street","city","state","zip","card_num","cvv" ],
 55+ numFields = fields.length,
 56+ i,
 57+ output = '',
 58+ currField = '';
 59+
 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+
 67+ if (document.getElementById('fname').value == '$first') {
 68+ output += payflowproGatewayErrorMsgJs + ' first name.\\r\\n';
 69+ }
 70+ if (document.getElementById('lname').value == '$last') {
 71+ output += payflowproGatewayErrorMsgJs + ' last name.\\r\\n';
 72+ }
 73+
 74+ // validate email address
 75+ var apos = document.payment.emailAdd.value.indexOf("@");
 76+ var dotpos = document.payment.emailAdd.value.lastIndexOf(".");
 77+
 78+ if( apos < 1 || dotpos-apos < 2 ) {
 79+ output += payflowproGatewayErrorMsgEmail;
 80+ }
 81+
 82+ if( output ) {
 83+ alert( output );
 84+ return false;
 85+ }
 86+}
4587 </script>
4688 EOT;
4789 $wgOut->addHeadItem( 'placeholders', $js );
@@ -90,7 +132,7 @@
91133
92134 // Xml::element seems to convert html to htmlentities
93135 $form .= "<p class='creditcard-error-msg'>" . $this->form_errors['retryMsg'] . "</p>";
94 - $form .= Xml::openElement( 'form', array( 'name' => 'payment', 'method' => 'post', 'action' => $this->getNoCacheAction(), 'onsubmit' => 'return validate_form(this)', 'autocomplete' => 'off' ) );
 136+ $form .= Xml::openElement( 'form', array( 'name' => 'payment', 'method' => 'post', 'action' => $this->getNoCacheAction(), 'onsubmit' => 'return formCheck(this)', 'autocomplete' => 'off' ) );
95137
96138 $form .= Xml::openElement( 'div', array( 'id' => 'left-column', 'class' => 'payflow-cc-form-section' ) );
97139 $form .= $this->generatePersonalContainer();
@@ -112,7 +154,7 @@
113155 $form .= Html::hidden( 'PaypalRedirect', false );
114156 $form .= Xml::element( 'input', array( 'class' => 'button-plain', 'value' => wfMsg( 'payflowpro_gateway-paypal-button' ), 'onclick' => 'document.payment.PaypalRedirect.value=\'true\';document.payment.submit();', 'type' => 'submit' ) );
115157 } else {
116 - $form .= Xml::element( 'input', array( 'class' => 'button-plain', 'value' => wfMsg( 'payflowpro_gateway-cc-button' ), 'onclick' => 'submit_form( this )', 'type' => 'submit' ) );
 158+ $form .= Xml::element( 'input', array( 'class' => 'button-plain', 'value' => wfMsg( 'payflowpro_gateway-cc-button' ), 'type' => 'submit' ) );
117159 $form .= Xml::closeElement( 'div' ); // close div#mw-donate-submit-button
118160 $form .= Xml::openElement( 'div', array( 'class' => 'mw-donate-submessage', 'id' => 'payflowpro_gateway-donate-submessage' ) ) .
119161 wfMsg( 'payflowpro_gateway-donate-click' );
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.i18n.php
@@ -98,7 +98,7 @@
9999 'payflowpro_gateway-question-comment' => 'Questions or comments? Contact: <a href="mailto:donate@wikimedia.org">donate@wikimedia.org</a>',
100100 'payflowpro_gateway-donate-click' => 'Your credit card will be securely processed.',
101101 'payflowpro_gateway-otherways' => 'There are <a href="http://wikimediafoundation.org/wiki/Ways_to_Give/en">other ways to give, including PayPal, check, or mail</a>.',
102 - 'payflowpro_gateway-otherways-alt' => 'There are <a href="http://wikimediafoundation.org/wiki/Ways_to_Give/en">other ways to give</a>, including check.',
 102+ 'payflowpro_gateway-otherways-alt' => 'There are <a href="http://wikimediafoundation.org/wiki/Ways_to_Give/en">other ways to give</a>, including by check.',
103103 'payflowpro_gateway-otherways-short' => '<a href="http://wikimediafoundation.org/wiki/Ways_to_Give/en">Other ways to give</a>',
104104 'payflowpro_gateway-paypal' => 'Have a PayPal account? <a href="$1/index.php/Special:PayflowProGateway?_cache_=true&paypal=true&masthead=none&form_name=$2&text_template=2010/JimmyAppealLong&language=en&utm_source=$3&utm_medium=$4&utm_campaign=$5">Donate with PayPal</a>.',
105105 'payflowpro_gateway-credit-storage-processing' => 'We do not store your credit card information, and your personal data is subject to our <a href="http://wikimediafoundation.org/wiki/Donor_Privacy_Policy">privacy policy</a>.',

Status & tagging log