Index: trunk/extensions/DonationInterface/gateway_forms/Form.php |
— | — | @@ -106,14 +106,15 @@ |
107 | 107 | |
108 | 108 | /** |
109 | 109 | * Initialize the form |
110 | | - * |
| 110 | + * Called by the main Form construtror, this was clearly meant to be |
| 111 | + * overridden where necessary in child classes. |
111 | 112 | */ |
112 | 113 | protected function init() { |
113 | 114 | } |
114 | 115 | |
115 | 116 | /** |
116 | | - * Override the link in the logo to redirec to a particular form |
117 | | - * rather than the main page |
| 117 | + * Override the link in the logo to redirect to a particular form |
| 118 | + * rather than the main page. Called by the form class constructor. |
118 | 119 | */ |
119 | 120 | public function loadLogoLinkOverride() { |
120 | 121 | global $wgOut; |
— | — | @@ -147,6 +148,7 @@ |
148 | 149 | |
149 | 150 | /** |
150 | 151 | * Generates the donation footer ("There are other ways to give...") |
| 152 | + * This function is not used by any RapidHTML forms. |
151 | 153 | * @return string of HTML |
152 | 154 | */ |
153 | 155 | public function generateDonationFooter() { |
— | — | @@ -171,6 +173,7 @@ |
172 | 174 | |
173 | 175 | /** |
174 | 176 | * Generate the menu select of countries |
| 177 | + * This function is not used by any RapidHTML forms. |
175 | 178 | * @fixme It would be great if we could default the country to the user's locale |
176 | 179 | * @fixme We should also do a locale-based asort on the country dropdown |
177 | 180 | * (see http://us.php.net/asort) |
— | — | @@ -214,7 +217,9 @@ |
215 | 218 | } |
216 | 219 | |
217 | 220 | /** |
218 | | - * Genereat the menu select of credit cards |
| 221 | + * Generate the menu select of credit cards |
| 222 | + * getCreditCardTypeField helper function, and getCreditCardTypeField is |
| 223 | + * only used by TwoStepTwoColumn.php. |
219 | 224 | * |
220 | 225 | * @fixme Abstract out the setting of avaiable cards |
221 | 226 | * @return string |
— | — | @@ -249,6 +254,12 @@ |
250 | 255 | return $card_menu; |
251 | 256 | } |
252 | 257 | |
| 258 | + /** |
| 259 | + * Generates the expiry month dropdown form element. |
| 260 | + * This function is not used by any RapidHTML forms. |
| 261 | + * @global type $wgLang |
| 262 | + * @return type |
| 263 | + */ |
253 | 264 | public function generateExpiryMonthDropdown() { |
254 | 265 | global $wgLang; |
255 | 266 | |
— | — | @@ -280,6 +291,12 @@ |
281 | 292 | return $expiry_month_menu; |
282 | 293 | } |
283 | 294 | |
| 295 | + /** |
| 296 | + * Generates the expiry year dropdown form element. |
| 297 | + * This function is not used by any RapidHTML forms. |
| 298 | + * @global type $wgLang |
| 299 | + * @return type |
| 300 | + */ |
284 | 301 | public function generateExpiryYearDropdown() { |
285 | 302 | // derive the previously set expiry year, if set |
286 | 303 | $year = NULL; |
— | — | @@ -309,6 +326,7 @@ |
310 | 327 | |
311 | 328 | /** |
312 | 329 | * Generates the dropdown for states |
| 330 | + * This function is not used by any RapidHTML forms. |
313 | 331 | * @fixme Alpha sort (ideally locale alpha sort) states in dropdown |
314 | 332 | * AFTER state names are translated |
315 | 333 | * @return string The entire HTML select element for the state dropdown list |
— | — | @@ -340,6 +358,7 @@ |
341 | 359 | |
342 | 360 | /** |
343 | 361 | * Generates the dropdown list for available currencies |
| 362 | + * This function is not used by any RapidHTML forms. |
344 | 363 | * |
345 | 364 | * @param string $defaultCurrencyCode default currency code to select |
346 | 365 | * @param boolean $showCardsOnCurrencyChange Allow javascript onchange="showCards();" to be executed. |
— | — | @@ -396,12 +415,16 @@ |
397 | 416 | |
398 | 417 | /** |
399 | 418 | * Generates the radio buttons for selecting a donation amount |
| 419 | + * This function appears to be used only by the Universal Test form, and as |
| 420 | + * such should be moved to that class and away from the class all the forms |
| 421 | + * are eventually descended from. |
400 | 422 | * |
401 | 423 | * @param array $options |
402 | 424 | * |
403 | 425 | * $options: |
404 | 426 | * - displayCurrencyDropdown: Display the currency dropdown selector |
405 | 427 | * - showCardsOnCurrencyChange: Passed to @see Gateway_Form::generateStateDropdown() |
| 428 | + * - setCurrency: ??? |
406 | 429 | * |
407 | 430 | * @todo |
408 | 431 | * - Use Xml object to generate form elements. |
— | — | @@ -410,6 +433,7 @@ |
411 | 434 | */ |
412 | 435 | public function generateAmountByRadio( $options = array() ) { |
413 | 436 | |
| 437 | + //TODO: Stop using extract. |
414 | 438 | extract( $options ); |
415 | 439 | |
416 | 440 | $showCardsOnCurrencyChange = isset( $showCardsOnCurrencyChange ) ? (boolean) $showCardsOnCurrencyChange : true; |
— | — | @@ -470,8 +494,8 @@ |
471 | 495 | |
472 | 496 | /** |
473 | 497 | * Set the hidden field array |
474 | | - * |
475 | 498 | * If you pass nothing in, we'll set the fields for you. |
| 499 | + * This function is not used by any RapidHTML forms. |
476 | 500 | * @param array $hidden_fields |
477 | 501 | */ |
478 | 502 | public function setHiddenFields( $hidden_fields = NULL ) { |
— | — | @@ -510,7 +534,7 @@ |
511 | 535 | |
512 | 536 | /** |
513 | 537 | * Gets an array of the hidden fields for the form |
514 | | - * |
| 538 | + * This function is not used by any RapidHTML forms. |
515 | 539 | * @return array |
516 | 540 | */ |
517 | 541 | public function getHiddenFields() { |
— | — | @@ -546,6 +570,14 @@ |
547 | 571 | $this->captcha_html = $html; |
548 | 572 | } |
549 | 573 | |
| 574 | + /** |
| 575 | + * generateBannerHeader |
| 576 | + * Generates a banner header based on the existance of set masthead data, |
| 577 | + * and/or a gateway header defined in LocalSettings. |
| 578 | + * This function is not used by any RapidHTML forms. |
| 579 | + * @global type $wgOut |
| 580 | + * @global type $wgRequest |
| 581 | + */ |
550 | 582 | protected function generateBannerHeader() { |
551 | 583 | global $wgOut, $wgRequest; |
552 | 584 | $g = $this->gateway; |
— | — | @@ -568,6 +600,13 @@ |
569 | 601 | } |
570 | 602 | } |
571 | 603 | |
| 604 | + /** |
| 605 | + * generateTextTemplate: Loads the text from the appropraite template. |
| 606 | + * This function is not used by any RapidHTML forms. |
| 607 | + * @global type $wgOut |
| 608 | + * @global type $wgRequest |
| 609 | + * @return string |
| 610 | + */ |
572 | 611 | protected function generateTextTemplate() { |
573 | 612 | global $wgOut, $wgRequest; |
574 | 613 | $text_template = $wgRequest->getText( 'text_template', '2010/JimmyAppealLong' ); |
— | — | @@ -582,6 +621,11 @@ |
583 | 622 | return $template; |
584 | 623 | } |
585 | 624 | |
| 625 | + /** |
| 626 | + * Builds and returns the email form field |
| 627 | + * This function is not used by any RapidHTML forms. |
| 628 | + * @return string |
| 629 | + */ |
586 | 630 | protected function getEmailField() { |
587 | 631 | // email |
588 | 632 | $form = '<tr>'; |
— | — | @@ -595,6 +639,11 @@ |
596 | 640 | return $form; |
597 | 641 | } |
598 | 642 | |
| 643 | + /** |
| 644 | + * Builds and returns the amount form field. |
| 645 | + * This function is not used by any RapidHTML forms. |
| 646 | + * @return string |
| 647 | + */ |
599 | 648 | protected function getAmountField() { |
600 | 649 | $otherChecked = false; |
601 | 650 | $amount = -1; |
— | — | @@ -621,6 +670,11 @@ |
622 | 671 | return $form; |
623 | 672 | } |
624 | 673 | |
| 674 | + /** |
| 675 | + * getCardnumberField builds and returns the credit card number field. |
| 676 | + * This function is not used by any RapidHTML forms. |
| 677 | + * @return string |
| 678 | + */ |
625 | 679 | protected function getCardnumberField() { |
626 | 680 | $card_num = ( $this->gateway->getGlobal( "Test" ) ) ? $this->getEscapedValue( 'card_num' ) : ''; |
627 | 681 | $form = ''; |
— | — | @@ -642,6 +696,11 @@ |
643 | 697 | return $form; |
644 | 698 | } |
645 | 699 | |
| 700 | + /** |
| 701 | + * Builds and returns the cvv form field |
| 702 | + * This function is not used by any RapidHTML forms. |
| 703 | + * @return string |
| 704 | + */ |
646 | 705 | protected function getCvvField() { |
647 | 706 | $cvv = ( $this->gateway->getGlobal( "Test" ) ) ? $this->getEscapedValue( 'cvv' ) : ''; |
648 | 707 | |
— | — | @@ -656,6 +715,11 @@ |
657 | 716 | return $form; |
658 | 717 | } |
659 | 718 | |
| 719 | + /** |
| 720 | + * Builds and returns the street form element. |
| 721 | + * This function is not used by any RapidHTML forms. |
| 722 | + * @return string |
| 723 | + */ |
660 | 724 | protected function getStreetField() { |
661 | 725 | $form = '<tr>'; |
662 | 726 | $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['street'] . '</span></td>'; |
— | — | @@ -668,6 +732,11 @@ |
669 | 733 | return $form; |
670 | 734 | } |
671 | 735 | |
| 736 | + /** |
| 737 | + * getCityField builds and returns the city form element. |
| 738 | + * This function is not used by any RapidHTML forms. |
| 739 | + * @return string |
| 740 | + */ |
672 | 741 | protected function getCityField() { |
673 | 742 | $form = '<tr>'; |
674 | 743 | $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['city'] . '</span></td>'; |
— | — | @@ -680,6 +749,11 @@ |
681 | 750 | return $form; |
682 | 751 | } |
683 | 752 | |
| 753 | + /** |
| 754 | + * Builds and returns the zip (postal) code form element. |
| 755 | + * This function is not used by any RapidHTML forms. |
| 756 | + * @return string |
| 757 | + */ |
684 | 758 | protected function getZipField() { |
685 | 759 | $form = '<tr>'; |
686 | 760 | $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['zip'] . '</span></td>'; |
— | — | @@ -692,6 +766,11 @@ |
693 | 767 | return $form; |
694 | 768 | } |
695 | 769 | |
| 770 | + /** |
| 771 | + * Builds and returns the name-related form controls. |
| 772 | + * This function is not used by any RapidHTML forms. |
| 773 | + * @return string |
| 774 | + */ |
696 | 775 | protected function getNameField() { |
697 | 776 | $form = '<tr>'; |
698 | 777 | $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['fname'] . '</span></td>'; |
— | — | @@ -707,6 +786,11 @@ |
708 | 787 | return $form; |
709 | 788 | } |
710 | 789 | |
| 790 | + /** |
| 791 | + * Builds and returns the comment message. |
| 792 | + * This function is not used by any RapidHTML forms. |
| 793 | + * @return string |
| 794 | + */ |
711 | 795 | protected function getCommentMessageField() { |
712 | 796 | $form = '<tr>'; |
713 | 797 | $form .= '<td colspan="2">'; |
— | — | @@ -716,6 +800,11 @@ |
717 | 801 | return $form; |
718 | 802 | } |
719 | 803 | |
| 804 | + /** |
| 805 | + * Builds and returns the comment form field. |
| 806 | + * This function is not used by any RapidHTML forms. |
| 807 | + * @return string |
| 808 | + */ |
720 | 809 | protected function getCommentField() { |
721 | 810 | $form = '<tr>'; |
722 | 811 | $form .= '<td class="label">' . Xml::label( wfMsg( 'donate_interface-comment' ), 'comment' ) . '</td>'; |
— | — | @@ -724,6 +813,11 @@ |
725 | 814 | return $form; |
726 | 815 | } |
727 | 816 | |
| 817 | + /** |
| 818 | + * Builds and returns the comment option checkbox. |
| 819 | + * This function is not used by any RapidHTML forms. |
| 820 | + * @return string |
| 821 | + */ |
728 | 822 | protected function getCommentOptionField() { |
729 | 823 | $comment_opt_value = ( $this->gateway->posted ) ? $this->getEscapedValue( 'comment-option' ) : true; |
730 | 824 | $form = '<tr>'; |
— | — | @@ -733,6 +827,11 @@ |
734 | 828 | return $form; |
735 | 829 | } |
736 | 830 | |
| 831 | + /** |
| 832 | + * Builds and returns the email-opt checkbox. |
| 833 | + * This function is not used by any RapidHTML forms. |
| 834 | + * @return string |
| 835 | + */ |
737 | 836 | protected function getEmailOptField() { |
738 | 837 | $email_opt_value = ( $this->gateway->posted ) ? $this->getEscapedValue( 'email-opt' ) : true; |
739 | 838 | $form = '<tr>'; |
— | — | @@ -747,6 +846,12 @@ |
748 | 847 | return $form; |
749 | 848 | } |
750 | 849 | |
| 850 | + /** |
| 851 | + * Builds and returns the paypal button form element. |
| 852 | + * This function is only used in TwoColumnPayPal.php. |
| 853 | + * @global type $wgScriptPath |
| 854 | + * @return string |
| 855 | + */ |
751 | 856 | protected function getPaypalButton() { |
752 | 857 | global $wgScriptPath; |
753 | 858 | $scriptPath = "$wgScriptPath/extensions/DonationInterface/gateway_forms/includes"; |
— | — | @@ -761,6 +866,11 @@ |
762 | 867 | return $form; |
763 | 868 | } |
764 | 869 | |
| 870 | + /** |
| 871 | + * Builds and returns the state dropdown form element. |
| 872 | + * This function is not used by any RapidHTML forms. |
| 873 | + * @return string |
| 874 | + */ |
765 | 875 | protected function getStateField() { |
766 | 876 | $form = '<tr>'; |
767 | 877 | $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['state'] . '</span></td>'; |
— | — | @@ -772,6 +882,12 @@ |
773 | 883 | return $form; |
774 | 884 | } |
775 | 885 | |
| 886 | + /** |
| 887 | + * Builds and returns the country form element. |
| 888 | + * This function is not used by any RapidHTML forms. |
| 889 | + * @param type $defaultCountry |
| 890 | + * @return string |
| 891 | + */ |
776 | 892 | protected function getCountryField( $defaultCountry = null ) { |
777 | 893 | $form = '<tr>'; |
778 | 894 | $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['country'] . '</span></td>'; |
— | — | @@ -783,6 +899,11 @@ |
784 | 900 | return $form; |
785 | 901 | } |
786 | 902 | |
| 903 | + /** |
| 904 | + * Builds and returns the card type dropdown. |
| 905 | + * This function is only used by TwoStepTwoColumn.php |
| 906 | + * @return string |
| 907 | + */ |
787 | 908 | protected function getCreditCardTypeField() { |
788 | 909 | $form = '<tr>'; |
789 | 910 | $form .= '<td class="label">' . Xml::label( wfMsg( 'donate_interface-donor-card' ), 'card_type' ) . '</td>'; |
— | — | @@ -791,6 +912,11 @@ |
792 | 913 | return $form; |
793 | 914 | } |
794 | 915 | |
| 916 | + /** |
| 917 | + * Builds and returns the credit card expiry form controls. |
| 918 | + * This function is not used by any RapidHTML forms. |
| 919 | + * @return string |
| 920 | + */ |
795 | 921 | protected function getExpiryField() { |
796 | 922 | $form = '<tr>'; |
797 | 923 | $form .= '<td class="label">' . Xml::label( wfMsg( 'donate_interface-donor-expiration' ), 'expiration' ) . '</td>'; |
— | — | @@ -799,16 +925,31 @@ |
800 | 926 | return $form; |
801 | 927 | } |
802 | 928 | |
| 929 | + /** |
| 930 | + * Uses resource loader to load the form validation javascript. |
| 931 | + * @global type $wgOut |
| 932 | + */ |
803 | 933 | protected function loadValidateJs() { |
804 | 934 | global $wgOut; |
805 | 935 | $wgOut->addModules( 'di.form.core.validate' ); |
806 | 936 | } |
807 | 937 | |
| 938 | + /** |
| 939 | + * Uses the resource loader to add the api client side javascript, usually |
| 940 | + * only when the form is caching. |
| 941 | + * @global type $wgOut |
| 942 | + */ |
808 | 943 | protected function loadApiJs() { |
809 | 944 | global $wgOut; |
810 | 945 | $wgOut->addModules( 'pfp.form.core.api' ); |
811 | 946 | } |
812 | 947 | |
| 948 | + /** |
| 949 | + * Loads the OWA javascript. |
| 950 | + * if OWA is enabled, this is called by the main form constructor. |
| 951 | + * @global type $wgOut |
| 952 | + * @global type $wgScriptPath |
| 953 | + */ |
813 | 954 | protected function loadOwaJs() { |
814 | 955 | global $wgOut, $wgScriptPath; |
815 | 956 | $wgOut->addHeadItem( 'owa_tracker', '<script type="text/javascript" src="https://owa.wikimedia.org/owa/modules/base/js/owa.tracker-combined-min.js"></script>' ); |
— | — | @@ -823,7 +964,7 @@ |
824 | 965 | |
825 | 966 | /** |
826 | 967 | * Generate HTML for <noscript> tags |
827 | | - * |
| 968 | + * This function is not used by any RapidHTML forms. |
828 | 969 | * For displaying when a user does not have Javascript enabled in their browser. |
829 | 970 | */ |
830 | 971 | protected function getNoScript() { |
— | — | @@ -877,7 +1018,9 @@ |
878 | 1019 | |
879 | 1020 | /** |
880 | 1021 | * Get the form id |
881 | | - * |
| 1022 | + * This function appears to be used only by the Universal Test form, and as |
| 1023 | + * such should be moved to that class and away from the class all the forms |
| 1024 | + * are eventually descended from. |
882 | 1025 | * @return string |
883 | 1026 | */ |
884 | 1027 | protected function getFormId() { |
— | — | @@ -888,7 +1031,9 @@ |
889 | 1032 | |
890 | 1033 | /** |
891 | 1034 | * Get the form name |
892 | | - * |
| 1035 | + * This function appears to be used only by the Universal Test form, and as |
| 1036 | + * such should be moved to that class and away from the class all the forms |
| 1037 | + * are eventually descended from. |
893 | 1038 | * @return string |
894 | 1039 | */ |
895 | 1040 | protected function getFormName() { |
— | — | @@ -897,28 +1042,8 @@ |
898 | 1043 | } |
899 | 1044 | |
900 | 1045 | /** |
901 | | - * Get the payment method |
902 | | - * |
903 | | - * @return string |
| 1046 | + * Create and return the Verisign logo (small size) form element. |
904 | 1047 | */ |
905 | | - protected function getPaymentMethod() { |
906 | | - |
907 | | - return $this->getEscapedValue( 'payment_method' ); |
908 | | - } |
909 | | - |
910 | | - /** |
911 | | - * Get the payment submethod |
912 | | - * |
913 | | - * @return string |
914 | | - */ |
915 | | - protected function getPaymentSubmethod() { |
916 | | - return $this->getEscapedValue( 'payment_submethod' ); |
917 | | - } |
918 | | - |
919 | | - /** |
920 | | - * Create the Verisign logo (small size) |
921 | | - * |
922 | | - */ |
923 | 1048 | protected function getSmallSecureLogo() { |
924 | 1049 | |
925 | 1050 | $form = '<table id="secureLogo" width="130" border="0" cellpadding="2" cellspacing="0" title=' . wfMsg('donate_interface-securelogo-title') . '>'; |