Index: trunk/extensions/DonationInterface/globalcollect_gateway/forms/TwoStepAmount.php |
— | — | @@ -24,26 +24,174 @@ |
25 | 25 | class Gateway_Form_TwoStepAmount extends Gateway_Form { |
26 | 26 | |
27 | 27 | /** |
| 28 | + * The default value of section header tags. |
| 29 | + * |
| 30 | + * A value of 3 => h3 |
| 31 | + * |
| 32 | + * @var integer $sectionHeaderLevel |
| 33 | + */ |
| 34 | + public $sectionHeaderLevel = 3; |
| 35 | + |
| 36 | + /** |
| 37 | + * The appeal |
| 38 | + * |
| 39 | + * @var string $appeal |
| 40 | + */ |
| 41 | + public $appeal = ''; |
| 42 | + |
| 43 | + /** |
| 44 | + * The default appeal |
| 45 | + * |
| 46 | + */ |
| 47 | + const DEFAULT_APPEAL = <<<HTML |
| 48 | + <h2 id="appeal-head"> <span class="mw-headline" id="From_Wikipedia_programmer_Brandon_Harris">From Wikipedia programmer Brandon Harris</span></h2> |
| 49 | + <div id="appeal-body" class="plainlinks"> |
| 50 | + <p>I feel like I'm living the first line of my obituary.</p> |
| 51 | + <p>I don't think there will be anything else that I do in my life as important as what I do now for Wikipedia. We're not just building an encyclopedia, we're working to make people free. When we have access to free knowledge, we are better people. We understand the world is bigger than us, and we become infected with tolerance and understanding.</p> |
| 52 | + <p>Wikipedia is the 5th largest website in the world. I work at the small non-profit that keeps it on the web. We don't run ads because doing so would sacrifice our independence. The site is not and should never be a propaganda tool.</p> |
| 53 | + <p>Our work is possible because of donations from our readers. Will you help protect Wikipedia by donating $5, $10, $20 or whatever you can afford?</p> |
| 54 | + <p>I work at the Wikimedia Foundation because everything in my soul tells me it's the right thing to do. I've worked at huge tech companies, doing some job to build some crappy thing that's designed to steal money from some kid who doesn't know it. I would come home from work crushed.</p> |
| 55 | + <p>You might not know this, but the Wikimedia Foundation operates with a very small staff. Most other top-ten sites have tens of thousands of people and massive budgets. But they produce a fraction of what we pull off with sticks and wire.</p> |
| 56 | + <p>When you give to Wikipedia, you're supporting free knowledge around the world. You're not only leaving a legacy for your children and for their children, you're elevating people around the world who have access to this treasure. You're assuring that one day everyone else will too.</p> |
| 57 | + <p>Thank you,</p> |
| 58 | + <p><strong>Brandon Harris</strong><br /></p> |
| 59 | + <p>Programmer, Wikimedia Foundation</p> |
| 60 | + </div> |
| 61 | +HTML; |
| 62 | + |
| 63 | + //////////////////////////////////////////////////////////////////////////// |
| 64 | + // |
| 65 | + // Form methods |
| 66 | + // |
| 67 | + //////////////////////////////////////////////////////////////////////////// |
| 68 | + |
| 69 | + /** |
28 | 70 | * Initialize the form |
29 | 71 | * |
| 72 | + * This is called at the end of the constructor |
| 73 | + * |
30 | 74 | */ |
31 | 75 | protected function init() { |
32 | 76 | |
33 | | - //TODO: This is pretty odd to do here. However, as this form is only |
34 | | - //being used for testing purposes, it's getting the update that goes |
35 | | - //along with yet another change in Form Class construction. |
36 | | - $this->form_data['payment_method'] = empty($this->form_data['payment_method']) ? 'bt' : $this->form_data['payment_method']; |
37 | | - $this->form_data['payment_submethod'] = empty($this->form_data['payment_submethod']) ? 'bt' : $this->form_data['payment_submethod']; |
38 | | - |
39 | 77 | $this->setPaymentMethod( $this->form_data['payment_method'] ); |
40 | 78 | $this->setPaymentSubmethod( $this->form_data['payment_submethod'] ); |
41 | 79 | |
| 80 | + // Should process be deprecated? |
42 | 81 | $this->form_data['process'] = 'other'; |
43 | | - |
| 82 | + |
| 83 | + // Initialize the appeal |
| 84 | + $this->appeal = self::DEFAULT_APPEAL; |
| 85 | + |
44 | 86 | $this->loadResources(); |
45 | 87 | } |
46 | 88 | |
47 | 89 | /** |
| 90 | + * Required method for returning the full HTML for a form. |
| 91 | + * |
| 92 | + * @return string The entire form HTML |
| 93 | + */ |
| 94 | + public function getForm() { |
| 95 | + |
| 96 | + return $this->getFormPage(); |
| 97 | + |
| 98 | + $form = ''; |
| 99 | + |
| 100 | + $form .= $this->generateFormStart(); |
| 101 | + $form .= $this->generateFormEnd(); |
| 102 | + return $form; |
| 103 | + } |
| 104 | + |
| 105 | + /** |
| 106 | + * Get the form messages |
| 107 | + * |
| 108 | + * @param array $options |
| 109 | + * |
| 110 | + * @todo |
| 111 | + * - Does retryMsg need to be displayed? |
| 112 | + * |
| 113 | + * @return string Returns an HTML string |
| 114 | + */ |
| 115 | + public function getFormMessages( $options = array() ) { |
| 116 | + |
| 117 | + $return = ''; |
| 118 | + |
| 119 | + // We want this container to exist so it can be populated with javascript messages. |
| 120 | + $return .= Xml::openElement( 'div', array( 'id' => 'payment_form_messages' ) ); |
| 121 | + |
| 122 | + // If errors are present, allow them to be displayed. |
| 123 | + if ( $this->form_errors['general'] ) { |
| 124 | + |
| 125 | + if ( is_array( $this->form_errors['general'] ) ) { |
| 126 | + |
| 127 | + // Loop through messages and display them as paragraphs |
| 128 | + foreach ( $this->form_errors['general'] as $this->form_errors_msg ) { |
| 129 | + $return .= Xml::tags( 'p', array( 'class' => 'creditcard-error-message' ), $this->form_errors_msg ); |
| 130 | + } |
| 131 | + } else { |
| 132 | + |
| 133 | + // Display single message |
| 134 | + $return .= Xml::tags( 'p', array( 'class' => 'creditcard-error-message' ), $this->form_errors_msg ); |
| 135 | + } |
| 136 | + } |
| 137 | + |
| 138 | + if ( $this->form_errors['invalidamount'] ) { |
| 139 | + $return .= Xml::tags( 'p', array( 'class' => 'creditcard-error-message' ), $this->form_errors['invalidamount'] ); |
| 140 | + } |
| 141 | + |
| 142 | + $return .= Xml::closeElement( 'div' ); // payment_form_messages |
| 143 | + //$return .= "<p class='creditcard-error-msg'>" . $this->form_errors['retryMsg'] . "</p>"; |
| 144 | + |
| 145 | + return $return; |
| 146 | + } |
| 147 | + |
| 148 | + /** |
| 149 | + * Get the section header tag |
| 150 | + * |
| 151 | + * @param string $section The section label |
| 152 | + * @param array $options |
| 153 | + * |
| 154 | + * @return string Returns an HTML string |
| 155 | + */ |
| 156 | + public function getFormSectionHeaderTag( $section, $options = array() ) { |
| 157 | + |
| 158 | + // Make sure $section does not get overridden. |
| 159 | + if ( isset( $options['section'] ) ) { |
| 160 | + |
| 161 | + unset( $options['section'] ); |
| 162 | + } |
| 163 | + |
| 164 | + extract( $options ); |
| 165 | + |
| 166 | + $headerLevel = isset( $headerLevel ) ? (integer) $headerLevel : (integer) $this->sectionHeaderLevel; |
| 167 | + $headerId = isset( $headerId ) ? (string) $headerId : ''; |
| 168 | + $headerClass = isset( $headerClass ) ? (string) $headerClass : ''; |
| 169 | + |
| 170 | + // Set maximum level to 6 |
| 171 | + $headerLevel = ( $headerLevel > 6 ) ? 6 : $headerLevel; |
| 172 | + |
| 173 | + // Set minimum level to 2 |
| 174 | + $headerLevel = ( $headerLevel < 2 ) ? 2 : $headerLevel; |
| 175 | + |
| 176 | + $headerTag = 'h' . $headerLevel; |
| 177 | + |
| 178 | + $headerOptions = array(); |
| 179 | + |
| 180 | + // Add a header class |
| 181 | + if ( !empty( $headerClass ) ) { |
| 182 | + $headerOptions['class'] = $headerClass; |
| 183 | + } |
| 184 | + |
| 185 | + // Add a header id |
| 186 | + if ( !empty( $headerId ) ) { |
| 187 | + $headerOptions['id'] = $headerId; |
| 188 | + } |
| 189 | + |
| 190 | + $return .= Xml::tags( $headerTag, $headerOptions, $section ); |
| 191 | + |
| 192 | + return $return; |
| 193 | + } |
| 194 | + |
| 195 | + /** |
48 | 196 | * Load form resources |
49 | 197 | */ |
50 | 198 | protected function loadResources() { |
— | — | @@ -58,7 +206,6 @@ |
59 | 207 | global $wgOut; |
60 | 208 | $wgOut->addModules( 'gc.form.core.validate' ); |
61 | 209 | |
62 | | - //$js = "\n" . '<script type="text/javascript">' . "validateForm( { validate: { address: true, amount: true, creditCard: false, email: true, name: true, }, payment_method: '" . $this->getPaymentMethod() . "', payment_submethod: '" . $this->getPaymentSubmethod() . "', formId: '" . $this->getFormId() . "' } );" . '</script>' . "\n"; |
63 | 210 | $js = "\n" . '<script type="text/javascript">' |
64 | 211 | . "var validatePaymentForm = { |
65 | 212 | formId: '" . $this->getFormId() . "', |
— | — | @@ -68,20 +215,414 @@ |
69 | 216 | . '</script>' . "\n"; |
70 | 217 | $wgOut->addHeadItem( 'loadValidateJs', $js ); |
71 | 218 | } |
| 219 | + |
| 220 | + //////////////////////////////////////////////////////////////////////////// |
| 221 | + // |
| 222 | + // Get and set html snippets of code for form |
| 223 | + // |
| 224 | + //////////////////////////////////////////////////////////////////////////// |
72 | 225 | |
73 | 226 | /** |
74 | | - * Required method for returning the full HTML for a form. |
| 227 | + * Set the appeal |
75 | 228 | * |
76 | | - * @return string The entire form HTML |
| 229 | + * @param string $appeal The html appeal text |
| 230 | + * @param array $options |
| 231 | + * |
| 232 | + * @return string Returns an HTML string |
77 | 233 | */ |
78 | | - public function getForm() { |
79 | | - $form = $this->generateFormStart(); |
80 | | - $form .= $this->getCaptchaHTML(); |
81 | | - $form .= $this->generateFormEnd(); |
82 | | - return $form; |
| 234 | + public function setAppeal( $appeal, $options = array() ) { |
| 235 | + |
| 236 | + $this->appeal = $appeal; |
83 | 237 | } |
| 238 | + |
| 239 | + /** |
| 240 | + * Get the appeal |
| 241 | + * |
| 242 | + * @param array $options |
| 243 | + * |
| 244 | + * @return string Returns an HTML string |
| 245 | + */ |
| 246 | + public function getAppeal( $options = array() ) { |
84 | 247 | |
| 248 | + $return = ''; |
| 249 | + |
| 250 | + $return .= Xml::openElement( 'div', array( 'id' => 'appeal' ) ); |
| 251 | + |
| 252 | + $return .= Xml::openElement( 'div', array( 'id' => 'appeal-content' ) ); |
| 253 | + |
| 254 | + $return .= $this->appeal; |
| 255 | + |
| 256 | + $return .= Xml::closeElement( 'div' ); // appeal-content |
| 257 | + |
| 258 | + $return .= Xml::closeElement( 'div' ); // appeal |
| 259 | + |
| 260 | + return $return; |
| 261 | + } |
| 262 | + |
85 | 263 | /** |
| 264 | + * Generate the direct debit component |
| 265 | + * |
| 266 | + * @param array $options |
| 267 | + * |
| 268 | + * @return string Returns an HTML string |
| 269 | + */ |
| 270 | + public function getDirectDebit( $options = array() ) { |
| 271 | + |
| 272 | + extract( $options ); |
| 273 | + |
| 274 | + $return = ''; |
| 275 | + |
| 276 | + $ignore = isset( $ignore ) ? (array) $ignore : array(); |
| 277 | + |
| 278 | + if ( $this->getPaymentMethod() != 'dd' ) { |
| 279 | + |
| 280 | + // No direct debit fields need to be loaded. |
| 281 | + return $form; |
| 282 | + } |
| 283 | + |
| 284 | + $fields = array( |
| 285 | + 'account_name' => array( 'required' => true, ), |
| 286 | + 'account_number' => array( 'required' => true, ), |
| 287 | + 'authorization_id' => array( 'required' => true, ), |
| 288 | + 'bank_check_digit' => array( 'required' => true, ), |
| 289 | + 'bank_code' => array( 'required' => true, ), |
| 290 | + 'bank_name' => array( 'required' => true, ), |
| 291 | + 'branch_code' => array( 'required' => true, ), |
| 292 | + 'direct_debit_text' => array( 'required' => true, ), |
| 293 | + 'iban' => array( 'required' => true, ), |
| 294 | + ); |
| 295 | + |
| 296 | + $country = isset( $this->form_data['country'] ) ? $this->form_data['country'] : ''; |
| 297 | + |
| 298 | + if ( $country == 'AT' ) { |
| 299 | + |
| 300 | + unset( $fields['bank_check_digit'] ); |
| 301 | + unset( $fields['branch_code'] ); |
| 302 | + unset( $fields['iban'] ); |
| 303 | + } |
| 304 | + elseif ( $country == 'BE' ) { |
| 305 | + |
| 306 | + unset( $fields['bank_code'] ); |
| 307 | + unset( $fields['bank_check_digit'] ); |
| 308 | + unset( $fields['branch_code'] ); |
| 309 | + unset( $fields['iban'] ); |
| 310 | + } |
| 311 | + elseif ( $country == 'IT' ) { |
| 312 | + |
| 313 | + unset( $fields['iban'] ); |
| 314 | + } |
| 315 | + elseif ( $country == 'NL' ) { |
| 316 | + |
| 317 | + unset( $fields['bank_check_digit'] ); |
| 318 | + unset( $fields['branch_code'] ); |
| 319 | + unset( $fields['iban'] ); |
| 320 | + } |
| 321 | + elseif ( $country == 'ES' ) { |
| 322 | + |
| 323 | + unset( $fields['iban'] ); |
| 324 | + } |
| 325 | + |
| 326 | + |
| 327 | + foreach ( $fields as $field => $meta ) { |
| 328 | + |
| 329 | + // Skip ignored fields |
| 330 | + if ( in_array( $field, $ignore ) ) { |
| 331 | + |
| 332 | + continue; |
| 333 | + } |
| 334 | + |
| 335 | + $return .= '<tr>'; |
| 336 | + $return .= '<td class="label">' . Xml::label( wfMsg( 'donate_interface-dd-' . $field ), $field ) . '</td>'; |
| 337 | + |
| 338 | + $return .= '<td>'; |
| 339 | + |
| 340 | + $required = isset ( $meta['required'] ) ? (boolean) $meta['required'] : false ; |
| 341 | + $elementClass = ''; |
| 342 | + $elementClass .= $required ? ' required ' : '' ; |
| 343 | + $elementClass = trim( $elementClass ); |
| 344 | + |
| 345 | + $return .= Xml::input( $field, '', $this->form_data[ $field ], array( 'class' => $elementClass, 'type' => 'text', 'maxlength' => '32', 'id' => $field ) ); |
| 346 | + $return .= '</td>'; |
| 347 | + $return .= '</tr>'; |
| 348 | + } |
| 349 | + |
| 350 | + return $return; |
| 351 | + } |
| 352 | + |
| 353 | + /** |
| 354 | + * Get the end of the form |
| 355 | + * |
| 356 | + * This method gets the hidden fields and appends the closing form tag. |
| 357 | + * |
| 358 | + * @param array $options |
| 359 | + * |
| 360 | + * @return string Returns an HTML string |
| 361 | + */ |
| 362 | + protected function getFormEnd( $options = array() ) { |
| 363 | + |
| 364 | + extract( $options ); |
| 365 | + |
| 366 | + $return = ''; |
| 367 | + |
| 368 | + $return .= $this->generateFormSubmit(); |
| 369 | + |
| 370 | + // Add hidden fields |
| 371 | + foreach ( $this->getHiddenFields() as $field => $value ) { |
| 372 | + |
| 373 | + $return .= Html::hidden( $field, $value ); |
| 374 | + } |
| 375 | + |
| 376 | + $return .= Xml::closeElement( 'form' ); |
| 377 | + |
| 378 | + return $return; |
| 379 | + } |
| 380 | + |
| 381 | + /** |
| 382 | + * Get the page including form and content |
| 383 | + * |
| 384 | + * @param array $options |
| 385 | + * |
| 386 | + * @return string Returns an HTML string |
| 387 | + */ |
| 388 | + protected function getFormPage( $options = array() ) { |
| 389 | + |
| 390 | + extract( $options ); |
| 391 | + |
| 392 | + $return = ''; |
| 393 | + |
| 394 | + $headerLevel = isset( $headerLevel ) ? (integer) $headerLevel : 3; |
| 395 | + |
| 396 | + // Tell the user they need JavaScript enabled. |
| 397 | + $return .= $this->getNoScript(); |
| 398 | + |
| 399 | + // Display the form messages |
| 400 | + $return .= $this->getFormMessages( $options ); |
| 401 | + |
| 402 | + $return .= Xml::openElement( 'div', array( 'id' => 'payment_form_container' ) ); |
| 403 | + |
| 404 | + $return .= $this->getFormStart(); |
| 405 | + |
| 406 | + $return .= $this->getCaptchaHTML(); |
| 407 | + |
| 408 | + $return .= $this->getFormSectionAmount(); |
| 409 | + |
| 410 | + $return .= $this->getFormSectionPersonal(); |
| 411 | + |
| 412 | + $return .= $this->getFormSectionPayment(); |
| 413 | + |
| 414 | + $return .= $this->getFormEnd(); |
| 415 | + |
| 416 | + $return .= $this->generateDonationFooter(); |
| 417 | + |
| 418 | + $return .= Xml::closeElement( 'div' ); // payment_form_container |
| 419 | + |
| 420 | + // Display the appeal |
| 421 | + $return .= $this->getAppeal( $options ); |
| 422 | + |
| 423 | + return $return; |
| 424 | + } |
| 425 | + |
| 426 | + /** |
| 427 | + * Get the page including form and content |
| 428 | + * |
| 429 | + * @param array $options |
| 430 | + * |
| 431 | + * @return string Returns an HTML string |
| 432 | + */ |
| 433 | + protected function generateFormSubmit( $options = array() ) { |
| 434 | + |
| 435 | + extract( $options ); |
| 436 | + |
| 437 | + $return = ''; |
| 438 | + |
| 439 | + // submit button |
| 440 | + $return .= Xml::openElement( 'div', array( 'id' => 'payment_gateway-form-submit' ) ); |
| 441 | + $return .= Xml::openElement( 'div', array( 'id' => 'mw-donate-submit-button' ) ); |
| 442 | + $return .= Xml::element( 'input', array( 'class' => 'button-plain', 'value' => wfMsg( 'donate_interface-submit-button' ), 'type' => 'submit' ) ); |
| 443 | + $return .= Xml::closeElement( 'div' ); // close div#mw-donate-submit-button |
| 444 | + $return .= Xml::closeElement( 'div' ); // close div#payment_gateway-form-submit |
| 445 | + |
| 446 | + return $return; |
| 447 | + } |
| 448 | + |
| 449 | + /** |
| 450 | + * Get the start of the form |
| 451 | + * |
| 452 | + * @param array $options |
| 453 | + * |
| 454 | + * @return string Returns an HTML string |
| 455 | + */ |
| 456 | + protected function getFormStart( $options = array() ) { |
| 457 | + |
| 458 | + extract( $options ); |
| 459 | + |
| 460 | + $return = ''; |
| 461 | + |
| 462 | + $formOptions = array( |
| 463 | + 'action' => $this->getNoCacheAction(), |
| 464 | + 'autocomplete' => 'off', |
| 465 | + 'id' => $this->getFormId(), |
| 466 | + 'method' => 'post', |
| 467 | + 'name' => $this->getFormName(), |
| 468 | + 'onsubmit' => '', |
| 469 | + ); |
| 470 | + |
| 471 | + // Xml::element seems to convert html to htmlentities |
| 472 | + $return .= Xml::openElement( 'form', $formOptions ); |
| 473 | + |
| 474 | + return $return; |
| 475 | + } |
| 476 | + |
| 477 | + //////////////////////////////////////////////////////////////////////////// |
| 478 | + // |
| 479 | + // Form sections |
| 480 | + // |
| 481 | + //////////////////////////////////////////////////////////////////////////// |
| 482 | + |
| 483 | + /** |
| 484 | + * Get the donation amount section |
| 485 | + * |
| 486 | + * @param array $options |
| 487 | + * |
| 488 | + * Fields: |
| 489 | + * - amount|amountRadio |
| 490 | + * - currency_code |
| 491 | + * |
| 492 | + * @return string Returns an HTML string |
| 493 | + */ |
| 494 | + public function getFormSectionAmount( $options = array() ) { |
| 495 | + |
| 496 | + $return = ''; |
| 497 | + |
| 498 | + $id = 'section_amount'; |
| 499 | + |
| 500 | + $headerOptions = $options; |
| 501 | + |
| 502 | + $headerOptions['id'] = $id . '_header'; |
| 503 | + |
| 504 | + $return .= $this->getFormSectionHeaderTag( wfMsg( 'donate_interface-currency' ), $headerOptions ); |
| 505 | + |
| 506 | + $return .= Xml::openElement( 'div', array( 'id' => $id ) ); // $id |
| 507 | + |
| 508 | + $radioOptions = array(); |
| 509 | + $radioOptions['showCardsOnCurrencyChange'] = false; |
| 510 | + |
| 511 | + $country = isset( $this->form_data['country'] ) ? $this->form_data['country'] : ''; |
| 512 | + |
| 513 | + if ( $country == 'SG' ) { |
| 514 | + $radioOptions['setCurrency'] = 'SGD'; |
| 515 | + } |
| 516 | + |
| 517 | + $return .= $this->generateAmountByRadio( $radioOptions ); |
| 518 | + |
| 519 | + $return .= Xml::closeElement( 'div' ); // $id |
| 520 | + |
| 521 | + return $return; |
| 522 | + } |
| 523 | + |
| 524 | + /** |
| 525 | + * Get the personal information section |
| 526 | + * |
| 527 | + * @param array $options |
| 528 | + * |
| 529 | + * Fields: |
| 530 | + * - fname |
| 531 | + * - lname |
| 532 | + * - email |
| 533 | + * - street |
| 534 | + * - city |
| 535 | + * - zip |
| 536 | + * - country |
| 537 | + * |
| 538 | + * @return string Returns an HTML string |
| 539 | + */ |
| 540 | + public function getFormSectionPersonal( $options = array() ) { |
| 541 | + |
| 542 | + $return = ''; |
| 543 | + |
| 544 | + $id = 'section_personal'; |
| 545 | + |
| 546 | + $headerOptions = $options; |
| 547 | + |
| 548 | + $headerOptions['id'] = $id . '_header'; |
| 549 | + |
| 550 | + $return .= $this->getFormSectionHeaderTag( wfMsg( 'donate_interface-cc-form-header-personal' ), $headerOptions ); |
| 551 | + |
| 552 | + $return .= Xml::openElement( 'div', array( 'id' => $id ) ); // $id |
| 553 | + |
| 554 | + $return .= Xml::openElement( 'table', array( 'id' => $id . '_table' ) ); |
| 555 | + |
| 556 | + $return .= $this->getNameField(); |
| 557 | + |
| 558 | + // email |
| 559 | + $return .= $this->getEmailField(); |
| 560 | + |
| 561 | + // street |
| 562 | + $return .= $this->getStreetField(); |
| 563 | + |
| 564 | + // city |
| 565 | + $return .= $this->getCityField(); |
| 566 | + |
| 567 | + // state |
| 568 | + //$return .= $this->getStateField(); |
| 569 | + |
| 570 | + // zip |
| 571 | + $return .= $this->getZipField(); |
| 572 | + |
| 573 | + // country |
| 574 | + $return .= $this->getCountryField(); |
| 575 | + |
| 576 | + $return .= Xml::closeElement( 'table' ); // close $id . '_table' |
| 577 | + |
| 578 | + $return .= Xml::closeElement( 'div' ); // $id |
| 579 | + |
| 580 | + return $return; |
| 581 | + } |
| 582 | + |
| 583 | + /** |
| 584 | + * Get the payment information section |
| 585 | + * |
| 586 | + * @param array $options |
| 587 | + * |
| 588 | + * Fields: |
| 589 | + * - rtbt |
| 590 | + * - bt |
| 591 | + * - dd |
| 592 | + * |
| 593 | + * @return string Returns an HTML string |
| 594 | + */ |
| 595 | + public function getFormSectionPayment( $options = array() ) { |
| 596 | + |
| 597 | + $return = ''; |
| 598 | + |
| 599 | + $id = 'section_personal'; |
| 600 | + |
| 601 | + $headerOptions = $options; |
| 602 | + |
| 603 | + $headerOptions['id'] = $id . '_header'; |
| 604 | + |
| 605 | + $return .= $this->getFormSectionHeaderTag( wfMsg( 'donate_interface-cc-form-header-payment' ), $headerOptions ); |
| 606 | + |
| 607 | + $return .= Xml::openElement( 'div', array( 'id' => $id ) ); // $id |
| 608 | + |
| 609 | + $return .= Xml::openElement( 'table', array( 'id' => $id . '_table' ) ); |
| 610 | + |
| 611 | + $return .= $this->getDirectDebit(); |
| 612 | + |
| 613 | + $return .= Xml::closeElement( 'table' ); // close $id . '_table' |
| 614 | + |
| 615 | + $return .= Xml::closeElement( 'div' ); // $id |
| 616 | + |
| 617 | + return $return; |
| 618 | + } |
| 619 | + |
| 620 | + //////////////////////////////////////////////////////////////////////////// |
| 621 | + // |
| 622 | + // Deprecated |
| 623 | + // |
| 624 | + //////////////////////////////////////////////////////////////////////////// |
| 625 | + |
| 626 | + /** |
86 | 627 | * Generate the payment information |
87 | 628 | * |
88 | 629 | * @todo |
— | — | @@ -114,6 +655,8 @@ |
115 | 656 | |
116 | 657 | // Payment methods that are not supported by this form. |
117 | 658 | $ignorePaymentMethod = array( 'cc', ); |
| 659 | + |
| 660 | + // Loop through forms to display |
118 | 661 | foreach ( $this->gateway->getPaymentMethods() as $payment_method => $payment_methodMeta ) { |
119 | 662 | |
120 | 663 | if ( in_array( $payment_method, $ignorePaymentMethod ) ) { |
— | — | @@ -144,6 +687,7 @@ |
145 | 688 | public function generateFormIssuerIdDropdown() { |
146 | 689 | |
147 | 690 | $form = ''; |
| 691 | + //return $form; |
148 | 692 | |
149 | 693 | $payment_submethod = $this->gateway->getPaymentSubmethodMeta( $this->getPaymentSubmethod() ); |
150 | 694 | if ( !isset( $payment_submethod['issuerids'] ) || empty( $payment_submethod['issuerids'] ) ) { |
— | — | @@ -156,12 +700,12 @@ |
157 | 701 | |
158 | 702 | // generate dropdown of issuer_ids |
159 | 703 | foreach ( $payment_submethod['issuerids'] as $issuer_id => $issuer_id_label ) { |
160 | | - $selected = ( $this->form_data['issuer_id'] == $value ) ? true : false; |
| 704 | + $selected = ( $this->form_data['issuer_id'] == $issuer_id ) ? true : false; |
161 | 705 | //$selectOptions .= Xml::option( wfMsg( 'donate_interface-rtbt-' . $issuer_id ), $issuer_id_label, $selected ); |
162 | | - $selectOptions .= Xml::option( $issuer_id_label, $issuer_id_label, $selected ); |
| 706 | + $selectOptions .= Xml::option( $issuer_id_label, $issuer_id, $selected ); |
163 | 707 | } |
164 | 708 | $form .= '<tr>'; |
165 | | - $form .= '<td class="label">' . Xml::label( wfMsg( 'donate_interface-donor-issuer_id' ), 'issuer_id' ) . '</td>'; |
| 709 | + $form .= '<td class="label">' . Xml::label( wfMsg( 'donate_interface-rtbt-issuer_id' ), 'issuer_id' ) . '</td>'; |
166 | 710 | |
167 | 711 | $form .= '<td>'; |
168 | 712 | $form .= Xml::openElement( |
— | — | @@ -180,6 +724,7 @@ |
181 | 725 | return $form; |
182 | 726 | } |
183 | 727 | |
| 728 | + |
184 | 729 | /** |
185 | 730 | * Generate the first part of the form |
186 | 731 | */ |
— | — | @@ -227,16 +772,6 @@ |
228 | 773 | return $form; |
229 | 774 | } |
230 | 775 | |
231 | | - public function generateFormSubmit() { |
232 | | - // submit button |
233 | | - $form = Xml::openElement( 'div', array( 'id' => 'payment_gateway-form-submit' ) ); |
234 | | - $form .= Xml::openElement( 'div', array( 'id' => 'mw-donate-submit-button' ) ); |
235 | | - $form .= Xml::element( 'input', array( 'class' => 'button-plain', 'value' => wfMsg( 'donate_interface-submit-button' ), 'type' => 'submit' ) ); |
236 | | - $form .= Xml::closeElement( 'div' ); // close div#mw-donate-submit-button |
237 | | - $form .= Xml::closeElement( 'div' ); // close div#payment_gateway-form-submit |
238 | | - return $form; |
239 | | - } |
240 | | - |
241 | 776 | public function generateFormEnd() { |
242 | 777 | $form = ''; |
243 | 778 | // add hidden fields |
— | — | @@ -291,7 +826,7 @@ |
292 | 827 | |
293 | 828 | return $form; |
294 | 829 | } |
295 | | - |
| 830 | + |
296 | 831 | protected function generatePaymentContainer() { |
297 | 832 | $form = ''; |
298 | 833 | // credit card info |
— | — | @@ -309,17 +844,12 @@ |
310 | 845 | |
311 | 846 | protected function generatePaymentFields() { |
312 | 847 | // amount |
313 | | - $form = '<tr>'; |
314 | | - $form .= '<td colspan="2"><span class="donation-error-msg">' . $this->form_errors['invalidamount'] . '</span></td>'; |
315 | | - $form .= '</tr>'; |
316 | | - $form .= '<tr>'; |
317 | | - $form .= '<td class="label">' . Xml::label( wfMsg( 'donate_interface-donor-amount' ), 'amount' ) . '</td>'; |
318 | | - $form .= '<td>' . Xml::input( 'amount', '7', $this->form_data['amount'], array( 'class' => 'required', 'type' => 'text', 'maxlength' => '10', 'id' => 'amount' ) ) . |
319 | | - ' ' . $this->generateCurrencyDropdown( array( 'showCardsOnCurrencyChange' => false, ) ) . '</td>'; |
320 | | - $form .= '</tr>'; |
| 848 | + $form .= $this->generateAmountByRadio(); |
321 | 849 | |
322 | 850 | $form .= $this->generateFormIssuerIdDropdown(); |
| 851 | + $form .= $this->generateFormDirectDebit(); |
323 | 852 | |
| 853 | + |
324 | 854 | return $form; |
325 | 855 | } |
326 | 856 | } |