r74456 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74455‎ | r74456 | r74457 >
Date:19:48, 7 October 2010
Author:awjrichards
Status:deferred
Tags:
Comment:
Refactored paypal button and opt-out form fields; Updated opt-out form fields to check if they were posted to remember deselection of fields
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/forms/TwoColumnPayPal.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumnPayPal.php
@@ -50,25 +50,14 @@
5151 }
5252
5353 protected function generatePersonalFields() {
54 - global $wgScriptPath, $wgPayflowGatewayTest, $wgPayflowGatewayPaypalURL;
55 - $scriptPath = "$wgScriptPath/extensions/DonationInterface/payflowpro_gateway/includes";
56 - $card_num = ( $wgPayflowGatewayTest ) ? $this->form_data[ 'card_num' ] : '';
57 - $cvv = ( $wgPayflowGatewayTest ) ? $this->form_data[ 'cvv' ] : '';
 54+ global $wgPayflowGatewayPaypalURL;
5855 $form = '';
5956
6057 // name
61 - $form .= '<tr>';
62 - $form .= '<td class="label">' . Xml::label( wfMsg( 'payflowpro_gateway-donor-name' ), 'fname' ) . '</td>';
63 - $form .= '<td>' . Xml::input( 'fname', '30', $this->form_data['fname'], array( 'type' => 'text', 'onfocus' => 'clearField( this, "First" )', 'maxlength' => '15', 'class' => 'required', 'id' => 'fname' ) ) .
64 - Xml::input( 'lname', '30', $this->form_data['lname'], array( 'type' => 'text', 'onfocus' => 'clearField( this, "Last" )', 'maxlength' => '15', 'id' => 'lname' ) ) . '<span class="creditcard-error-msg">' . ' ' . $this->form_errors['fname'] . '</span></td>';
65 - $form .= "</tr>";
 58+ $form .= $this->getNameField();
6659
6760 // email
68 - $form .= '<tr>';
69 - $form .= '<td class="label">' . Xml::label( wfMsg( 'payflowpro_gateway-donor-email' ), 'emailAdd' ) . '</td>';
70 - $form .= '<td>' . Xml::input( 'emailAdd', '30', $this->form_data['email'], array( 'type' => 'text', 'maxlength' => '64', 'id' => 'emailAdd', 'class' => 'fullwidth' ) ) .
71 - '<span class="creditcard-error-msg">' . ' ' . $this->form_errors['emailAdd'] . '</span></td>';
72 - $form .= '</tr>';
 61+ $form .= $this->getEmailField();
7362
7463 //comment message
7564 $form .= '<tr>';
@@ -84,38 +73,17 @@
8574 $form .= '</tr>';
8675
8776 // anonymous
88 - $comment_opt_value = ( $this->form_data[ 'numAttempt' ] ) ? $this->form_data[ 'comment-option' ] : true;
89 - $form .= '<tr>';
90 - $form .= '<td class="check-option" colspan="2">' . Xml::check( 'comment-option', $comment_opt_value );
91 - $form .= ' ' . Xml::label( wfMsg( 'donate_interface-anon-message' ), 'comment-option' ) . '</td>';
92 - $form .= '</tr>';
 77+ $fom .= $this->getCommentOptionField();
9378
9479 // email agreement
95 - $email_opt_value = ( $this->form_data[ 'numAttempt' ]) ? $this->form_data[ 'email-opt' ] : true;
96 - $form .= '<tr>';
97 - $form .= '<td class="check-option" colspan="2">' . Xml::check( 'email-opt', $email_opt_value );
98 - $form .= ' ';
99 - // put the label inside Xml::openElement so any HTML in the msg might get rendered (right, Germany?)
100 - $form .= Xml::openElement( 'label', array( 'for' => 'email-opt' ));
101 - $form .= wfMsg( 'donate_interface-email-agreement' );
102 - $form .= Xml::closeElement( 'label' );
103 - $form .= '</td>';
104 - $form .= '</tr>';
 80+ $form .= $this->getEmailOptField();
10581
10682 // amount
10783 $form .= $this->getAmountField();
10884
10985 // PayPal button
11086 if ( strlen( $wgPayflowGatewayPaypalURL )) {
111 - $form .= '<tr>';
112 - $form .= '<td class="paypal-button" colspan="2">';
113 - $form .= Xml::hidden( 'PaypalRedirect', false );
114 - $form .= Xml::tags( 'div',
115 - array(),
116 - '<a href="#" onclick="document.payment.PaypalRedirect.value=\'true\';document.payment.submit();"><img src="'.$scriptPath.'/donate_with_paypal.gif"/></a>'
117 - );
118 - $form .= '</td>';
119 - $form .= '</tr>';
 87+ $form .= $this->getPaypalButton();
12088 }
12189
12290 return $form;
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumn.php
@@ -148,10 +148,6 @@
149149 }
150150
151151 protected function generatePersonalFields() {
152 - global $wgScriptPath, $wgPayflowGatewayTest;
153 - $scriptPath = "$wgScriptPath/extensions/DonationInterface/payflowpro_gateway";
154 - $card_num = ( $wgPayflowGatewayTest ) ? $this->form_data[ 'card_num' ] : '';
155 - $cvv = ( $wgPayflowGatewayTest ) ? $this->form_data[ 'cvv' ] : '';
156152 $form = '';
157153
158154 // name
@@ -174,23 +170,10 @@
175171 $form .= '</tr>';
176172
177173 // anonymous
178 - $comment_opt_value = ( $this->form_data[ 'numAttempt' ] ) ? $this->form_data[ 'comment-option' ] : true;
179 - $form .= '<tr>';
180 - $form .= '<td class="check-option" colspan="2">' . Xml::check( 'comment-option', $comment_opt_value );
181 - $form .= ' ' . Xml::label( wfMsg( 'donate_interface-anon-message' ), 'comment-option' ) . '</td>';
182 - $form .= '</tr>';
 174+ $form .= $this->getCommentOptionField();
183175
184176 // email agreement
185 - $email_opt_value = ( $this->form_data[ 'numAttempt' ]) ? $this->form_data[ 'email-opt' ] : true;
186 - $form .= '<tr>';
187 - $form .= '<td class="check-option" colspan="2">' . Xml::check( 'email-opt', $email_opt_value );
188 - $form .= ' ';
189 - // put the label inside Xml::openElement so any HTML in the msg might get rendered (right, Germany?)
190 - $form .= Xml::openElement( 'label', array( 'for' => 'email-opt' ));
191 - $form .= wfMsg( 'donate_interface-email-agreement' );
192 - $form .= Xml::closeElement( 'label' );
193 - $form .= '</td>';
194 - $form .= '</tr>';
 177+ $form .= $this->getEmailOptField();
195178
196179 // amount
197180 $form .= $this->getAmountField();
@@ -214,8 +197,6 @@
215198
216199 protected function generatePaymentFields() {
217200 global $wgScriptPath, $wgPayflowGatewayTest;
218 -
219 -
220201
221202 $form = '';
222203
@@ -383,4 +364,45 @@
384365 $form .= "</tr>";
385366 return $form;
386367 }
 368+
 369+ protected function getCommentOptionField() {
 370+ global $wgRequest;
 371+ $comment_opt_value = ( $wgRequest->wasPosted() ) ? $this->form_data[ 'comment-option' ] : true;
 372+ $form = '<tr>';
 373+ $form .= '<td class="check-option" colspan="2">' . Xml::check( 'comment-option', $comment_opt_value );
 374+ $form .= ' ' . Xml::label( wfMsg( 'donate_interface-anon-message' ), 'comment-option' ) . '</td>';
 375+ $form .= '</tr>';
 376+ return $form;
 377+ }
 378+
 379+ protected function getEmailOptField() {
 380+ global $wgRequest;
 381+ $email_opt_value = ( $wgRequest->wasPosted() ) ? $this->form_data[ 'email-opt' ] : true;
 382+ $form = '<tr>';
 383+ $form .= '<td class="check-option" colspan="2">' . Xml::check( 'email-opt', $email_opt_value );
 384+ $form .= ' ';
 385+ // put the label inside Xml::openElement so any HTML in the msg might get rendered (right, Germany?)
 386+ $form .= Xml::openElement( 'label', array( 'for' => 'email-opt' ));
 387+ $form .= wfMsg( 'donate_interface-email-agreement' );
 388+ $form .= Xml::closeElement( 'label' );
 389+ $form .= '</td>';
 390+ $form .= '</tr>';
 391+ return $form;
 392+ }
 393+
 394+ protected function getPaypalButton() {
 395+ global $wgScriptPath;
 396+ $scriptPath = "$wgScriptPath/extensions/DonationInterface/payflowpro_gateway/includes";
 397+
 398+ $form = '<tr>';
 399+ $form .= '<td class="paypal-button" colspan="2">';
 400+ $form .= Xml::hidden( 'PaypalRedirect', false );
 401+ $form .= Xml::tags( 'div',
 402+ array(),
 403+ '<a href="#" onclick="document.payment.PaypalRedirect.value=\'true\';document.payment.submit();"><img src="'.$scriptPath.'/donate_with_paypal.gif"/></a>'
 404+ );
 405+ $form .= '</td>';
 406+ $form .= '</tr>';
 407+ return $form;
 408+ }
387409 }
\ No newline at end of file
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumnLetter.php
@@ -90,7 +90,7 @@
9191 }
9292
9393 protected function generateBillingFields() {
94 - global $wgScriptPath, $wgPayflowGatewayTest, $wgPayflowGatewayPaypalURL;
 94+ global $wgScriptPath, $wgPayflowGatewayPaypalURL;
9595 $scriptPath = "$wgScriptPath/extensions/DonationInterface/payflowpro_gateway/includes";
9696
9797 $form = '';
@@ -115,23 +115,10 @@
116116 $form .= '</tr>';
117117
118118 // anonymous
119 - $comment_opt_value = ( $this->form_data[ 'numAttempt' ] ) ? $this->form_data[ 'comment-option' ] : true;
120 - $form .= '<tr>';
121 - $form .= '<td class="check-option" colspan="2">' . Xml::check( 'comment-option', $comment_opt_value );
122 - $form .= ' ' . Xml::label( wfMsg( 'donate_interface-anon-message' ), 'comment-option' ) . '</td>';
123 - $form .= '</tr>';
 119+ $form .= $this->getCommentOptionField();
124120
125121 // email agreement
126 - $email_opt_value = ( $this->form_data[ 'numAttempt' ]) ? $this->form_data[ 'email-opt' ] : true;
127 - $form .= '<tr>';
128 - $form .= '<td class="check-option" colspan="2">' . Xml::check( 'email-opt', $email_opt_value );
129 - $form .= ' ';
130 - // put the label inside Xml::openElement so any HTML in the msg might get rendered (right, Germany?)
131 - $form .= Xml::openElement( 'label', array( 'for' => 'email-opt' ));
132 - $form .= wfMsg( 'donate_interface-email-agreement' );
133 - $form .= Xml::closeElement( 'label' );
134 - $form .= '</td>';
135 - $form .= '</tr>';
 122+ $form .= $this->getEmailOptField();
136123
137124 // amount
138125 $form .= $this->getAmountField();
@@ -140,15 +127,7 @@
141128 // PayPal button
142129 // make sure we have a paypal url set to redirect the user to before displaying the button
143130 if ( strlen( $wgPayflowGatewayPaypalURL )) {
144 - $form .= '<tr>';
145 - $form .= '<td class="paypal-button" colspan="2">';
146 - $form .= Xml::hidden( 'PaypalRedirect', false );
147 - $form .= Xml::tags( 'div',
148 - array(),
149 - '<a href="#" onclick="document.payment.PaypalRedirect.value=\'true\';document.payment.submit();"><img src="'.$scriptPath.'/donate_with_paypal.gif"/></a>'
150 - );
151 - $form .= '</td>';
152 - $form .= '</tr>';
 131+ $form .= $this->getPaypalButton();
153132 }
154133
155134 // card logos

Status & tagging log