Index: trunk/extensions/DonationInterface/gateway_forms/Form.php |
— | — | @@ -21,6 +21,24 @@ |
22 | 22 | public $form_data; |
23 | 23 | |
24 | 24 | /** |
| 25 | + * The id of the form. |
| 26 | + * |
| 27 | + * This should also be the name of the form |
| 28 | + * |
| 29 | + * @var string |
| 30 | + */ |
| 31 | + public $form_id = 'payment'; |
| 32 | + |
| 33 | + /** |
| 34 | + * The name of the form. |
| 35 | + * |
| 36 | + * This should also be the id of the form |
| 37 | + * |
| 38 | + * @var string |
| 39 | + */ |
| 40 | + public $form_name = 'payment'; |
| 41 | + |
| 42 | + /** |
25 | 43 | * An array of form errors, passed from the payflow pro object |
26 | 44 | * @var array |
27 | 45 | */ |
— | — | @@ -39,6 +57,18 @@ |
40 | 58 | protected $captcha_html; |
41 | 59 | |
42 | 60 | /** |
| 61 | + * The payment method |
| 62 | + * @var string |
| 63 | + */ |
| 64 | + protected $payment_method = ''; |
| 65 | + |
| 66 | + /** |
| 67 | + * The payment submethod |
| 68 | + * @var string |
| 69 | + */ |
| 70 | + protected $payment_submethod = ''; |
| 71 | + |
| 72 | + /** |
43 | 73 | * Required method for returning the full HTML for a form. |
44 | 74 | * |
45 | 75 | * Code invoking forms will expect this method to be set. Requiring only |
— | — | @@ -82,9 +112,19 @@ |
83 | 113 | } |
84 | 114 | |
85 | 115 | $this->loadLogoLinkOverride(); |
| 116 | + |
| 117 | + // This method should be overridden in the child class |
| 118 | + $this->init(); |
86 | 119 | } |
87 | 120 | |
88 | 121 | /** |
| 122 | + * Initialize the form |
| 123 | + * |
| 124 | + */ |
| 125 | + protected function init() { |
| 126 | + } |
| 127 | + |
| 128 | + /** |
89 | 129 | * Override the link in the logo to redirec to a particular form |
90 | 130 | * rather than the main page |
91 | 131 | */ |
— | — | @@ -313,7 +353,12 @@ |
314 | 354 | * @fixme It would be great to default the currency to a locale's currency |
315 | 355 | * @return string The entire HTML select for the currency dropdown |
316 | 356 | */ |
317 | | - public function generateCurrencyDropdown() { |
| 357 | + public function generateCurrencyDropdown( $options = array() ) { |
| 358 | + |
| 359 | + extract( $options ); |
| 360 | + |
| 361 | + $showCardsOnCurrencyChange = isset( $showCardsOnCurrencyChange ) ? (boolean) $showCardsOnCurrencyChange : true; |
| 362 | + |
318 | 363 | $available_currencies = array( |
319 | 364 | 'USD' => 'USD: U.S. Dollar', |
320 | 365 | 'GBP' => 'GBP: British Pound', |
— | — | @@ -336,7 +381,7 @@ |
337 | 382 | array( |
338 | 383 | 'name' => 'currency_code', |
339 | 384 | 'id' => 'input_currency_code', |
340 | | - 'onchange' => 'showCards()' |
| 385 | + 'onchange' => $showCardsOnCurrencyChange ? 'showCards()' : '', |
341 | 386 | ) ); |
342 | 387 | $currency_menu .= $currency_opts; |
343 | 388 | $currency_menu .= Xml::closeElement( 'select' ); |
— | — | @@ -736,4 +781,84 @@ |
737 | 782 | return wfAppendQuery( $wgTitle->getLocalURL(), $query_array ); |
738 | 783 | } |
739 | 784 | |
| 785 | + /** |
| 786 | + * Get the form id |
| 787 | + * |
| 788 | + * @return string |
| 789 | + */ |
| 790 | + protected function getFormId() { |
| 791 | + |
| 792 | + return $this->form_id; |
| 793 | + } |
| 794 | + |
| 795 | + /** |
| 796 | + * Set the form id |
| 797 | + * |
| 798 | + * @param string $value The form_id value |
| 799 | + */ |
| 800 | + protected function setFormId( $value = '' ) { |
| 801 | + |
| 802 | + $this->form_id = (string) $value; |
| 803 | + } |
| 804 | + |
| 805 | + /** |
| 806 | + * Get the form name |
| 807 | + * |
| 808 | + * @return string |
| 809 | + */ |
| 810 | + protected function getFormName() { |
| 811 | + |
| 812 | + return $this->form_name; |
| 813 | + } |
| 814 | + |
| 815 | + /** |
| 816 | + * Set the form name |
| 817 | + * |
| 818 | + * @param string $value The form_name value |
| 819 | + */ |
| 820 | + protected function setFormName( $value = '' ) { |
| 821 | + |
| 822 | + $this->form_name = (string) $value; |
| 823 | + } |
| 824 | + |
| 825 | + /** |
| 826 | + * Get the payment method |
| 827 | + * |
| 828 | + * @return string |
| 829 | + */ |
| 830 | + protected function getPaymentMethod() { |
| 831 | + |
| 832 | + return $this->payment_method; |
| 833 | + } |
| 834 | + |
| 835 | + /** |
| 836 | + * Set the payment method |
| 837 | + * |
| 838 | + * @param string $value The payment method value |
| 839 | + */ |
| 840 | + protected function setPaymentMethod( $value = '' ) { |
| 841 | + |
| 842 | + $this->payment_method = (string) $value; |
| 843 | + } |
| 844 | + |
| 845 | + /** |
| 846 | + * Get the payment submethod |
| 847 | + * |
| 848 | + * @return string |
| 849 | + */ |
| 850 | + protected function getPaymentSubmethod() { |
| 851 | + |
| 852 | + return $this->payment_submethod; |
| 853 | + } |
| 854 | + |
| 855 | + /** |
| 856 | + * Set the payment submethod |
| 857 | + * |
| 858 | + * @param string $value The payment submethod value |
| 859 | + */ |
| 860 | + protected function setPaymentSubmethod( $value = '' ) { |
| 861 | + |
| 862 | + $this->payment_submethod = (string) $value; |
| 863 | + } |
| 864 | + |
740 | 865 | } |