Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoStepTwoColumn.php |
— | — | @@ -2,207 +2,207 @@ |
3 | 3 | |
4 | 4 | class PayflowProGateway_Form_TwoStepTwoColumn extends PayflowProGateway_Form { |
5 | 5 | |
6 | | - public function __construct( &$form_data, &$form_errors ) { |
7 | | - global $wgOut, $wgScriptPath; |
| 6 | + public function __construct( &$form_data, &$form_errors ) { |
| 7 | + global $wgOut, $wgScriptPath; |
8 | 8 | |
9 | | - parent::__construct( $form_data, $form_errors ); |
| 9 | + parent::__construct( $form_data, $form_errors ); |
10 | 10 | |
11 | | - // we only want to load this JS if the form is being rendered |
12 | | - $this->loadValidateJs(); // validation JS |
| 11 | + // we only want to load this JS if the form is being rendered |
| 12 | + $this->loadValidateJs(); // validation JS |
13 | 13 | |
14 | | - $first = wfMsg( 'payflowpro_gateway-first' ); |
15 | | - $last = wfMsg( 'payflowpro_gateway-last' ); |
16 | | - $js = <<<EOT |
| 14 | + $first = wfMsg( 'payflowpro_gateway-first' ); |
| 15 | + $last = wfMsg( 'payflowpro_gateway-last' ); |
| 16 | + $js = <<<EOT |
17 | 17 | <script type="text/javascript"> |
18 | 18 | function loadPlaceholders() { |
19 | | - var fname = document.getElementById('fname'); |
20 | | - var lname = document.getElementById('lname'); |
21 | | - var amountOther = document.getElementById('amountOther'); |
22 | | - if (fname.value == '') { |
23 | | - fname.style.color = '#999999'; |
24 | | - fname.value = '$first'; |
25 | | - } |
26 | | - if (lname.value == '') { |
27 | | - lname.style.color = '#999999'; |
28 | | - lname.value = '$last'; |
29 | | - } |
| 19 | + var fname = document.getElementById('fname'); |
| 20 | + var lname = document.getElementById('lname'); |
| 21 | + var amountOther = document.getElementById('amountOther'); |
| 22 | + if (fname.value == '') { |
| 23 | + fname.style.color = '#999999'; |
| 24 | + fname.value = '$first'; |
| 25 | + } |
| 26 | + if (lname.value == '') { |
| 27 | + lname.style.color = '#999999'; |
| 28 | + lname.value = '$last'; |
| 29 | + } |
30 | 30 | } |
31 | 31 | addEvent( window, 'load', loadPlaceholders ); |
32 | 32 | </script> |
33 | 33 | EOT; |
34 | | - $wgOut->addHeadItem( 'placeholders', $js ); |
35 | | - } |
| 34 | + $wgOut->addHeadItem( 'placeholders', $js ); |
| 35 | + } |
36 | 36 | |
37 | | - /** |
38 | | - * Required method for constructing the entire form |
39 | | - * |
40 | | - * This can of course be overloaded by a child class. |
41 | | - * @return string The entire form HTML |
42 | | - */ |
43 | | - public function getForm() { |
44 | | - $form = $this->generateFormStart(); |
45 | | - $form .= $this->getCaptchaHTML(); |
46 | | - $form .= $this->generateFormSubmit(); |
47 | | - $form .= $this->generateFormEnd(); |
48 | | - return $form; |
49 | | - } |
| 37 | + /** |
| 38 | + * Required method for constructing the entire form |
| 39 | + * |
| 40 | + * This can of course be overloaded by a child class. |
| 41 | + * @return string The entire form HTML |
| 42 | + */ |
| 43 | + public function getForm() { |
| 44 | + $form = $this->generateFormStart(); |
| 45 | + $form .= $this->getCaptchaHTML(); |
| 46 | + $form .= $this->generateFormSubmit(); |
| 47 | + $form .= $this->generateFormEnd(); |
| 48 | + return $form; |
| 49 | + } |
50 | 50 | |
51 | | - public function generateFormStart() { |
52 | | - global $wgPayflowGatewayHeader, $wgPayflwGatewayTest, $wgOut; |
53 | | - $form = $this->generateBannerHeader(); |
| 51 | + public function generateFormStart() { |
| 52 | + global $wgPayflowGatewayHeader, $wgPayflwGatewayTest, $wgOut; |
| 53 | + $form = $this->generateBannerHeader(); |
54 | 54 | |
55 | | - $form .= Xml::openElement( 'div', array( 'id' => 'mw-creditcard' ) ); |
| 55 | + $form .= Xml::openElement( 'div', array( 'id' => 'mw-creditcard' ) ); |
56 | 56 | |
57 | | - // provide a place at the top of the form for displaying general messages |
58 | | - if ( $this->form_errors['general'] ) { |
59 | | - $form .= Xml::openElement( 'div', array( 'id' => 'mw-payflow-general-error' )); |
60 | | - if ( is_array( $this->form_errors['general'] )) { |
61 | | - foreach ( $this->form_errors['general'] as $this->form_errors_msg ) { |
62 | | - $form .= Xml::tags( 'p', array( 'class' => 'creditcard-error-msg' ), $this->form_errors_msg ); |
63 | | - } |
64 | | - } else { |
65 | | - $form .= Xml::tags( 'p', array( 'class' => 'creditcard-error-msg' ), $this->form_errors_msg ); |
66 | | - } |
67 | | - $form .= Xml::closeElement( 'div' ); |
68 | | - } |
| 57 | + // provide a place at the top of the form for displaying general messages |
| 58 | + if ( $this->form_errors['general'] ) { |
| 59 | + $form .= Xml::openElement( 'div', array( 'id' => 'mw-payflow-general-error' )); |
| 60 | + if ( is_array( $this->form_errors['general'] )) { |
| 61 | + foreach ( $this->form_errors['general'] as $this->form_errors_msg ) { |
| 62 | + $form .= Xml::tags( 'p', array( 'class' => 'creditcard-error-msg' ), $this->form_errors_msg ); |
| 63 | + } |
| 64 | + } else { |
| 65 | + $form .= Xml::tags( 'p', array( 'class' => 'creditcard-error-msg' ), $this->form_errors_msg ); |
| 66 | + } |
| 67 | + $form .= Xml::closeElement( 'div' ); |
| 68 | + } |
69 | 69 | |
70 | | - // add noscript tags for javascript disabled browsers |
71 | | - $form .= $this->getNoScript(); |
72 | | - |
73 | | - // open form |
74 | | - $form .= Xml::openElement( 'div', array( 'id' => 'mw-creditcard-form' ) ); |
| 70 | + // add noscript tags for javascript disabled browsers |
| 71 | + $form .= $this->getNoScript(); |
75 | 72 | |
76 | | - // Xml::element seems to convert html to htmlentities |
77 | | - $form .= "<p class='creditcard-error-msg'>" . $this->form_errors['retryMsg'] . "</p>"; |
78 | | - $form .= Xml::openElement( 'form', array( 'name' => 'payment', 'method' => 'post', 'action' => $this->getNoCacheAction(), 'onsubmit' => 'return validate_form(this)', 'autocomplete' => 'off' ) ); |
| 73 | + // open form |
| 74 | + $form .= Xml::openElement( 'div', array( 'id' => 'mw-creditcard-form' ) ); |
79 | 75 | |
80 | | - $form .= Xml::openElement( 'div', array( 'id' => 'left-column', 'class' => 'payflow-cc-form-section')); |
81 | | - $form .= $this->generatePersonalContainer(); |
82 | | - $form .= Xml::closeElement( 'div' ); // close div#left-column |
| 76 | + // Xml::element seems to convert html to htmlentities |
| 77 | + $form .= "<p class='creditcard-error-msg'>" . $this->form_errors['retryMsg'] . "</p>"; |
| 78 | + $form .= Xml::openElement( 'form', array( 'name' => 'payment', 'method' => 'post', 'action' => $this->getNoCacheAction(), 'onsubmit' => 'return validate_form(this)', 'autocomplete' => 'off' ) ); |
83 | 79 | |
84 | | - $form .= Xml::openElement( 'div', array( 'id' => 'right-column', 'class' => 'payflow-cc-form-section' )); |
85 | | - $form .= $this->generatePaymentContainer(); |
| 80 | + $form .= Xml::openElement( 'div', array( 'id' => 'left-column', 'class' => 'payflow-cc-form-section')); |
| 81 | + $form .= $this->generatePersonalContainer(); |
| 82 | + $form .= Xml::closeElement( 'div' ); // close div#left-column |
86 | 83 | |
87 | | - return $form; |
88 | | - } |
| 84 | + $form .= Xml::openElement( 'div', array( 'id' => 'right-column', 'class' => 'payflow-cc-form-section' )); |
| 85 | + $form .= $this->generatePaymentContainer(); |
89 | 86 | |
90 | | - public function generateFormSubmit() { |
91 | | - // submit button |
92 | | - $form = Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-form-submit')); |
93 | | - $form .= Xml::openElement( 'div', array( 'id' => 'mw-donate-submit-button' )); |
94 | | - //$form .= Xml::submitButton( wfMsg( 'payflowpro_gateway-submit-button' )); |
95 | | - $form .= Xml::element( 'input', array( 'class' => 'button-plain', 'value' => wfMsg( 'payflowpro_gateway-cc-button'), 'onclick' => 'submit_form( this )', 'type' => 'submit')); |
96 | | - $form .= Xml::closeElement( 'div' ); // close div#mw-donate-submit-button |
97 | | - $form .= Xml::openElement( 'div', array( 'class' => 'mw-donate-submessage', 'id' => 'payflowpro_gateway-donate-submessage' ) ) . |
98 | | - wfMsg( 'payflowpro_gateway-donate-click' ); |
99 | | - $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-donate-submessage |
100 | | - $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-form-submit |
101 | | - return $form; |
102 | | - } |
| 87 | + return $form; |
| 88 | + } |
103 | 89 | |
104 | | - public function generateFormEnd() { |
105 | | - $form = ''; |
106 | | - // add hidden fields |
107 | | - $hidden_fields = $this->getHiddenFields(); |
108 | | - foreach ( $hidden_fields as $field => $value ) { |
109 | | - $form .= Xml::hidden( $field, $value ); |
110 | | - } |
111 | | - $form .= Xml::closeElement( 'div' ); // close div#right-column |
112 | | - $form .= Xml::closeElement( 'form' ); |
113 | | - $form .= Xml::closeElement( 'div' ); // close div#mw-creditcard-form |
114 | | - $form .= $this->generateDonationFooter(); |
115 | | - $form .= Xml::closeElement( 'div' ); // div#close mw-creditcard |
116 | | - return $form; |
117 | | - } |
| 90 | + public function generateFormSubmit() { |
| 91 | + // submit button |
| 92 | + $form = Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-form-submit')); |
| 93 | + $form .= Xml::openElement( 'div', array( 'id' => 'mw-donate-submit-button' )); |
| 94 | + //$form .= Xml::submitButton( wfMsg( 'payflowpro_gateway-submit-button' )); |
| 95 | + $form .= Xml::element( 'input', array( 'class' => 'button-plain', 'value' => wfMsg( 'payflowpro_gateway-cc-button'), 'onclick' => 'submit_form( this )', 'type' => 'submit')); |
| 96 | + $form .= Xml::closeElement( 'div' ); // close div#mw-donate-submit-button |
| 97 | + $form .= Xml::openElement( 'div', array( 'class' => 'mw-donate-submessage', 'id' => 'payflowpro_gateway-donate-submessage' ) ) . |
| 98 | + wfMsg( 'payflowpro_gateway-donate-click' ); |
| 99 | + $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-donate-submessage |
| 100 | + $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-form-submit |
| 101 | + return $form; |
| 102 | + } |
118 | 103 | |
119 | | - protected function generatePersonalContainer() { |
120 | | - $form = ''; |
121 | | - $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-personal-info' )); ; |
122 | | - $form .= Xml::tags( 'h3', array( 'class' => 'payflow-cc-form-header','id' => 'payflow-cc-form-header-personal' ), wfMsg( 'payflowpro_gateway-cc-form-header-personal' )); |
123 | | - $form .= Xml::openElement( 'table', array( 'id' => 'payflow-table-donor' ) ); |
| 104 | + public function generateFormEnd() { |
| 105 | + $form = ''; |
| 106 | + // add hidden fields |
| 107 | + $hidden_fields = $this->getHiddenFields(); |
| 108 | + foreach ( $hidden_fields as $field => $value ) { |
| 109 | + $form .= Xml::hidden( $field, $value ); |
| 110 | + } |
| 111 | + $form .= Xml::closeElement( 'div' ); // close div#right-column |
| 112 | + $form .= Xml::closeElement( 'form' ); |
| 113 | + $form .= Xml::closeElement( 'div' ); // close div#mw-creditcard-form |
| 114 | + $form .= $this->generateDonationFooter(); |
| 115 | + $form .= Xml::closeElement( 'div' ); // div#close mw-creditcard |
| 116 | + return $form; |
| 117 | + } |
124 | 118 | |
125 | | - $form .= $this->generatePersonalFields(); |
| 119 | + protected function generatePersonalContainer() { |
| 120 | + $form = ''; |
| 121 | + $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-personal-info' )); ; |
| 122 | + $form .= Xml::tags( 'h3', array( 'class' => 'payflow-cc-form-header','id' => 'payflow-cc-form-header-personal' ), wfMsg( 'payflowpro_gateway-cc-form-header-personal' )); |
| 123 | + $form .= Xml::openElement( 'table', array( 'id' => 'payflow-table-donor' ) ); |
126 | 124 | |
127 | | - $form .= Xml::closeElement( 'table' ); // close table#payflow-table-donor |
128 | | - $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-personal-info |
| 125 | + $form .= $this->generatePersonalFields(); |
129 | 126 | |
130 | | - return $form; |
131 | | - } |
| 127 | + $form .= Xml::closeElement( 'table' ); // close table#payflow-table-donor |
| 128 | + $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-personal-info |
132 | 129 | |
133 | | - protected function generatePersonalFields() { |
134 | | - // first name |
135 | | - $form = $this->getNameField(); |
| 130 | + return $form; |
| 131 | + } |
136 | 132 | |
137 | | - // country |
138 | | - $form .= $this->getCountryField(); |
| 133 | + protected function generatePersonalFields() { |
| 134 | + // first name |
| 135 | + $form = $this->getNameField(); |
139 | 136 | |
140 | | - // street |
141 | | - $form .= $this->getStreetField(); |
| 137 | + // country |
| 138 | + $form .= $this->getCountryField(); |
142 | 139 | |
| 140 | + // street |
| 141 | + $form .= $this->getStreetField(); |
143 | 142 | |
144 | | - // city |
145 | | - $form .= $this->getCityField(); |
146 | 143 | |
147 | | - // state |
148 | | - $form .= $this->getStateField(); |
| 144 | + // city |
| 145 | + $form .= $this->getCityField(); |
149 | 146 | |
150 | | - // zip |
151 | | - $form .= $this->getZipField(); |
| 147 | + // state |
| 148 | + $form .= $this->getStateField(); |
152 | 149 | |
153 | | - // email |
154 | | - $form .= $this->getEmailField(); |
| 150 | + // zip |
| 151 | + $form .= $this->getZipField(); |
155 | 152 | |
156 | | - return $form; |
157 | | - } |
| 153 | + // email |
| 154 | + $form .= $this->getEmailField(); |
158 | 155 | |
159 | | - protected function generatePaymentContainer() { |
160 | | - $form = ''; |
161 | | - // credit card info |
162 | | - $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-payment-info' )); |
163 | | - $form .= Xml::tags( 'h3', array( 'class' => 'payflow-cc-form-header', 'id' => 'payflow-cc-form-header-payment' ), wfMsg( 'payflowpro_gateway-cc-form-header-payment' )); |
164 | | - $form .= Xml::openElement( 'table', array( 'id' => 'payflow-table-cc' ) ); |
| 156 | + return $form; |
| 157 | + } |
165 | 158 | |
166 | | - $form .= $this->generatePaymentFields(); |
| 159 | + protected function generatePaymentContainer() { |
| 160 | + $form = ''; |
| 161 | + // credit card info |
| 162 | + $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-payment-info' )); |
| 163 | + $form .= Xml::tags( 'h3', array( 'class' => 'payflow-cc-form-header', 'id' => 'payflow-cc-form-header-payment' ), wfMsg( 'payflowpro_gateway-cc-form-header-payment' )); |
| 164 | + $form .= Xml::openElement( 'table', array( 'id' => 'payflow-table-cc' ) ); |
167 | 165 | |
168 | | - $form .= Xml::closeElement( 'table' ); // close table#payflow-table-cc |
169 | | - $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-payment-info |
| 166 | + $form .= $this->generatePaymentFields(); |
170 | 167 | |
171 | | - return $form; |
172 | | - } |
| 168 | + $form .= Xml::closeElement( 'table' ); // close table#payflow-table-cc |
| 169 | + $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-payment-info |
173 | 170 | |
174 | | - protected function generatePaymentFields() { |
175 | | - global $wgScriptPath, $wgPayflowGatewayTest; |
| 171 | + return $form; |
| 172 | + } |
176 | 173 | |
177 | | - $form = ''; |
| 174 | + protected function generatePaymentFields() { |
| 175 | + global $wgScriptPath, $wgPayflowGatewayTest; |
178 | 176 | |
179 | | - // amount |
180 | | - $form = '<tr>'; |
181 | | - $form .= '<td colspan="2"><span class="creditcard-error-msg">' . $this->form_errors['invalidamount'] . '</span></td>'; |
182 | | - $form .= '</tr>'; |
183 | | - $form .= '<tr>'; |
184 | | - $form .= '<td class="label">' . Xml::label(wfMsg( 'payflowpro_gateway-donor-amount' ), 'amount') . '</td>'; |
185 | | - $form .= '<td>' . Xml::input( 'amount', '7', $this->form_data['amount'], array( 'type' => 'text', 'maxlength' => '10', 'id' => 'amount' ) ) . |
186 | | - ' ' . $this->generateCurrencyDropdown() . '</td>'; |
187 | | - $form .= '</tr>'; |
| 177 | + $form = ''; |
188 | 178 | |
189 | | - // card logos |
190 | | - $form .= '<tr>'; |
191 | | - $form .= '<td />'; |
192 | | - $form .= '<td>' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/credit_card_logos.gif" )) . '</td>'; |
193 | | - $form .= '</tr>'; |
| 179 | + // amount |
| 180 | + $form = '<tr>'; |
| 181 | + $form .= '<td colspan="2"><span class="creditcard-error-msg">' . $this->form_errors['invalidamount'] . '</span></td>'; |
| 182 | + $form .= '</tr>'; |
| 183 | + $form .= '<tr>'; |
| 184 | + $form .= '<td class="label">' . Xml::label(wfMsg( 'payflowpro_gateway-donor-amount' ), 'amount') . '</td>'; |
| 185 | + $form .= '<td>' . Xml::input( 'amount', '7', $this->form_data['amount'], array( 'type' => 'text', 'maxlength' => '10', 'id' => 'amount' ) ) . |
| 186 | + ' ' . $this->generateCurrencyDropdown() . '</td>'; |
| 187 | + $form .= '</tr>'; |
194 | 188 | |
195 | | - // credit card type |
196 | | - $form .= $this->getCreditCardTypeField(); |
| 189 | + // card logos |
| 190 | + $form .= '<tr>'; |
| 191 | + $form .= '<td />'; |
| 192 | + $form .= '<td>' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/credit_card_logos.gif" )) . '</td>'; |
| 193 | + $form .= '</tr>'; |
197 | 194 | |
198 | | - // card number |
199 | | - $form .= $this->getCardnumberField(); |
| 195 | + // credit card type |
| 196 | + $form .= $this->getCreditCardTypeField(); |
200 | 197 | |
201 | | - // expiry |
202 | | - $form .= $this->getExpiryField(); |
| 198 | + // card number |
| 199 | + $form .= $this->getCardnumberField(); |
203 | 200 | |
204 | | - // cvv |
205 | | - $form .= $this->getCvvField(); |
| 201 | + // expiry |
| 202 | + $form .= $this->getExpiryField(); |
206 | 203 | |
207 | | - return $form; |
208 | | - } |
| 204 | + // cvv |
| 205 | + $form .= $this->getCvvField(); |
| 206 | + |
| 207 | + return $form; |
| 208 | + } |
209 | 209 | } |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoStepTwoColumnLetter.php |
— | — | @@ -3,44 +3,44 @@ |
4 | 4 | class PayflowProGateway_Form_TwoStepTwoColumnLetter extends PayflowProGateway_Form_TwoStepTwoColumn { |
5 | 5 | public function __construct( &$form_data, &$form_errors ) { |
6 | 6 | global $wgOut, $wgScriptPath; |
7 | | - |
| 7 | + |
8 | 8 | // set the path to css, before the parent constructor is called, checking to make sure some child class hasn't already set this |
9 | 9 | if ( !strlen( $this->getStylePath())) { |
10 | 10 | $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoStepTwoColumnLetter.css' ); |
11 | 11 | } |
12 | | - |
| 12 | + |
13 | 13 | parent::__construct( $form_data, $form_errors ); |
14 | 14 | } |
15 | 15 | |
16 | 16 | public function generateFormStart() { |
17 | 17 | global $wgOut, $wgRequest; |
18 | | - |
| 18 | + |
19 | 19 | $form = parent::generateBannerHeader(); |
20 | | - |
| 20 | + |
21 | 21 | $form .= Xml::openElement( 'table', array( 'width' => '100%', 'cellspacing' => 0, 'cellpadding' => 0, 'border' => 0)); |
22 | | - |
| 22 | + |
23 | 23 | $form .= Xml::openElement( 'tr' ); |
24 | | - |
| 24 | + |
25 | 25 | $form .= Xml::openElement( 'td', array( 'id' => 'appeal', 'valign' => 'top' ) ); |
26 | | - |
| 26 | + |
27 | 27 | $text_template = $wgRequest->getText( 'text_template', '2010/JimmyAppealLong' ); |
28 | 28 | // if the user has uselang set, honor that, otherwise default to the language set for the form defined by 'language' in the query string |
29 | 29 | if ( $wgRequest->getText( 'language' )) $text_template .= '/' . $this->form_data[ 'language' ]; |
30 | | - |
| 30 | + |
31 | 31 | $template = ( strlen( $text_template )) ? $wgOut->parse( '{{'.$text_template.'}}' ) : ''; |
32 | 32 | // if the template doesn't exist, prevent the display of the red link |
33 | 33 | if ( preg_match( '/redlink\=1/', $template )) $template = NULL; |
34 | 34 | $form .= $template; |
35 | | - |
| 35 | + |
36 | 36 | $form .= Xml::closeElement( 'td' ); |
37 | | - |
| 37 | + |
38 | 38 | $form .= Xml::openElement( 'td', array( 'id' => 'donate', 'valign' => 'top' ) ); |
39 | | - |
| 39 | + |
40 | 40 | // add noscript tags for javascript disabled browsers |
41 | 41 | $form .= $this->getNoScript(); |
42 | | - |
| 42 | + |
43 | 43 | $form .= Xml::tags( 'h2', array( 'id' => 'donate-head' ), wfMsg( 'payflowpro_gateway-make-your-donation' )); |
44 | | - |
| 44 | + |
45 | 45 | // provide a place at the top of the form for displaying general messages |
46 | 46 | if ( $this->form_errors['general'] ) { |
47 | 47 | $form .= Xml::openElement( 'div', array( 'id' => 'mw-payflow-general-error' )); |
— | — | @@ -57,17 +57,17 @@ |
58 | 58 | // Xml::element seems to convert html to htmlentities |
59 | 59 | $form .= "<p class='creditcard-error-msg'>" . $this->form_errors['retryMsg'] . "</p>"; |
60 | 60 | $form .= Xml::openElement( 'form', array( 'name' => 'payment', 'method' => 'post', 'action' => $this->getNoCacheAction(), 'onsubmit' => 'return validate_form(this)', 'autocomplete' => 'off' ) ); |
61 | | - |
| 61 | + |
62 | 62 | $form .= $this->generateBillingContainer(); |
63 | 63 | return $form; |
64 | 64 | } |
65 | | - |
| 65 | + |
66 | 66 | public function generateFormEnd() { |
67 | 67 | $form = ''; |
68 | 68 | $form .= $this->generateFormClose(); |
69 | 69 | return $form; |
70 | 70 | } |
71 | | - |
| 71 | + |
72 | 72 | protected function generateBillingContainer() { |
73 | 73 | $form = ''; |
74 | 74 | $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-personal-info' )); |
— | — | @@ -82,37 +82,37 @@ |
83 | 83 | protected function generateBillingFields() { |
84 | 84 | global $wgScriptPath; |
85 | 85 | $scriptPath = "$wgScriptPath/extensions/DonationInterface/payflowpro_gateway/includes"; |
86 | | - |
| 86 | + |
87 | 87 | $form = ''; |
88 | | - |
89 | | - // name |
| 88 | + |
| 89 | + // name |
90 | 90 | $form .= $this->getNameField(); |
91 | | - |
| 91 | + |
92 | 92 | // email |
93 | 93 | $form .= $this->getEmailField(); |
94 | | - |
| 94 | + |
95 | 95 | // amount |
96 | 96 | $form .= '<tr>'; |
97 | 97 | $form .= '<td colspan="2"><span class="creditcard-error-msg">' . $this->form_errors['invalidamount'] . '</span></td>'; |
98 | 98 | $form .= '</tr>'; |
99 | 99 | $form .= '<tr>'; |
100 | 100 | $form .= '<td class="label">' . Xml::label(wfMsg( 'payflowpro_gateway-donor-amount' ), 'amount') . '</td>'; |
101 | | - $form .= '<td>' . Xml::input( 'amount', '7', $this->form_data['amount'], array( 'type' => 'text', 'maxlength' => '10', 'id' => 'amount' ) ) . |
| 101 | + $form .= '<td>' . Xml::input( 'amount', '7', $this->form_data['amount'], array( 'type' => 'text', 'maxlength' => '10', 'id' => 'amount' ) ) . |
102 | 102 | ' ' . $this->generateCurrencyDropdown() . '</td>'; |
103 | 103 | $form .= '</tr>'; |
104 | | - |
| 104 | + |
105 | 105 | // card logos |
106 | 106 | $form .= '<tr>'; |
107 | 107 | $form .= '<td />'; |
108 | 108 | $form .= '<td>' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/credit_card_logos.gif" )) . '</td>'; |
109 | 109 | $form .= '</tr>'; |
110 | | - |
| 110 | + |
111 | 111 | // card number |
112 | 112 | $form .= $this->getCardNumberField(); |
113 | | - |
| 113 | + |
114 | 114 | // cvv |
115 | 115 | $form .= $this->getCvvField(); |
116 | | - |
| 116 | + |
117 | 117 | // expiry |
118 | 118 | $form .= $this->getExpiryField(); |
119 | 119 | |
— | — | @@ -126,7 +126,7 @@ |
127 | 127 | $form .= $this->getStateField(); |
128 | 128 | // zip |
129 | 129 | $form .= $this->getZipField(); |
130 | | - |
| 130 | + |
131 | 131 | // country |
132 | 132 | $form .= $this->getCountryField(); |
133 | 133 | |
— | — | @@ -138,12 +138,12 @@ |
139 | 139 | */ |
140 | 140 | public function generateFormClose() { |
141 | 141 | $form = ''; |
142 | | - // add hidden fields |
| 142 | + // add hidden fields |
143 | 143 | $hidden_fields = $this->getHiddenFields(); |
144 | 144 | foreach ( $hidden_fields as $field => $value ) { |
145 | 145 | $form .= Xml::hidden( $field, $value ); |
146 | 146 | } |
147 | | - |
| 147 | + |
148 | 148 | $form .= Xml::closeElement( 'form' ); // close form 'payment' |
149 | 149 | $form .= $this->generateDonationFooter(); |
150 | 150 | $form .= Xml::closeElement( 'td' ); |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumnPayPal.php |
— | — | @@ -1,18 +1,17 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class PayflowProGateway_Form_TwoColumnPayPal extends PayflowProGateway_Form_OneStepTwoColumn { |
5 | | - |
6 | 5 | public function __construct( &$form_data, &$form_errors ) { |
7 | | - |
| 6 | + |
8 | 7 | parent::__construct( $form_data, $form_errors ); |
9 | 8 | } |
10 | | - |
| 9 | + |
11 | 10 | public function generateFormStart() { |
12 | 11 | global $wgPayflowGatewayHeader, $wgPayflwGatewayTest, $wgOut; |
13 | 12 | $form = $this->generateBannerHeader(); |
14 | | - |
15 | | - $form .= Xml::openElement( 'div', array( 'id' => 'mw-creditcard' ) ); |
16 | | - |
| 13 | + |
| 14 | + $form .= Xml::openElement( 'div', array( 'id' => 'mw-creditcard' ) ); |
| 15 | + |
17 | 16 | // provide a place at the top of the form for displaying general messages |
18 | 17 | if ( $this->form_errors['general'] ) { |
19 | 18 | $form .= Xml::openElement( 'div', array( 'id' => 'mw-payflow-general-error' )); |
— | — | @@ -28,33 +27,33 @@ |
29 | 28 | |
30 | 29 | // add noscript tags for javascript disabled browsers |
31 | 30 | $form .= $this->getNoScript(); |
32 | | - |
| 31 | + |
33 | 32 | // open form |
34 | 33 | $form .= Xml::openElement( 'div', array( 'id' => 'mw-creditcard-form' ) ); |
35 | | - |
| 34 | + |
36 | 35 | // Xml::element seems to convert html to htmlentities |
37 | 36 | $form .= "<p class='creditcard-error-msg'>" . $this->form_errors['retryMsg'] . "</p>"; |
38 | 37 | $form .= Xml::openElement( 'form', array( 'name' => 'payment', 'method' => 'post', 'action' => $this->getNoCacheAction(), 'onsubmit' => 'return validate_form(this)', 'autocomplete' => 'off' ) ); |
39 | | - |
| 38 | + |
40 | 39 | $form .= Xml::openElement( 'div', array( 'id' => 'left-column', 'class' => 'payflow-cc-form-section')); |
41 | 40 | $form .= $this->generatePersonalContainer(); |
42 | 41 | $form .= Xml::closeElement( 'div' ); // close div#left-column |
43 | | - |
| 42 | + |
44 | 43 | $form .= Xml::openElement( 'div', array( 'id' => 'right-column', 'class' => 'payflow-cc-form-section' )); |
45 | 44 | $form .= $this->generatePaymentContainer(); |
46 | | - |
| 45 | + |
47 | 46 | return $form; |
48 | 47 | } |
49 | | - |
| 48 | + |
50 | 49 | protected function generatePersonalContainer() { |
51 | 50 | global $wgRequest; |
52 | 51 | $form = ''; |
53 | 52 | $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-personal-info' )); ; |
54 | 53 | $form .= Xml::tags( 'h3', array( 'class' => 'payflow-cc-form-header','id' => 'payflow-cc-form-header-personal' ), wfMsg( 'payflowpro_gateway-make-your-donation' )); |
55 | 54 | $form .= Xml::openElement( 'table', array( 'id' => 'payflow-table-donor' ) ); |
56 | | - |
| 55 | + |
57 | 56 | $form .= $this->generatePersonalFields(); |
58 | | - |
| 57 | + |
59 | 58 | $form .= Xml::closeElement( 'table' ); // close table#payflow-table-donor |
60 | 59 | $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-personal-info |
61 | 60 | |
— | — | @@ -64,34 +63,33 @@ |
65 | 64 | protected function generatePersonalFields() { |
66 | 65 | global $wgPayflowGatewayPaypalURL; |
67 | 66 | $form = ''; |
68 | | - |
69 | | - // name |
| 67 | + |
| 68 | + // name |
70 | 69 | $form .= $this->getNameField(); |
71 | | - |
| 70 | + |
72 | 71 | // email |
73 | 72 | $form .= $this->getEmailField(); |
74 | | - |
| 73 | + |
75 | 74 | //comment message |
76 | 75 | $form .= $this->getCommentMessageField(); |
77 | | - |
| 76 | + |
78 | 77 | //comment |
79 | 78 | $form .= $this->getCommentField(); |
80 | | - |
| 79 | + |
81 | 80 | // anonymous |
82 | 81 | $form .= $this->getCommentOptionField(); |
83 | 82 | |
84 | 83 | // email agreement |
85 | 84 | $form .= $this->getEmailOptField(); |
86 | | - |
| 85 | + |
87 | 86 | // amount |
88 | 87 | $form .= $this->getAmountField(); |
89 | | - |
| 88 | + |
90 | 89 | // PayPal button |
91 | 90 | if ( strlen( $wgPayflowGatewayPaypalURL )) { |
92 | 91 | $form .= $this->getPaypalButton(); |
93 | 92 | } |
94 | | - |
| 93 | + |
95 | 94 | return $form; |
96 | 95 | } |
97 | | - |
98 | | -} |
\ No newline at end of file |
| 96 | +} |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/SingleColumn.php |
— | — | @@ -1,19 +1,19 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class PayflowProGateway_Form_SingleColumn extends PayflowProGateway_Form_TwoColumnLetter { |
5 | | - |
| 5 | + |
6 | 6 | public function __construct( &$form_data, &$form_errors ) { |
7 | 7 | global $wgOut, $wgScriptPath; |
8 | | - |
| 8 | + |
9 | 9 | // set the path to css, before the parent constructor is called, checking to make sure some child class hasn't already set this |
10 | 10 | if ( !strlen( $this->getStylePath())) { |
11 | 11 | $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/SingleColumn.css' ); |
12 | 12 | } |
13 | | - |
14 | | - parent::__construct( $form_data, $form_errors ); |
| 13 | + |
| 14 | + parent::__construct( $form_data, $form_errors ); |
15 | 15 | } |
16 | | - |
| 16 | + |
17 | 17 | public function generateFormEnd() { |
18 | 18 | return $this->generateFormClose(); |
19 | 19 | } |
20 | | -} |
\ No newline at end of file |
| 20 | +} |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/Form.php |
— | — | @@ -7,7 +7,7 @@ |
8 | 8 | * @var bool |
9 | 9 | */ |
10 | 10 | public $test = false; |
11 | | - |
| 11 | + |
12 | 12 | /** |
13 | 13 | * An array of hidden fields, name => value |
14 | 14 | * @var array |
— | — | @@ -31,34 +31,34 @@ |
32 | 32 | * @var string |
33 | 33 | */ |
34 | 34 | protected $style_path; |
35 | | - |
| 35 | + |
36 | 36 | /** |
37 | 37 | * A string to hold the HTML to display a cpatcha |
38 | 38 | * @var string |
39 | 39 | */ |
40 | 40 | protected $captcha_html; |
41 | | - |
| 41 | + |
42 | 42 | /** |
43 | 43 | * Required method for returning the full HTML for a form. |
44 | | - * |
| 44 | + * |
45 | 45 | * Code invoking forms will expect this method to be set. Requiring only |
46 | 46 | * this method allows for flexible form generation inside of child classes |
47 | | - * while also providing a unified method for returning the full HTML for |
| 47 | + * while also providing a unified method for returning the full HTML for |
48 | 48 | * a form. |
49 | 49 | * @return string The entire form HTML |
50 | 50 | */ |
51 | 51 | abstract function getForm(); |
52 | | - |
| 52 | + |
53 | 53 | public function __construct( &$data, &$error ) { |
54 | 54 | global $wgPayflowGatewayTest, $wgOut; |
55 | 55 | |
56 | 56 | $this->test = $wgPayflowGatewayTest; |
57 | 57 | $this->form_data =& $data; |
58 | 58 | $this->form_errors =& $error; |
59 | | - |
| 59 | + |
60 | 60 | /** |
61 | | - * add form-specific css - the path can be set in child classes |
62 | | - * using $this->setStylePath, which should be called before |
| 61 | + * add form-specific css - the path can be set in child classes |
| 62 | + * using $this->setStylePath, which should be called before |
63 | 63 | * calling parent::__construct() |
64 | 64 | */ |
65 | 65 | if ( !strlen( $this->getStylePath())) { |
— | — | @@ -66,10 +66,10 @@ |
67 | 67 | } |
68 | 68 | $wgOut->addExtensionStyle( $this->getStylePath() ); |
69 | 69 | } |
70 | | - |
| 70 | + |
71 | 71 | /** |
72 | 72 | * Set the path to the CSS file for the form |
73 | | - * |
| 73 | + * |
74 | 74 | * This should be a full path, perhaps taking advantage of $wgScriptPath. |
75 | 75 | * If you do not pass the path to the method, the style path will default |
76 | 76 | * to the default css in css/Form.css |
— | — | @@ -83,7 +83,7 @@ |
84 | 84 | } |
85 | 85 | $this->style_path = $style_path; |
86 | 86 | } |
87 | | - |
| 87 | + |
88 | 88 | /** |
89 | 89 | * Get the path to CSS |
90 | 90 | * @return String |
— | — | @@ -91,7 +91,7 @@ |
92 | 92 | public function getStylePath() { |
93 | 93 | return $this->style_path; |
94 | 94 | } |
95 | | - |
| 95 | + |
96 | 96 | /** |
97 | 97 | * Generates the donation footer ("There are other ways to give...") |
98 | 98 | * @returns string of HTML |
— | — | @@ -101,7 +101,7 @@ |
102 | 102 | $form = ''; |
103 | 103 | $form .= Xml::openElement( 'div', array( 'class' => 'payflow-cc-form-section', 'id' => 'payflowpro_gateway-donate-addl-info' )); |
104 | 104 | $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-donate-addl-info-secure-logos' )); |
105 | | - $form .= Xml::tags( 'p', array( 'class' => '' ), Xml::openElement( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/rapidssl_ssl_certificate.gif" ))); |
| 105 | + $form .= Xml::tags( 'p', array( 'class' => '' ), Xml::openElement( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/rapidssl_ssl_certificate.gif" ))); |
106 | 106 | $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-donate-addl-info-secure-logos |
107 | 107 | $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-donate-addl-info-text' )); |
108 | 108 | $form .= Xml::tags( 'p', array( 'class' => '' ), wfMsg( 'payflowpro_gateway-otherways' )); |
— | — | @@ -111,7 +111,7 @@ |
112 | 112 | $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-donate-addl-info |
113 | 113 | return $form; |
114 | 114 | } |
115 | | - |
| 115 | + |
116 | 116 | /** |
117 | 117 | * Fetch the array of iso country codes => country names |
118 | 118 | * @return array |
— | — | @@ -135,10 +135,10 @@ |
136 | 136 | foreach ( $this->getCountries() as $iso_value => $full_name ) { |
137 | 137 | $countries[ $iso_value ] = wfMsg( 'payflowpro_gateway-country-dropdown-' . $iso_value ); |
138 | 138 | } |
139 | | - |
| 139 | + |
140 | 140 | // alphabetically sort the country names |
141 | 141 | asort( $countries, SORT_STRING ); |
142 | | - |
| 142 | + |
143 | 143 | // generate a dropdown option for each country |
144 | 144 | foreach ( $countries as $iso_value => $full_name ) { |
145 | 145 | if ( $this->form_data[ 'country' ] ) { |
— | — | @@ -150,10 +150,10 @@ |
151 | 151 | } |
152 | 152 | |
153 | 153 | // build the actual select |
154 | | - $country_menu = Xml::openElement( |
155 | | - 'select', |
156 | | - array( |
157 | | - 'name' => 'country', |
| 154 | + $country_menu = Xml::openElement( |
| 155 | + 'select', |
| 156 | + array( |
| 157 | + 'name' => 'country', |
158 | 158 | 'id' => 'country', |
159 | 159 | 'onchange' => 'return disableStates( this )' |
160 | 160 | )); |
— | — | @@ -213,15 +213,15 @@ |
214 | 214 | // generate a dropdown opt for each month |
215 | 215 | for ( $i = 1; $i < 13; $i++ ) { |
216 | 216 | $selected = ( $i == $month && $this->test ) ? true : false; |
217 | | - $expiry_months .= Xml::option( |
218 | | - $wgLang->getMonthName( $i ), |
219 | | - str_pad( $i, 2, '0', STR_PAD_LEFT ), |
| 217 | + $expiry_months .= Xml::option( |
| 218 | + $wgLang->getMonthName( $i ), |
| 219 | + str_pad( $i, 2, '0', STR_PAD_LEFT ), |
220 | 220 | $selected ); |
221 | 221 | } |
222 | 222 | |
223 | 223 | $expiry_month_menu = Xml::openElement( |
224 | 224 | 'select', |
225 | | - array( |
| 225 | + array( |
226 | 226 | 'name' => 'mos', |
227 | 227 | 'id' => 'expiration' |
228 | 228 | )); |
— | — | @@ -241,7 +241,7 @@ |
242 | 242 | |
243 | 243 | // generate a dropdown of year opts |
244 | 244 | for ( $i = 0; $i < 11; $i++ ) { |
245 | | - $selected = ( date( 'Y' ) + $i == substr( date( 'Y' ), 0, 2 ) . $year |
| 245 | + $selected = ( date( 'Y' ) + $i == substr( date( 'Y' ), 0, 2 ) . $year |
246 | 246 | && $this->test ) ? true : false; |
247 | 247 | $expiry_years .= Xml::option( date( 'Y' ) + $i, date( 'Y' ) + $i, $selected ); |
248 | 248 | } |
— | — | @@ -290,7 +290,7 @@ |
291 | 291 | |
292 | 292 | /** |
293 | 293 | * Generates the dropdown list for available currencies |
294 | | - * |
| 294 | + * |
295 | 295 | * @fixme The list of available currencies should NOT be defined here but rather |
296 | 296 | * be customizable |
297 | 297 | * @fixme It would be great to default the currency to a locale's currency |
— | — | @@ -370,10 +370,10 @@ |
371 | 371 | } |
372 | 372 | return $this->hidden_fields; |
373 | 373 | } |
374 | | - |
| 374 | + |
375 | 375 | /** |
376 | 376 | * Get the HTML set to display a captcha |
377 | | - * |
| 377 | + * |
378 | 378 | * If $this->captcha_html has no string length, an empty string is returned. |
379 | 379 | * @return string The HTML to display the captcha or an empty string |
380 | 380 | */ |
— | — | @@ -383,39 +383,39 @@ |
384 | 384 | } |
385 | 385 | return $this->captcha_html; |
386 | 386 | } |
387 | | - |
| 387 | + |
388 | 388 | /** |
389 | 389 | * Set a string of HTML used to display a captcha |
390 | | - * |
| 390 | + * |
391 | 391 | * This allows for a flexible way of inserting some kind of captcha |
392 | | - * into a form, and for a form to flexibly insert captcha HTML |
| 392 | + * into a form, and for a form to flexibly insert captcha HTML |
393 | 393 | * wherever it needs to go. |
394 | | - * |
| 394 | + * |
395 | 395 | * @param string The HTML to display the captcha |
396 | 396 | */ |
397 | 397 | public function setCaptchaHTML( $html ) { |
398 | | - $this->captcha_html = $html; |
| 398 | + $this->captcha_html = $html; |
399 | 399 | } |
400 | | - |
| 400 | + |
401 | 401 | protected function generateBannerHeader() { |
402 | 402 | global $wgPayflowGatewayHeader, $wgOut, $wgRequest; |
403 | | - |
| 403 | + |
404 | 404 | $template = ''; |
405 | | - |
| 405 | + |
406 | 406 | // intro text |
407 | 407 | if ( $wgRequest->getText('masthead', false)) { |
408 | 408 | $template = $wgOut->parse( '{{' . $wgRequest->getText( 'masthead' ) . '/' . $this->form_data[ 'language' ] . '}}' ); |
409 | 409 | } elseif ( $wgPayflowGatewayHeader ) { |
410 | 410 | $header = str_replace( '@language', $this->form_data[ 'language' ], $wgPayflowGatewayHeader ); |
411 | 411 | $template = $wgOut->parse( $header ); |
412 | | - } |
413 | | - |
| 412 | + } |
| 413 | + |
414 | 414 | // make sure that we actually have a matching template to display so we don't display the 'redlink' |
415 | 415 | if ( strlen( $template ) && !preg_match( '/redlink\=1/', $template )) { |
416 | 416 | $wgOut->addHtml( $template ); |
417 | 417 | } |
418 | 418 | } |
419 | | - |
| 419 | + |
420 | 420 | protected function getEmailField() { |
421 | 421 | // email |
422 | 422 | $form = '<tr>'; |
— | — | @@ -428,7 +428,7 @@ |
429 | 429 | $form .= '</tr>'; |
430 | 430 | return $form; |
431 | 431 | } |
432 | | - |
| 432 | + |
433 | 433 | protected function getAmountField() { |
434 | 434 | $otherChecked = false; |
435 | 435 | $amount = -1; |
— | — | @@ -440,8 +440,8 @@ |
441 | 441 | $form .= '<td colspan="2"><span class="creditcard-error-msg">' . $this->form_errors['invalidamount'] . '</span></td>'; |
442 | 442 | $form .= '</tr>'; |
443 | 443 | $form .= '<tr>'; |
444 | | - $form .= '<td class="label">' . Xml::label(wfMsg( 'payflowpro_gateway-donor-amount' ), 'amount') . '</td>'; |
445 | | - $form .= '<td>' . Xml::radio( 'amount', 250, $this->form_data['amount'] == 250 ) . '250 ' . |
| 444 | + $form .= '<td class="label">' . Xml::label(wfMsg( 'payflowpro_gateway-donor-amount' ), 'amount') . '</td>'; |
| 445 | + $form .= '<td>' . Xml::radio( 'amount', 250, $this->form_data['amount'] == 250 ) . '250 ' . |
446 | 446 | Xml::radio( 'amount', 100, $this->form_data['amount'] == 100 ) . '100 ' . |
447 | 447 | Xml::radio( 'amount', 75, $this->form_data['amount'] == 75 ) . '75 ' . |
448 | 448 | Xml::radio( 'amount', 35, $this->form_data['amount'] == 35 ) . '35 ' . |
— | — | @@ -449,16 +449,16 @@ |
450 | 450 | $form .= '</tr>'; |
451 | 451 | $form .= '<tr>'; |
452 | 452 | $form .= '<td class="label"></td>'; |
453 | | - $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;if (this.value > 0) document.getElementById("otherRadio").checked=true;', 'maxlength' => '10', 'id' => 'amountOther' ) ) . |
| 453 | + $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;if (this.value > 0) document.getElementById("otherRadio").checked=true;', 'maxlength' => '10', 'id' => 'amountOther' ) ) . |
454 | 454 | ' ' . $this->generateCurrencyDropdown() . '</td>'; |
455 | 455 | $form .= '</tr>'; |
456 | 456 | return $form; |
457 | 457 | } |
458 | | - |
| 458 | + |
459 | 459 | protected function getCardnumberField() { |
460 | 460 | global $wgPayflowGatewayTest; |
461 | 461 | $card_num = ( $wgPayflowGatewayTest ) ? $this->form_data[ 'card_num' ] : ''; |
462 | | - |
| 462 | + |
463 | 463 | $form = '<tr>'; |
464 | 464 | $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['card_num'] . '</span></td>'; |
465 | 465 | $form .= '</tr>'; |
— | — | @@ -472,11 +472,11 @@ |
473 | 473 | $form .= '</tr>'; |
474 | 474 | return $form; |
475 | 475 | } |
476 | | - |
| 476 | + |
477 | 477 | protected function getCvvField() { |
478 | 478 | global $wgPayflowGatewayTest; |
479 | 479 | $cvv = ( $wgPayflowGatewayTest ) ? $this->form_data[ 'cvv' ] : ''; |
480 | | - |
| 480 | + |
481 | 481 | $form = '<tr>'; |
482 | 482 | $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['cvv'] . '</span></td>'; |
483 | 483 | $form .= '<tr>'; |
— | — | @@ -487,7 +487,7 @@ |
488 | 488 | $form .= '</tr>'; |
489 | 489 | return $form; |
490 | 490 | } |
491 | | - |
| 491 | + |
492 | 492 | protected function getStreetField() { |
493 | 493 | $form = '<tr>'; |
494 | 494 | $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['street'] . '</span></td>'; |
— | — | @@ -499,7 +499,7 @@ |
500 | 500 | $form .= '</tr>'; |
501 | 501 | return $form; |
502 | 502 | } |
503 | | - |
| 503 | + |
504 | 504 | protected function getCityField() { |
505 | 505 | $form = '<tr>'; |
506 | 506 | $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['city'] . '</span></td>'; |
— | — | @@ -511,7 +511,7 @@ |
512 | 512 | $form .= '</tr>'; |
513 | 513 | return $form; |
514 | 514 | } |
515 | | - |
| 515 | + |
516 | 516 | protected function getZipField() { |
517 | 517 | $form = '<tr>'; |
518 | 518 | $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['zip'] . '</span></td>'; |
— | — | @@ -523,7 +523,7 @@ |
524 | 524 | $form .= '</tr>'; |
525 | 525 | return $form; |
526 | 526 | } |
527 | | - |
| 527 | + |
528 | 528 | protected function getNameField() { |
529 | 529 | $form = '<tr>'; |
530 | 530 | $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['fname'] . '</span></td>'; |
— | — | @@ -538,7 +538,7 @@ |
539 | 539 | $form .= "</tr>"; |
540 | 540 | return $form; |
541 | 541 | } |
542 | | - |
| 542 | + |
543 | 543 | protected function getCommentMessageField() { |
544 | 544 | $form = '<tr>'; |
545 | 545 | $form .= '<td colspan="2">'; |
— | — | @@ -547,7 +547,7 @@ |
548 | 548 | $form .= '</tr>'; |
549 | 549 | return $form; |
550 | 550 | } |
551 | | - |
| 551 | + |
552 | 552 | protected function getCommentField() { |
553 | 553 | $form = '<tr>'; |
554 | 554 | $form .= '<td class="label">' . Xml::label( wfMsg('payflowpro_gateway-comment'), 'comment' ) . '</td>'; |
— | — | @@ -555,7 +555,7 @@ |
556 | 556 | $form .= '</tr>'; |
557 | 557 | return $form; |
558 | 558 | } |
559 | | - |
| 559 | + |
560 | 560 | protected function getCommentOptionField() { |
561 | 561 | global $wgRequest; |
562 | 562 | $comment_opt_value = ( $wgRequest->wasPosted() ) ? $this->form_data[ 'comment-option' ] : true; |
— | — | @@ -565,7 +565,7 @@ |
566 | 566 | $form .= '</tr>'; |
567 | 567 | return $form; |
568 | 568 | } |
569 | | - |
| 569 | + |
570 | 570 | protected function getEmailOptField() { |
571 | 571 | global $wgRequest; |
572 | 572 | $email_opt_value = ( $wgRequest->wasPosted() ) ? $this->form_data[ 'email-opt' ] : true; |
— | — | @@ -580,11 +580,11 @@ |
581 | 581 | $form .= '</tr>'; |
582 | 582 | return $form; |
583 | 583 | } |
584 | | - |
| 584 | + |
585 | 585 | protected function getPaypalButton() { |
586 | 586 | global $wgScriptPath; |
587 | 587 | $scriptPath = "$wgScriptPath/extensions/DonationInterface/payflowpro_gateway/includes"; |
588 | | - |
| 588 | + |
589 | 589 | $form = '<tr>'; |
590 | 590 | $form .= '<td class="paypal-button" colspan="2">'; |
591 | 591 | $form .= Xml::hidden( 'PaypalRedirect', false ); |
— | — | @@ -596,7 +596,7 @@ |
597 | 597 | $form .= '</tr>'; |
598 | 598 | return $form; |
599 | 599 | } |
600 | | - |
| 600 | + |
601 | 601 | protected function getStateField() { |
602 | 602 | $form = '<tr>'; |
603 | 603 | $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['state'] . '</span></td>'; |
— | — | @@ -607,7 +607,7 @@ |
608 | 608 | $form .= '</tr>'; |
609 | 609 | return $form; |
610 | 610 | } |
611 | | - |
| 611 | + |
612 | 612 | protected function getCountryField() { |
613 | 613 | $form = '<tr>'; |
614 | 614 | $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['country'] . '</span></td>'; |
— | — | @@ -618,7 +618,7 @@ |
619 | 619 | $form .= '</tr>'; |
620 | 620 | return $form; |
621 | 621 | } |
622 | | - |
| 622 | + |
623 | 623 | protected function getCreditCardTypeField() { |
624 | 624 | $form = '<tr>'; |
625 | 625 | $form .= '<td class="label">' . Xml::label( wfMsg( 'payflowpro_gateway-donor-card' ), 'card' ) . '</td>'; |
— | — | @@ -626,7 +626,7 @@ |
627 | 627 | $form .= '</tr>'; |
628 | 628 | return $form; |
629 | 629 | } |
630 | | - |
| 630 | + |
631 | 631 | protected function getExpiryField() { |
632 | 632 | $form = '<tr>'; |
633 | 633 | $form .= '<td class="label">' . Xml::label( wfMsg( 'payflowpro_gateway-donor-expiration' ), 'expiration' ) . '</td>'; |
— | — | @@ -634,45 +634,45 @@ |
635 | 635 | $form .= '</tr>'; |
636 | 636 | return $form; |
637 | 637 | } |
638 | | - |
| 638 | + |
639 | 639 | protected function loadValidateJs() { |
640 | 640 | global $wgOut, $wgScriptPath; |
641 | | - $wgOut->addHeadItem( 'validatescript', '<script type="text/javascript" src="' . |
642 | | - $wgScriptPath . |
| 641 | + $wgOut->addHeadItem( 'validatescript', '<script type="text/javascript" src="' . |
| 642 | + $wgScriptPath . |
643 | 643 | '/extensions/DonationInterface/payflowpro_gateway/validate_input.js?284"></script>' ); |
644 | 644 | } |
645 | | - |
| 645 | + |
646 | 646 | protected function loadApiJs() { |
647 | 647 | global $wgOut, $wgScriptPath; |
648 | 648 | $wgOut->addHeadItem( 'pfp_api_call', '<script type="text/javascript" src="' . |
649 | 649 | $wgScriptPath . |
650 | 650 | '/extensions/DonationInterface/payflowpro_gateway/pfp_api_controller.js?284"></script>' ); |
651 | 651 | } |
652 | | - |
| 652 | + |
653 | 653 | /** |
654 | 654 | * Generate HTML for <noscript> tags |
655 | | - * |
| 655 | + * |
656 | 656 | * For displaying when a user does not have Javascript enabled in their browser. |
657 | 657 | */ |
658 | 658 | protected function getNoScript() { |
659 | 659 | global $wgPayflowGatewayNoScriptRedirect; |
660 | | - |
| 660 | + |
661 | 661 | $form = '<noscript>'; |
662 | 662 | $form .= '<div id="noscript">'; |
663 | 663 | $form .= '<p id="noscript-msg">' . wfMsg( 'payflowpro_gateway-noscript-msg' ) . '</p>'; |
664 | 664 | if ( $wgPayflowGatewayNoScriptRedirect ) { |
665 | 665 | $form .= '<p id="noscript-redirect-msg">' . wfMsg( 'payflowpro_gateway-noscript-redirect-msg' ) . '</p>'; |
666 | | - $form .= '<p id="noscript-redirect-link"><a href="' . $wgPayflowGatewayNoScriptRedirect . '">' . $wgPayflowGatewayNoScriptRedirect . '</a></p>'; |
| 666 | + $form .= '<p id="noscript-redirect-link"><a href="' . $wgPayflowGatewayNoScriptRedirect . '">' . $wgPayflowGatewayNoScriptRedirect . '</a></p>'; |
667 | 667 | } |
668 | 668 | $form .= '</div>'; |
669 | 669 | $form .= '</noscript>'; |
670 | 670 | return $form; |
671 | 671 | } |
672 | | - |
| 672 | + |
673 | 673 | /** |
674 | 674 | * Determine the 'no cache' form action |
675 | | - * |
676 | | - * This mostly exists to ensure that the form does not try to use AJAX to |
| 675 | + * |
| 676 | + * This mostly exists to ensure that the form does not try to use AJAX to |
677 | 677 | * overwrite certain hidden form params that are normally overwitten for |
678 | 678 | * cached versions of the form. |
679 | 679 | * @return string $url The full URL for the form to post to |
— | — | @@ -681,12 +681,12 @@ |
682 | 682 | global $wgRequest; |
683 | 683 | |
684 | 684 | $url = $wgRequest->getFullRequestURL(); |
685 | | - |
| 685 | + |
686 | 686 | // it the _nocache_ param != true, add it to the URL |
687 | 687 | if ( !$wgRequest->getText( '_nocache_' )) { |
688 | 688 | $url = wfAppendQuery( $url, array( '_nocache_' => 'true' )); |
689 | 689 | } |
690 | | - |
| 690 | + |
691 | 691 | return $url; |
692 | 692 | } |
693 | | -} |
\ No newline at end of file |
| 693 | +} |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/OneStepTwoColumn.php |
— | — | @@ -1,246 +1,246 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class PayflowProGateway_Form_OneStepTwoColumn extends PayflowProGateway_Form { |
5 | | - public $paypal = false; // true for paypal only version |
| 5 | + public $paypal = false; // true for paypal only version |
6 | 6 | |
7 | | - public function __construct( &$form_data, &$form_errors ) { |
8 | | - global $wgOut, $wgScriptPath; |
| 7 | + public function __construct( &$form_data, &$form_errors ) { |
| 8 | + global $wgOut, $wgScriptPath; |
9 | 9 | |
10 | | - parent::__construct( $form_data, $form_errors ); |
| 10 | + parent::__construct( $form_data, $form_errors ); |
11 | 11 | |
12 | | - // update the list of hidden fields we need to use in this form. |
13 | | - $this->updateHiddenFields(); |
| 12 | + // update the list of hidden fields we need to use in this form. |
| 13 | + $this->updateHiddenFields(); |
14 | 14 | |
15 | | - // we only want to load this JS if the form is being rendered |
16 | | - $this->loadValidateJs(); // validation JS |
17 | | - |
18 | | - $this->loadApiJs(); // API/Ajax JS |
19 | | - } |
| 15 | + // we only want to load this JS if the form is being rendered |
| 16 | + $this->loadValidateJs(); // validation JS |
20 | 17 | |
21 | | - /** |
22 | | - * Required method for constructing the entire form |
23 | | - * |
24 | | - * This can of course be overloaded by a child class. |
25 | | - * @return string The entire form HTML |
26 | | - */ |
27 | | - public function getForm() { |
28 | | - $form = $this->generateFormStart(); |
29 | | - $form .= $this->getCaptchaHTML(); |
30 | | - $form .= $this->generateFormSubmit(); |
31 | | - $form .= $this->generateFormEnd(); |
32 | | - return $form; |
33 | | - } |
| 18 | + $this->loadApiJs(); // API/Ajax JS |
| 19 | + } |
34 | 20 | |
35 | | - public function generateFormStart() { |
36 | | - global $wgPayflowGatewayHeader, $wgPayflwGatewayTest, $wgOut, $wgRequest; |
| 21 | + /** |
| 22 | + * Required method for constructing the entire form |
| 23 | + * |
| 24 | + * This can of course be overloaded by a child class. |
| 25 | + * @return string The entire form HTML |
| 26 | + */ |
| 27 | + public function getForm() { |
| 28 | + $form = $this->generateFormStart(); |
| 29 | + $form .= $this->getCaptchaHTML(); |
| 30 | + $form .= $this->generateFormSubmit(); |
| 31 | + $form .= $this->generateFormEnd(); |
| 32 | + return $form; |
| 33 | + } |
37 | 34 | |
38 | | - $this->paypal = $wgRequest->getBool( 'paypal', false ); |
| 35 | + public function generateFormStart() { |
| 36 | + global $wgPayflowGatewayHeader, $wgPayflwGatewayTest, $wgOut, $wgRequest; |
39 | 37 | |
40 | | - $form = $this->generateBannerHeader(); |
| 38 | + $this->paypal = $wgRequest->getBool( 'paypal', false ); |
41 | 39 | |
42 | | - $form .= Xml::openElement( 'div', array( 'id' => 'mw-creditcard' ) ); |
| 40 | + $form = $this->generateBannerHeader(); |
43 | 41 | |
44 | | - // provide a place at the top of the form for displaying general messages |
45 | | - if ( $this->form_errors['general'] ) { |
46 | | - $form .= Xml::openElement( 'div', array( 'id' => 'mw-payflow-general-error' )); |
47 | | - if ( is_array( $this->form_errors['general'] )) { |
48 | | - foreach ( $this->form_errors['general'] as $this->form_errors_msg ) { |
49 | | - $form .= Xml::tags( 'p', array( 'class' => 'creditcard-error-msg' ), $this->form_errors_msg ); |
50 | | - } |
51 | | - } else { |
52 | | - $form .= Xml::tags( 'p', array( 'class' => 'creditcard-error-msg' ), $this->form_errors_msg ); |
53 | | - } |
54 | | - $form .= Xml::closeElement( 'div' ); |
55 | | - } |
| 42 | + $form .= Xml::openElement( 'div', array( 'id' => 'mw-creditcard' ) ); |
56 | 43 | |
57 | | - // add noscript tags for javascript disabled browsers |
58 | | - $form .= $this->getNoScript(); |
59 | | - |
60 | | - // open form |
61 | | - $form .= Xml::openElement( 'div', array( 'id' => 'mw-creditcard-form' ) ); |
| 44 | + // provide a place at the top of the form for displaying general messages |
| 45 | + if ( $this->form_errors['general'] ) { |
| 46 | + $form .= Xml::openElement( 'div', array( 'id' => 'mw-payflow-general-error' )); |
| 47 | + if ( is_array( $this->form_errors['general'] )) { |
| 48 | + foreach ( $this->form_errors['general'] as $this->form_errors_msg ) { |
| 49 | + $form .= Xml::tags( 'p', array( 'class' => 'creditcard-error-msg' ), $this->form_errors_msg ); |
| 50 | + } |
| 51 | + } else { |
| 52 | + $form .= Xml::tags( 'p', array( 'class' => 'creditcard-error-msg' ), $this->form_errors_msg ); |
| 53 | + } |
| 54 | + $form .= Xml::closeElement( 'div' ); |
| 55 | + } |
62 | 56 | |
63 | | - // Xml::element seems to convert html to htmlentities |
64 | | - $form .= "<p class='creditcard-error-msg'>" . $this->form_errors['retryMsg'] . "</p>"; |
65 | | - $form .= Xml::openElement( 'form', array( 'name' => 'payment', 'method' => 'post', 'action' => $this->getNoCacheAction(), 'onsubmit' => 'return validate_form(this)', 'autocomplete' => 'off' ) ); |
| 57 | + // add noscript tags for javascript disabled browsers |
| 58 | + $form .= $this->getNoScript(); |
66 | 59 | |
67 | | - $form .= Xml::openElement( 'div', array( 'id' => 'left-column', 'class' => 'payflow-cc-form-section')); |
68 | | - $form .= $this->generatePersonalContainer(); |
| 60 | + // open form |
| 61 | + $form .= Xml::openElement( 'div', array( 'id' => 'mw-creditcard-form' ) ); |
69 | 62 | |
70 | | - if ( !$this->paypal ) { |
71 | | - $form .= Xml::closeElement( 'div' ); // close div#left-column |
| 63 | + // Xml::element seems to convert html to htmlentities |
| 64 | + $form .= "<p class='creditcard-error-msg'>" . $this->form_errors['retryMsg'] . "</p>"; |
| 65 | + $form .= Xml::openElement( 'form', array( 'name' => 'payment', 'method' => 'post', 'action' => $this->getNoCacheAction(), 'onsubmit' => 'return validate_form(this)', 'autocomplete' => 'off' ) ); |
72 | 66 | |
73 | | - $form .= Xml::openElement( 'div', array( 'id' => 'right-column', 'class' => 'payflow-cc-form-section' )); |
74 | | - $form .= $this->generatePaymentContainer(); |
75 | | - } |
| 67 | + $form .= Xml::openElement( 'div', array( 'id' => 'left-column', 'class' => 'payflow-cc-form-section')); |
| 68 | + $form .= $this->generatePersonalContainer(); |
76 | 69 | |
77 | | - return $form; |
78 | | - } |
79 | | - public function generateFormSubmit() { |
80 | | - // submit button |
81 | | - $form = Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-form-submit')); |
82 | | - $form .= Xml::openElement( 'div', array( 'id' => 'mw-donate-submit-button' )); |
83 | | - if ( $this->paypal ) { |
84 | | - $form .= Xml::hidden( 'PaypalRedirect', false ); |
85 | | - $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')); |
86 | | - } else { |
87 | | - $form .= Xml::element( 'input', array( 'class' => 'input-button button-navyblue', 'value' => wfMsg( 'payflowpro_gateway-submit-button'), 'onclick' => 'submit_form( this )', 'type' => 'submit')); |
88 | | - $form .= Xml::closeElement( 'div' ); // close div#mw-donate-submit-button |
89 | | - $form .= Xml::openElement( 'div', array( 'class' => 'mw-donate-submessage', 'id' => 'payflowpro_gateway-donate-submessage' ) ) . |
90 | | - wfMsg( 'payflowpro_gateway-donate-click' ); |
91 | | - } |
92 | | - $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-donate-submessage |
93 | | - $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-form-submit |
| 70 | + if ( !$this->paypal ) { |
| 71 | + $form .= Xml::closeElement( 'div' ); // close div#left-column |
94 | 72 | |
95 | | - return $form; |
96 | | - } |
| 73 | + $form .= Xml::openElement( 'div', array( 'id' => 'right-column', 'class' => 'payflow-cc-form-section' )); |
| 74 | + $form .= $this->generatePaymentContainer(); |
| 75 | + } |
97 | 76 | |
98 | | - public function generateFormEnd() { |
99 | | - $form = ''; |
100 | | - // add hidden fields |
101 | | - $hidden_fields = $this->getHiddenFields(); |
102 | | - foreach ( $hidden_fields as $field => $value ) { |
103 | | - $form .= Xml::hidden( $field, $value ); |
104 | | - } |
105 | | - $form .= Xml::closeElement( 'div' ); // close div#right-column |
106 | | - $form .= Xml::closeElement( 'form' ); |
107 | | - $form .= Xml::closeElement( 'div' ); // close div#mw-creditcard-form |
108 | | - $form .= $this->generateDonationFooter(); |
109 | | - $form .= Xml::closeElement( 'div' ); // div#close mw-creditcard |
110 | | - return $form; |
111 | | - } |
| 77 | + return $form; |
| 78 | + } |
| 79 | + public function generateFormSubmit() { |
| 80 | + // submit button |
| 81 | + $form = Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-form-submit')); |
| 82 | + $form .= Xml::openElement( 'div', array( 'id' => 'mw-donate-submit-button' )); |
| 83 | + if ( $this->paypal ) { |
| 84 | + $form .= Xml::hidden( 'PaypalRedirect', false ); |
| 85 | + $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')); |
| 86 | + } else { |
| 87 | + $form .= Xml::element( 'input', array( 'class' => 'input-button button-navyblue', 'value' => wfMsg( 'payflowpro_gateway-submit-button'), 'onclick' => 'submit_form( this )', 'type' => 'submit')); |
| 88 | + $form .= Xml::closeElement( 'div' ); // close div#mw-donate-submit-button |
| 89 | + $form .= Xml::openElement( 'div', array( 'class' => 'mw-donate-submessage', 'id' => 'payflowpro_gateway-donate-submessage' ) ) . |
| 90 | + wfMsg( 'payflowpro_gateway-donate-click' ); |
| 91 | + } |
| 92 | + $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-donate-submessage |
| 93 | + $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-form-submit |
112 | 94 | |
113 | | - protected function generateBannerHeader() { |
114 | | - global $wgPayflowGatewayHeader, $wgOut, $wgRequest; |
115 | | - $template = ''; |
| 95 | + return $form; |
| 96 | + } |
116 | 97 | |
117 | | - // intro text |
118 | | - if ( $wgRequest->getText('masthead', false)) { |
119 | | - $template = $wgOut->parse( '{{' . $wgRequest->getText( 'masthead' ) . '/' . $this->form_data[ 'language' ] . '}}' ); |
120 | | - } elseif ( $wgPayflowGatewayHeader ) { |
121 | | - $header = str_replace( '@language', $this->form_data[ 'language' ], $wgPayflowGatewayHeader ); |
122 | | - $template = $wgOut->parse( $header ); |
123 | | - } |
| 98 | + public function generateFormEnd() { |
| 99 | + $form = ''; |
| 100 | + // add hidden fields |
| 101 | + $hidden_fields = $this->getHiddenFields(); |
| 102 | + foreach ( $hidden_fields as $field => $value ) { |
| 103 | + $form .= Xml::hidden( $field, $value ); |
| 104 | + } |
| 105 | + $form .= Xml::closeElement( 'div' ); // close div#right-column |
| 106 | + $form .= Xml::closeElement( 'form' ); |
| 107 | + $form .= Xml::closeElement( 'div' ); // close div#mw-creditcard-form |
| 108 | + $form .= $this->generateDonationFooter(); |
| 109 | + $form .= Xml::closeElement( 'div' ); // div#close mw-creditcard |
| 110 | + return $form; |
| 111 | + } |
124 | 112 | |
125 | | - // make sure that we actually have a matching template to display so we don't display the 'redlink' |
126 | | - if ( strlen( $template ) && !preg_match( '/redlink\=1/', $template )) { |
127 | | - $wgOut->addHtml( $template ); |
128 | | - } |
129 | | - } |
| 113 | + protected function generateBannerHeader() { |
| 114 | + global $wgPayflowGatewayHeader, $wgOut, $wgRequest; |
| 115 | + $template = ''; |
130 | 116 | |
131 | | - protected function generatePersonalContainer() { |
132 | | - global $wgRequest, $wgScriptPath; |
133 | | - $form = ''; |
134 | | - $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-personal-info' )); ; |
135 | | - $form .= Xml::tags( 'h3', array( 'class' => 'payflow-cc-form-header','id' => 'payflow-cc-form-header-personal' ), wfMsg( 'payflowpro_gateway-make-your-donation' )); |
136 | | - if ( !$this->paypal ) { |
137 | | - $source = $wgRequest->getText( 'utm_source' ); |
138 | | - $medium = $wgRequest->getText( 'utm_medium' ); |
139 | | - $campaign = $wgRequest->getText( 'utm_campaign' ); |
140 | | - $formname = $wgRequest->getText( 'form_name' ); |
141 | | - $form .= Xml::Tags( 'p', array( 'id' => 'payflowpro_gateway-cc_otherways' ), wfMsg( 'payflowpro_gateway-paypal', $wgScriptPath, $formname, $source, $medium, $campaign )); |
142 | | - } |
143 | | - $form .= Xml::openElement( 'table', array( 'id' => 'payflow-table-donor' ) ); |
| 117 | + // intro text |
| 118 | + if ( $wgRequest->getText('masthead', false)) { |
| 119 | + $template = $wgOut->parse( '{{' . $wgRequest->getText( 'masthead' ) . '/' . $this->form_data[ 'language' ] . '}}' ); |
| 120 | + } elseif ( $wgPayflowGatewayHeader ) { |
| 121 | + $header = str_replace( '@language', $this->form_data[ 'language' ], $wgPayflowGatewayHeader ); |
| 122 | + $template = $wgOut->parse( $header ); |
| 123 | + } |
144 | 124 | |
145 | | - $form .= $this->generatePersonalFields(); |
| 125 | + // make sure that we actually have a matching template to display so we don't display the 'redlink' |
| 126 | + if ( strlen( $template ) && !preg_match( '/redlink\=1/', $template )) { |
| 127 | + $wgOut->addHtml( $template ); |
| 128 | + } |
| 129 | + } |
146 | 130 | |
147 | | - $form .= Xml::closeElement( 'table' ); // close table#payflow-table-donor |
148 | | - $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-personal-info |
| 131 | + protected function generatePersonalContainer() { |
| 132 | + global $wgRequest, $wgScriptPath; |
| 133 | + $form = ''; |
| 134 | + $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-personal-info' )); |
| 135 | + $form .= Xml::tags( 'h3', array( 'class' => 'payflow-cc-form-header','id' => 'payflow-cc-form-header-personal' ), wfMsg( 'payflowpro_gateway-make-your-donation' )); |
| 136 | + if ( !$this->paypal ) { |
| 137 | + $source = $wgRequest->getText( 'utm_source' ); |
| 138 | + $medium = $wgRequest->getText( 'utm_medium' ); |
| 139 | + $campaign = $wgRequest->getText( 'utm_campaign' ); |
| 140 | + $formname = $wgRequest->getText( 'form_name' ); |
| 141 | + $form .= Xml::Tags( 'p', array( 'id' => 'payflowpro_gateway-cc_otherways' ), wfMsg( 'payflowpro_gateway-paypal', $wgScriptPath, $formname, $source, $medium, $campaign )); |
| 142 | + } |
| 143 | + $form .= Xml::openElement( 'table', array( 'id' => 'payflow-table-donor' ) ); |
149 | 144 | |
150 | | - return $form; |
151 | | - } |
| 145 | + $form .= $this->generatePersonalFields(); |
152 | 146 | |
153 | | - protected function generatePersonalFields() { |
154 | | - $form = ''; |
| 147 | + $form .= Xml::closeElement( 'table' ); // close table#payflow-table-donor |
| 148 | + $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-personal-info |
155 | 149 | |
156 | | - // name |
157 | | - $form .= $this->getNameField(); |
| 150 | + return $form; |
| 151 | + } |
158 | 152 | |
159 | | - // email |
160 | | - $form .= $this->getEmailField(); |
| 153 | + protected function generatePersonalFields() { |
| 154 | + $form = ''; |
161 | 155 | |
162 | | - //comment message |
163 | | - $form .= $this->getCommentMessageField(); |
| 156 | + // name |
| 157 | + $form .= $this->getNameField(); |
164 | 158 | |
165 | | - //comment |
166 | | - $form .= $this->getCommentField(); |
| 159 | + // email |
| 160 | + $form .= $this->getEmailField(); |
167 | 161 | |
168 | | - // anonymous |
169 | | - $form .= $this->getCommentOptionField(); |
| 162 | + //comment message |
| 163 | + $form .= $this->getCommentMessageField(); |
170 | 164 | |
171 | | - // email agreement |
172 | | - $form .= $this->getEmailOptField(); |
| 165 | + //comment |
| 166 | + $form .= $this->getCommentField(); |
173 | 167 | |
174 | | - // amount |
175 | | - $form .= $this->getAmountField(); |
| 168 | + // anonymous |
| 169 | + $form .= $this->getCommentOptionField(); |
176 | 170 | |
177 | | - return $form; |
178 | | - } |
| 171 | + // email agreement |
| 172 | + $form .= $this->getEmailOptField(); |
179 | 173 | |
180 | | - protected function generatePaymentContainer() { |
181 | | - $form = ''; |
182 | | - // credit card info |
183 | | - $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-payment-info' )); |
184 | | - $form .= Xml::openElement( 'table', array( 'id' => 'payflow-table-cc' ) ); |
| 174 | + // amount |
| 175 | + $form .= $this->getAmountField(); |
185 | 176 | |
186 | | - $form .= $this->generatePaymentFields(); |
| 177 | + return $form; |
| 178 | + } |
187 | 179 | |
188 | | - $form .= Xml::closeElement( 'table' ); // close table#payflow-table-cc |
189 | | - $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-payment-info |
| 180 | + protected function generatePaymentContainer() { |
| 181 | + $form = ''; |
| 182 | + // credit card info |
| 183 | + $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-payment-info' )); |
| 184 | + $form .= Xml::openElement( 'table', array( 'id' => 'payflow-table-cc' ) ); |
190 | 185 | |
191 | | - return $form; |
192 | | - } |
| 186 | + $form .= $this->generatePaymentFields(); |
193 | 187 | |
194 | | - protected function generatePaymentFields() { |
195 | | - global $wgScriptPath, $wgPayflowGatewayTest; |
| 188 | + $form .= Xml::closeElement( 'table' ); // close table#payflow-table-cc |
| 189 | + $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-payment-info |
196 | 190 | |
197 | | - $form = ''; |
| 191 | + return $form; |
| 192 | + } |
198 | 193 | |
199 | | - // card logos |
200 | | - $form .= '<tr>'; |
201 | | - $form .= '<td />'; |
202 | | - $form .= '<td> <br/>' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/credit_card_logos.gif" )) . '</td>'; |
203 | | - $form .= '</tr>'; |
| 194 | + protected function generatePaymentFields() { |
| 195 | + global $wgScriptPath, $wgPayflowGatewayTest; |
204 | 196 | |
205 | | - // card number |
206 | | - $form .= $this->getCardnumberField(); |
| 197 | + $form = ''; |
207 | 198 | |
208 | | - // cvv |
209 | | - $form .= $this->getCvvField(); |
| 199 | + // card logos |
| 200 | + $form .= '<tr>'; |
| 201 | + $form .= '<td />'; |
| 202 | + $form .= '<td> <br/>' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/credit_card_logos.gif" )) . '</td>'; |
| 203 | + $form .= '</tr>'; |
210 | 204 | |
211 | | - // expiry |
212 | | - $form .= $this->getExpiryField(); |
| 205 | + // card number |
| 206 | + $form .= $this->getCardnumberField(); |
213 | 207 | |
214 | | - // street |
215 | | - $form .= $this->getStreetField(); |
| 208 | + // cvv |
| 209 | + $form .= $this->getCvvField(); |
216 | 210 | |
217 | | - // city |
218 | | - $form .= $this->getCityField(); |
| 211 | + // expiry |
| 212 | + $form .= $this->getExpiryField(); |
219 | 213 | |
220 | | - // state |
221 | | - $form .= $this->getStateField(); |
| 214 | + // street |
| 215 | + $form .= $this->getStreetField(); |
222 | 216 | |
223 | | - // zip |
224 | | - $form .= $this->getZipField(); |
| 217 | + // city |
| 218 | + $form .= $this->getCityField(); |
225 | 219 | |
226 | | - // country |
227 | | - $form .= $this->getCountryField(); |
| 220 | + // state |
| 221 | + $form .= $this->getStateField(); |
228 | 222 | |
229 | | - return $form; |
230 | | - } |
| 223 | + // zip |
| 224 | + $form .= $this->getZipField(); |
231 | 225 | |
232 | | - /** |
233 | | - * Update hidden fields to not set any comment-related fields |
234 | | - */ |
235 | | - public function updateHiddenFields() { |
236 | | - $hidden_fields = $this->getHiddenFields(); |
| 226 | + // country |
| 227 | + $form .= $this->getCountryField(); |
237 | 228 | |
238 | | - // make sure that the below elements are not set in the hidden fields |
239 | | - $not_needed = array( 'comment-option', 'email-opt', 'comment' ); |
| 229 | + return $form; |
| 230 | + } |
240 | 231 | |
241 | | - foreach ( $not_needed as $field ) { |
242 | | - unset( $hidden_fields[ $field ] ); |
243 | | - } |
244 | | - |
245 | | - $this->setHiddenFields( $hidden_fields ); |
246 | | - } |
| 232 | + /** |
| 233 | + * Update hidden fields to not set any comment-related fields |
| 234 | + */ |
| 235 | + public function updateHiddenFields() { |
| 236 | + $hidden_fields = $this->getHiddenFields(); |
| 237 | + |
| 238 | + // make sure that the below elements are not set in the hidden fields |
| 239 | + $not_needed = array( 'comment-option', 'email-opt', 'comment' ); |
| 240 | + |
| 241 | + foreach ( $not_needed as $field ) { |
| 242 | + unset( $hidden_fields[ $field ] ); |
| 243 | + } |
| 244 | + |
| 245 | + $this->setHiddenFields( $hidden_fields ); |
| 246 | + } |
247 | 247 | } |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumnLetter.php |
— | — | @@ -5,26 +5,26 @@ |
6 | 6 | |
7 | 7 | public function __construct( &$form_data, &$form_errors ) { |
8 | 8 | global $wgOut, $wgScriptPath; |
9 | | - |
| 9 | + |
10 | 10 | // set the path to css, before the parent constructor is called, checking to make sure some child class hasn't already set this |
11 | 11 | if ( !strlen( $this->getStylePath())) { |
12 | 12 | $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoColumnLetter.css' ); |
13 | 13 | } |
14 | | - |
| 14 | + |
15 | 15 | parent::__construct( $form_data, $form_errors ); |
16 | 16 | } |
17 | 17 | |
18 | 18 | public function generateFormStart() { |
19 | 19 | global $wgOut, $wgRequest; |
20 | | - |
| 20 | + |
21 | 21 | $this->paypal = $wgRequest->getBool( 'paypal', false ); |
22 | | - |
| 22 | + |
23 | 23 | $form = parent::generateBannerHeader(); |
24 | | - |
| 24 | + |
25 | 25 | $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-cc_form_container')); |
26 | 26 | $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-cc_form_form', 'class' => 'payflowpro_gateway-cc_form_column')); |
27 | | - $form .= Xml::openElement( 'div', array( 'id' => 'mw-creditcard' ) ); |
28 | | - |
| 27 | + $form .= Xml::openElement( 'div', array( 'id' => 'mw-creditcard' ) ); |
| 28 | + |
29 | 29 | // provide a place at the top of the form for displaying general messages |
30 | 30 | if ( $this->form_errors['general'] ) { |
31 | 31 | $form .= Xml::openElement( 'div', array( 'id' => 'mw-payflow-general-error' )); |
— | — | @@ -37,42 +37,42 @@ |
38 | 38 | } |
39 | 39 | $form .= Xml::closeElement( 'div' ); // close div#mw-payflow-general-error |
40 | 40 | } |
41 | | - |
| 41 | + |
42 | 42 | // add noscript tags for javascript disabled browsers |
43 | 43 | $form .= $this->getNoScript(); |
44 | | - |
| 44 | + |
45 | 45 | // Xml::element seems to convert html to htmlentities |
46 | 46 | $form .= "<p class='creditcard-error-msg'>" . $this->form_errors['retryMsg'] . "</p>"; |
47 | 47 | $form .= Xml::openElement( 'form', array( 'name' => 'payment', 'method' => 'post', 'action' => $this->getNoCacheAction(), 'onsubmit' => 'return validate_form(this)', 'autocomplete' => 'off' ) ); |
48 | | - |
| 48 | + |
49 | 49 | $form .= $this->generateBillingContainer(); |
50 | 50 | return $form; |
51 | 51 | } |
52 | | - |
| 52 | + |
53 | 53 | public function generateFormEnd() { |
54 | 54 | global $wgRequest, $wgOut; |
55 | 55 | $form = ''; |
56 | | - |
| 56 | + |
57 | 57 | $form .= $this->generateFormClose(); |
58 | 58 | |
59 | 59 | $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-cc_form_letter', 'class' => 'payflowpro_gateway-cc_form_column')); |
60 | 60 | $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-cc_form_letter_inside' )); |
61 | | - |
| 61 | + |
62 | 62 | $text_template = $wgRequest->getText( 'text_template', '2010/JimmyAppealLong' ); |
63 | 63 | // if the user has uselang set, honor that, otherwise default to the language set for the form defined by 'language' in the query string |
64 | 64 | if ( $wgRequest->getText( 'language' )) $text_template .= '/' . $this->form_data[ 'language' ]; |
65 | | - |
| 65 | + |
66 | 66 | $template = ( strlen( $text_template )) ? $wgOut->parse( '{{'.$text_template.'}}' ) : ''; |
67 | 67 | // if the template doesn't exist, prevent the display of the red link |
68 | 68 | if ( preg_match( '/redlink\=1/', $template )) $template = NULL; |
69 | 69 | $form .= $template; |
70 | | - |
| 70 | + |
71 | 71 | $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-cc_form_letter_inside |
72 | 72 | $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-cc_form_letter |
73 | 73 | $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-cc_form_container |
74 | 74 | return $form; |
75 | 75 | } |
76 | | - |
| 76 | + |
77 | 77 | protected function generateBillingContainer() { |
78 | 78 | $form = ''; |
79 | 79 | $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-personal-info' )); |
— | — | @@ -88,30 +88,30 @@ |
89 | 89 | protected function generateBillingFields() { |
90 | 90 | global $wgScriptPath, $wgPayflowGatewayPaypalURL; |
91 | 91 | $scriptPath = "$wgScriptPath/extensions/DonationInterface/payflowpro_gateway/includes"; |
92 | | - |
| 92 | + |
93 | 93 | $form = ''; |
94 | | - |
95 | | - // name |
| 94 | + |
| 95 | + // name |
96 | 96 | $form .= $this->getNameField(); |
97 | | - |
| 97 | + |
98 | 98 | // email |
99 | 99 | $form .= $this->getEmailField(); |
100 | | - |
| 100 | + |
101 | 101 | //comment message |
102 | 102 | $form .= $this->getCommentMessageField(); |
103 | | - |
| 103 | + |
104 | 104 | //comment |
105 | 105 | $form .= $this->getCommentField(); |
106 | | - |
| 106 | + |
107 | 107 | // anonymous |
108 | 108 | $form .= $this->getCommentOptionField(); |
109 | 109 | |
110 | 110 | // email agreement |
111 | 111 | $form .= $this->getEmailOptField(); |
112 | | - |
| 112 | + |
113 | 113 | // amount |
114 | 114 | $form .= $this->getAmountField(); |
115 | | - |
| 115 | + |
116 | 116 | if ( !$this->paypal ) { |
117 | 117 | // PayPal button |
118 | 118 | // make sure we have a paypal url set to redirect the user to before displaying the button |
— | — | @@ -127,27 +127,27 @@ |
128 | 128 | $form .= '</td>'; |
129 | 129 | $form .= '</tr>'; |
130 | 130 | } |
131 | | - |
| 131 | + |
132 | 132 | // card number |
133 | 133 | $form .= $this->getCardNumberField(); |
134 | | - |
| 134 | + |
135 | 135 | // cvv |
136 | 136 | $form .= $this->getCvvField(); |
137 | | - |
| 137 | + |
138 | 138 | // expiry |
139 | 139 | $form .= $this->getExpiryField(); |
140 | | - |
| 140 | + |
141 | 141 | // street |
142 | 142 | $form .= $this->getStreetField(); |
143 | | - |
| 143 | + |
144 | 144 | // city |
145 | 145 | $form .= $this->getCityField(); |
146 | | - |
| 146 | + |
147 | 147 | // state |
148 | 148 | $form .= $this->getStateField(); |
149 | 149 | // zip |
150 | 150 | $form .= $this->getZipField(); |
151 | | - |
| 151 | + |
152 | 152 | // country |
153 | 153 | $form .= $this->getCountryField(); |
154 | 154 | } |
— | — | @@ -160,12 +160,12 @@ |
161 | 161 | */ |
162 | 162 | public function generateFormClose() { |
163 | 163 | $form = ''; |
164 | | - // add hidden fields |
| 164 | + // add hidden fields |
165 | 165 | $hidden_fields = $this->getHiddenFields(); |
166 | 166 | foreach ( $hidden_fields as $field => $value ) { |
167 | 167 | $form .= Xml::hidden( $field, $value ); |
168 | 168 | } |
169 | | - |
| 169 | + |
170 | 170 | $form .= Xml::closeElement( 'form' ); // close form 'payment' |
171 | 171 | $form .= $this->generateDonationFooter(); |
172 | 172 | if ( $this->paypal ) { |