Index: trunk/extensions/DonationInterface/gateway_forms/TwoColumnLetter2.php |
— | — | @@ -71,7 +71,7 @@ |
72 | 72 | } |
73 | 73 | |
74 | 74 | protected function generateBillingFields() { |
75 | | - global $wgScriptPath, $wgRequest; |
| 75 | + global $wgScriptPath; |
76 | 76 | $scriptPath = "$wgScriptPath/extensions/DonationInterface/gateway_forms/includes"; |
77 | 77 | |
78 | 78 | $form = ''; |
— | — | @@ -134,12 +134,8 @@ |
135 | 135 | } |
136 | 136 | |
137 | 137 | // anonymous |
138 | | - $comment_opt_value = ( $wgRequest->wasPosted() ) ? $this->getEscapedValue( 'comment-option' ) : true; |
139 | | - $form .= '<tr>'; |
140 | | - $form .= '<td class="check-option" colspan="2">' . Xml::check( 'comment-option', $comment_opt_value ); |
141 | | - $form .= ' ' . Xml::label( wfMsg( 'donate_interface-anon-message' ), 'comment-option' ) . '</td>'; |
142 | | - $form .= '</tr>'; |
143 | | - |
| 138 | + $form .= $this->getCommentOptionField(); |
| 139 | + |
144 | 140 | // email agreement |
145 | 141 | $form .= $this->getEmailOptField(); |
146 | 142 | |
Index: trunk/extensions/DonationInterface/gateway_forms/TwoColumnLetter3.php |
— | — | @@ -71,7 +71,7 @@ |
72 | 72 | } |
73 | 73 | |
74 | 74 | protected function generateBillingFields() { |
75 | | - global $wgScriptPath, $wgRequest; |
| 75 | + global $wgScriptPath; |
76 | 76 | $scriptPath = "$wgScriptPath/extensions/DonationInterface/gateway_forms/includes"; |
77 | 77 | |
78 | 78 | $form = ''; |
— | — | @@ -134,11 +134,7 @@ |
135 | 135 | } |
136 | 136 | |
137 | 137 | // anonymous |
138 | | - $comment_opt_value = ( $wgRequest->wasPosted() ) ? $this->getEscapedValue( 'comment-option' ) : true; |
139 | | - $form .= '<tr>'; |
140 | | - $form .= '<td class="check-option" colspan="2">' . Xml::check( 'comment-option', $comment_opt_value ); |
141 | | - $form .= ' ' . Xml::label( wfMsg( 'donate_interface-anon-message' ), 'comment-option' ) . '</td>'; |
142 | | - $form .= '</tr>'; |
| 138 | + $form .= $this->getCommentOptionField(); |
143 | 139 | |
144 | 140 | // email agreement |
145 | 141 | $form .= $this->getEmailOptField(); |
Index: trunk/extensions/DonationInterface/gateway_forms/TwoColumnLetter4.php |
— | — | @@ -71,7 +71,7 @@ |
72 | 72 | } |
73 | 73 | |
74 | 74 | protected function generateBillingFields() { |
75 | | - global $wgScriptPath, $wgRequest; |
| 75 | + global $wgScriptPath; |
76 | 76 | $scriptPath = "$wgScriptPath/extensions/DonationInterface/gateway_forms/includes"; |
77 | 77 | |
78 | 78 | $form = ''; |
— | — | @@ -134,11 +134,7 @@ |
135 | 135 | } |
136 | 136 | |
137 | 137 | // anonymous |
138 | | - $comment_opt_value = ( $wgRequest->wasPosted() ) ? $this->getEscapedValue( 'comment-option' ) : true; |
139 | | - $form .= '<tr>'; |
140 | | - $form .= '<td class="check-option" colspan="2">' . Xml::check( 'comment-option', $comment_opt_value ); |
141 | | - $form .= ' ' . Xml::label( wfMsg( 'donate_interface-anon-message' ), 'comment-option' ) . '</td>'; |
142 | | - $form .= '</tr>'; |
| 138 | + $form .= $this->getCommentOptionField(); |
143 | 139 | |
144 | 140 | // email agreement |
145 | 141 | $form .= $this->getEmailOptField(); |
Index: trunk/extensions/DonationInterface/gateway_forms/TwoColumnLetter5.php |
— | — | @@ -73,7 +73,7 @@ |
74 | 74 | } |
75 | 75 | |
76 | 76 | protected function generateBillingFields() { |
77 | | - global $wgScriptPath, $wgRequest; |
| 77 | + global $wgScriptPath; |
78 | 78 | $scriptPath = "$wgScriptPath/extensions/DonationInterface/gateway_forms/includes"; |
79 | 79 | |
80 | 80 | $form = ''; |
— | — | @@ -115,7 +115,7 @@ |
116 | 116 | $form .= $this->getEmailField(); |
117 | 117 | |
118 | 118 | // email opt-in |
119 | | - $email_opt_value = ( $wgRequest->wasPosted() ) ? $this->getEscapedValue( 'email-opt' ) : true; |
| 119 | + $email_opt_value = ( $this->gateway->posted ) ? $this->getEscapedValue( 'email-opt' ) : true; |
120 | 120 | $form .= '<tr>'; |
121 | 121 | $form .= '<td class="label"> </td>'; |
122 | 122 | $form .= '<td class="check-option">' . Xml::check( 'email-opt', $email_opt_value ); |
— | — | @@ -126,7 +126,7 @@ |
127 | 127 | $form .= Xml::closeElement( 'label' ); |
128 | 128 | $form .= '</td>'; |
129 | 129 | $form .= '</tr>'; |
130 | | - |
| 130 | + |
131 | 131 | $form .= '<tr>'; |
132 | 132 | $form .= '<td class="label">' . wfMsg( 'donate_interface-payment-type' ) . '</td>'; |
133 | 133 | $form .= '<td>' . |
— | — | @@ -172,16 +172,6 @@ |
173 | 173 | // country |
174 | 174 | $form .= $this->getCountryField(); |
175 | 175 | |
176 | | - /* |
177 | | - $comment_opt_value = ( $wgRequest->wasPosted() ) ? $this->getEscapedValue( 'comment-option' ) : true; |
178 | | - $form .= '<tr>'; |
179 | | - $form .= '<td class="check-option" colspan="2">' . Xml::check( 'comment-option', $comment_opt_value ); |
180 | | - $form .= ' ' . Xml::label( wfMsg( 'donate_interface-anon-message' ), 'comment-option' ) . '</td>'; |
181 | | - $form .= '</tr>'; |
182 | | - |
183 | | - $form .= $this->getEmailOptField(); |
184 | | - */ |
185 | | - |
186 | 176 | return $form; |
187 | 177 | } |
188 | 178 | |
Index: trunk/extensions/DonationInterface/gateway_forms/TwoColumnLetter6.php |
— | — | @@ -73,7 +73,7 @@ |
74 | 74 | } |
75 | 75 | |
76 | 76 | protected function generateBillingFields() { |
77 | | - global $wgScriptPath, $wgRequest; |
| 77 | + global $wgScriptPath; |
78 | 78 | $scriptPath = "$wgScriptPath/extensions/DonationInterface/gateway_forms/includes"; |
79 | 79 | |
80 | 80 | $form = ''; |
— | — | @@ -109,7 +109,7 @@ |
110 | 110 | $form .= '</tr>'; |
111 | 111 | |
112 | 112 | // email opt-in |
113 | | - $email_opt_value = ( $wgRequest->wasPosted() ) ? $this->getEscapedValue( 'email-opt' ) : true; |
| 113 | + $email_opt_value = ( $this->gateway->posted ) ? $this->getEscapedValue( 'email-opt' ) : true; |
114 | 114 | $form .= '<tr>'; |
115 | 115 | $form .= '<td class="label"> </td>'; |
116 | 116 | $form .= '<td class="check-option">' . Xml::check( 'email-opt', $email_opt_value ); |
— | — | @@ -180,16 +180,6 @@ |
181 | 181 | // country |
182 | 182 | $form .= $this->getCountryField(); |
183 | 183 | |
184 | | - /* |
185 | | - $comment_opt_value = ( $wgRequest->wasPosted() ) ? $this->getEscapedValue( 'comment-option' ) : true; |
186 | | - $form .= '<tr>'; |
187 | | - $form .= '<td class="check-option" colspan="2">' . Xml::check( 'comment-option', $comment_opt_value ); |
188 | | - $form .= ' ' . Xml::label( wfMsg( 'donate_interface-anon-message' ), 'comment-option' ) . '</td>'; |
189 | | - $form .= '</tr>'; |
190 | | - |
191 | | - $form .= $this->getEmailOptField(); |
192 | | - */ |
193 | | - |
194 | 184 | return $form; |
195 | 185 | } |
196 | 186 | |
Index: trunk/extensions/DonationInterface/gateway_forms/TwoColumnLetter7.php |
— | — | @@ -135,7 +135,7 @@ |
136 | 136 | } |
137 | 137 | |
138 | 138 | public function generateFormStart() { |
139 | | - global $wgOut, $wgRequest; |
| 139 | + global $wgOut; |
140 | 140 | |
141 | 141 | $form = parent::generateBannerHeader(); |
142 | 142 | |
— | — | @@ -232,20 +232,6 @@ |
233 | 233 | '</td>'; |
234 | 234 | $form .= '</tr>'; |
235 | 235 | |
236 | | - // email opt-in |
237 | | - /* |
238 | | - $email_opt_value = ( $wgRequest->wasPosted() ) ? $this->getEscapedValue( 'email-opt' ) : true; |
239 | | - $form .= '<tr>'; |
240 | | - $form .= '<td class="label"> </td>'; |
241 | | - $form .= '<td class="check-option">' . Xml::check( 'email-opt', $email_opt_value ); |
242 | | - $form .= ' '; |
243 | | - $form .= Xml::openElement( 'label', array( 'for' => 'email-opt' ) ); |
244 | | - $form .= wfMsg( 'donate_interface-email-agreement' ); |
245 | | - $form .= Xml::closeElement( 'label' ); |
246 | | - $form .= '</td>'; |
247 | | - $form .= '</tr>'; |
248 | | - */ |
249 | | - |
250 | 236 | // Payment type |
251 | 237 | $form .= '<tr>'; |
252 | 238 | $form .= '<td class="label""><div style="padding-top:9px;">' . wfMsg( 'donate_interface-payment-type' ) . '</div></td>'; |
— | — | @@ -345,16 +331,6 @@ |
346 | 332 | '</td>'; |
347 | 333 | $form .= '</tr>'; |
348 | 334 | |
349 | | - /* |
350 | | - $comment_opt_value = ( $wgRequest->wasPosted() ) ? $this->getEscapedValue( 'comment-option' ) : true; |
351 | | - $form .= '<tr>'; |
352 | | - $form .= '<td class="check-option" colspan="2">' . Xml::check( 'comment-option', $comment_opt_value ); |
353 | | - $form .= ' ' . Xml::label( wfMsg( 'donate_interface-anon-message' ), 'comment-option' ) . '</td>'; |
354 | | - $form .= '</tr>'; |
355 | | - |
356 | | - $form .= $this->getEmailOptField(); |
357 | | - */ |
358 | | - |
359 | 335 | return $form; |
360 | 336 | } |
361 | 337 | |
Index: trunk/extensions/DonationInterface/gateway_forms/Form.php |
— | — | @@ -21,18 +21,13 @@ |
22 | 22 | * |
23 | 23 | * @var string |
24 | 24 | */ |
| 25 | + //TODO: Determine what this is, and either take measures to reference |
| 26 | + //something closer to the source data via the gateway object, or get rid of |
| 27 | + //it. If this is (as the comment suggests) also the name of the form, |
| 28 | + //my vote goes for option 2. |
25 | 29 | public $form_id = 'payment'; |
26 | 30 | |
27 | 31 | /** |
28 | | - * The name of the form. |
29 | | - * |
30 | | - * This should also be the id of the form |
31 | | - * |
32 | | - * @var string |
33 | | - */ |
34 | | - public $form_name = 'payment'; |
35 | | - |
36 | | - /** |
37 | 32 | * An array of form errors, passed from the payflow pro object |
38 | 33 | * @var array |
39 | 34 | */ |
— | — | @@ -49,18 +44,6 @@ |
50 | 45 | * @var string |
51 | 46 | */ |
52 | 47 | protected $captcha_html; |
53 | | - |
54 | | - /** |
55 | | - * The payment method |
56 | | - * @var string |
57 | | - */ |
58 | | - protected $payment_method = ''; |
59 | | - |
60 | | - /** |
61 | | - * The payment submethod |
62 | | - * @var string |
63 | | - */ |
64 | | - protected $payment_submethod = ''; |
65 | 48 | |
66 | 49 | /** |
67 | 50 | * Tells us if we're paypal only or not. |
— | — | @@ -568,12 +551,13 @@ |
569 | 552 | |
570 | 553 | // intro text |
571 | 554 | if ( $wgRequest->getText( 'masthead', false ) ) { |
572 | | - $template = $wgOut->parse( '{{' . $wgRequest->getText( 'masthead' ) . '/' . $this->getEscapedValue( 'language' ) . '}}' ); |
| 555 | + $parse = '{{' . htmlspecialchars( $wgRequest->getText( 'masthead' ), ENT_COMPAT, 'UTF-8', false ) . '/' . $this->getEscapedValue( 'language' ) . '}}'; |
| 556 | + $template = $wgOut->parse( $parse ); |
573 | 557 | } elseif ( $header ) { |
574 | 558 | $header = str_replace( '@language', $this->getEscapedValue( 'language' ), $header ); |
575 | | - $template = $wgOut->parse( $header ); |
| 559 | + $template = $wgOut->parse( htmlspecialchars( $header, ENT_COMPAT, 'UTF-8', false ) ); |
576 | 560 | } |
577 | | - |
| 561 | + |
578 | 562 | // make sure that we actually have a matching template to display so we don't display the 'redlink' |
579 | 563 | if ( strlen( $template ) && !preg_match( '/redlink\=1/', $template ) ) { |
580 | 564 | $wgOut->addHtml( $template ); |
— | — | @@ -737,8 +721,7 @@ |
738 | 722 | } |
739 | 723 | |
740 | 724 | protected function getCommentOptionField() { |
741 | | - global $wgRequest; |
742 | | - $comment_opt_value = ( $wgRequest->wasPosted() ) ? $this->getEscapedValue( 'comment-option' ) : true; |
| 725 | + $comment_opt_value = ( $this->gateway->posted ) ? $this->getEscapedValue( 'comment-option' ) : true; |
743 | 726 | $form = '<tr>'; |
744 | 727 | $form .= '<td class="check-option" colspan="2">' . Xml::check( 'comment-option', $comment_opt_value ); |
745 | 728 | $form .= ' ' . Xml::label( wfMsg( 'donate_interface-anon-message' ), 'comment-option' ) . '</td>'; |
— | — | @@ -747,8 +730,7 @@ |
748 | 731 | } |
749 | 732 | |
750 | 733 | protected function getEmailOptField() { |
751 | | - global $wgRequest; |
752 | | - $email_opt_value = ( $wgRequest->wasPosted() ) ? $this->getEscapedValue( 'email-opt' ) : true; |
| 734 | + $email_opt_value = ( $this->gateway->posted ) ? $this->getEscapedValue( 'email-opt' ) : true; |
753 | 735 | $form = '<tr>'; |
754 | 736 | $form .= '<td class="check-option" colspan="2">' . Xml::check( 'email-opt', $email_opt_value ); |
755 | 737 | $form .= ' '; |
— | — | @@ -895,81 +877,41 @@ |
896 | 878 | * @return string |
897 | 879 | */ |
898 | 880 | protected function getFormId() { |
899 | | - |
| 881 | + //TODO: Determine what this is, and either take measures to reference |
| 882 | + //something closer to the source data, move it to a child class, or get rid of it. |
900 | 883 | return $this->form_id; |
901 | 884 | } |
902 | 885 | |
903 | 886 | /** |
904 | | - * Set the form id |
905 | | - * |
906 | | - * @param string $value The form_id value |
907 | | - */ |
908 | | - protected function setFormId( $value = '' ) { |
909 | | - |
910 | | - $this->form_id = (string) $value; |
911 | | - } |
912 | | - |
913 | | - /** |
914 | 887 | * Get the form name |
915 | 888 | * |
916 | 889 | * @return string |
917 | 890 | */ |
918 | 891 | protected function getFormName() { |
919 | 892 | |
920 | | - return $this->form_name; |
| 893 | + return $this->getEscapedValue( 'form_name' ); |
921 | 894 | } |
922 | 895 | |
923 | 896 | /** |
924 | | - * Set the form name |
925 | | - * |
926 | | - * @param string $value The form_name value |
927 | | - */ |
928 | | - protected function setFormName( $value = '' ) { |
929 | | - |
930 | | - $this->form_name = (string) $value; |
931 | | - } |
932 | | - |
933 | | - /** |
934 | 897 | * Get the payment method |
935 | 898 | * |
936 | 899 | * @return string |
937 | 900 | */ |
938 | 901 | protected function getPaymentMethod() { |
939 | 902 | |
940 | | - return $this->payment_method; |
| 903 | + return $this->getEscapedValue( 'payment_method' ); |
941 | 904 | } |
942 | 905 | |
943 | 906 | /** |
944 | | - * Set the payment method |
945 | | - * |
946 | | - * @param string $value The payment method value |
947 | | - */ |
948 | | - protected function setPaymentMethod( $value = '' ) { |
949 | | - |
950 | | - $this->payment_method = (string) $value; |
951 | | - } |
952 | | - |
953 | | - /** |
954 | 907 | * Get the payment submethod |
955 | 908 | * |
956 | 909 | * @return string |
957 | 910 | */ |
958 | 911 | protected function getPaymentSubmethod() { |
959 | | - |
960 | | - return $this->payment_submethod; |
| 912 | + return $this->getEscapedValue( 'payment_submethod' ); |
961 | 913 | } |
962 | 914 | |
963 | 915 | /** |
964 | | - * Set the payment submethod |
965 | | - * |
966 | | - * @param string $value The payment submethod value |
967 | | - */ |
968 | | - protected function setPaymentSubmethod( $value = '' ) { |
969 | | - |
970 | | - $this->payment_submethod = (string) $value; |
971 | | - } |
972 | | - |
973 | | - /** |
974 | 916 | * Create the Verisign logo (small size) |
975 | 917 | * |
976 | 918 | */ |
Index: trunk/extensions/DonationInterface/gateway_forms/RapidHtml.php |
— | — | @@ -96,6 +96,7 @@ |
97 | 97 | |
98 | 98 | $this->loadValidateJs(); |
99 | 99 | |
| 100 | + //Not sure if we should be using $wgRequest here. Depends if we want the normalized one or not. |
100 | 101 | $country = $wgRequest->getText( 'country', '' ); |
101 | 102 | // Get error passed via query string |
102 | 103 | $error = $wgRequest->getText( 'error' ); |
— | — | @@ -406,6 +407,8 @@ |
407 | 408 | * Load API js if this form needs to support cacheing |
408 | 409 | */ |
409 | 410 | public function handle_cacheability() { |
| 411 | + //We may change this from checking one thing in $wgRequest, to a |
| 412 | + //reference to $this->gateway->isCaching(). Little more robust. |
410 | 413 | global $wgRequest; |
411 | 414 | if ( $wgRequest->getText( '_cache_', false )) { |
412 | 415 | $this->loadApiJs(); |
Index: trunk/extensions/DonationInterface/gateway_forms/OneStepTwoColumn.php |
— | — | @@ -192,24 +192,6 @@ |
193 | 193 | return $form; |
194 | 194 | } |
195 | 195 | |
196 | | - protected function generateBannerHeader() { |
197 | | - global $wgOut, $wgRequest; |
198 | | - $template = ''; |
199 | | - |
200 | | - // intro text |
201 | | - if ( $wgRequest->getText( 'masthead', false ) ) { |
202 | | - $template = $wgOut->parse( '{{' . $wgRequest->getText( 'masthead' ) . '/' . $this->getEscapedValue( 'language' ) . '}}' ); |
203 | | - } elseif ( $this->gateway->getGlobal( "Header" ) ) { |
204 | | - $header = str_replace( '@language', $this->getEscapedValue( 'language' ), $this->gateway->getGlobal( "Header" ) ); |
205 | | - $template = $wgOut->parse( $header ); |
206 | | - } |
207 | | - |
208 | | - // make sure that we actually have a matching template to display so we don't display the 'redlink' |
209 | | - if ( strlen( $template ) && !preg_match( '/redlink\=1/', $template ) ) { |
210 | | - $wgOut->addHtml( $template ); |
211 | | - } |
212 | | - } |
213 | | - |
214 | 196 | protected function generatePersonalContainer() { |
215 | 197 | global $wgScriptPath; |
216 | 198 | $form = ''; |
Index: trunk/extensions/DonationInterface/globalcollect_gateway/forms/TwoStepAmount.php |
— | — | @@ -73,9 +73,6 @@ |
74 | 74 | */ |
75 | 75 | protected function init() { |
76 | 76 | |
77 | | - $this->setPaymentMethod( $this->getEscapedValue( 'payment_method' ) ); |
78 | | - $this->setPaymentSubmethod( $this->getEscapedValue( 'payment_submethod' ) ); |
79 | | - |
80 | 77 | // Should process be deprecated? |
81 | 78 | $this->getEscapedValue( 'process' ) = 'other'; |
82 | 79 | |
Index: trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php |
— | — | @@ -168,11 +168,16 @@ |
169 | 169 | protected $xmlDoc; |
170 | 170 | protected $dataObj; |
171 | 171 | protected $transaction_results; |
172 | | - protected $form_class; |
173 | 172 | protected $validation_errors; |
174 | 173 | protected $current_transaction; |
175 | 174 | protected $action; |
176 | 175 | public $debugarray; |
| 176 | + /** |
| 177 | + * A boolean that will tell us if we've posted to ourselves. A little more telling than |
| 178 | + * $wgRequest->wasPosted(), as something else could have posted to us. |
| 179 | + * @var boolean |
| 180 | + */ |
| 181 | + public $posted = false; |
177 | 182 | protected $batch = false; |
178 | 183 | |
179 | 184 | //ALL OF THESE need to be redefined in the children. Much voodoo depends on the accuracy of these constants. |
— | — | @@ -224,6 +229,7 @@ |
225 | 230 | $this->unstaged_data = $this->dataObj->getDataEscaped(); |
226 | 231 | $this->staged_data = $this->unstaged_data; |
227 | 232 | |
| 233 | + //If we ever put numAttempt in the session, we'll probably want to re-examine which form value we want to use here. |
228 | 234 | $this->posted = ( $this->dataObj->wasPosted() && ( !is_null( $wgRequest->getVal( 'numAttempt', null ) ) ) ); |
229 | 235 | |
230 | 236 | $this->setPostDefaults( $postDefaults ); |
— | — | @@ -1876,14 +1882,10 @@ |
1877 | 1883 | } |
1878 | 1884 | } |
1879 | 1885 | |
1880 | | - public function setFormClass( $formClassName ) { |
1881 | | - //I'm adding this because Captcha needs it, and we're gonna fire the hook inside. Nothing else really needs it as far as I know. |
1882 | | - $this->form_class = $formClassName; |
1883 | | - } |
1884 | | - |
1885 | 1886 | public function getFormClass() { |
1886 | | - if ( isset( $this->form_class ) && class_exists( $this->form_class ) ) { |
1887 | | - return $this->form_class; |
| 1887 | + $form_class = $this->getData_Unstaged_Escaped( 'form_class' ); |
| 1888 | + if ( ( $form_class ) && class_exists( $form_class ) ) { |
| 1889 | + return $form_class; |
1888 | 1890 | } else { |
1889 | 1891 | return false; |
1890 | 1892 | } |
Index: trunk/extensions/DonationInterface/gateway_common/DonationData.php |
— | — | @@ -330,11 +330,37 @@ |
331 | 331 | $this->setCountry(); |
332 | 332 | $this->handleContributionTrackingID(); |
333 | 333 | $this->setCurrencyCode(); |
| 334 | + $this->setFormClass(); |
334 | 335 | } |
335 | 336 | } |
336 | 337 | |
337 | 338 | /** |
338 | 339 | * normalize helper function |
| 340 | + * Sets the form class we will be using. |
| 341 | + */ |
| 342 | + function setFormClass(){ |
| 343 | + //don't actually try to load the forms here... but do determine if what we've got in there will load or not. |
| 344 | + //Elsewise, set it to the default. |
| 345 | + |
| 346 | + if ( $this->isSomething( 'form_name' ) ){ //we're apparently going to try to load a form class. Note: That might not always be true. |
| 347 | + $class_name = "Gateway_Form_" . $this->getVal( 'form_name' ); |
| 348 | + if ( !class_exists( $class_name ) ) { |
| 349 | + //try the default |
| 350 | + $class_name_orig = $class_name; |
| 351 | + $class_name = "Gateway_Form_" . $this->getGatewayGlobal( 'DefaultForm' ); |
| 352 | + if ( class_exists( $class_name ) ) { |
| 353 | + $this->setVal( 'form_name', $this->getGatewayGlobal( 'DefaultForm' ) ); |
| 354 | + } else { |
| 355 | + throw new MWException( 'Could not find form ' . $class_name_orig . ', nor default form ' . $class_name ); |
| 356 | + } |
| 357 | + } |
| 358 | + |
| 359 | + $this->setVal( 'form_class', $class_name ); |
| 360 | + } |
| 361 | + } |
| 362 | + |
| 363 | + /** |
| 364 | + * normalize helper function |
339 | 365 | * Setting the country correctly. |
340 | 366 | */ |
341 | 367 | function setCountry() { |
Index: trunk/extensions/DonationInterface/gateway_common/GatewayForm.php |
— | — | @@ -23,14 +23,6 @@ |
24 | 24 | class GatewayForm extends UnlistedSpecialPage { |
25 | 25 | |
26 | 26 | /** |
27 | | - * A container for the form class |
28 | | - * |
29 | | - * Used to loard the form object to display the CC form |
30 | | - * @var object |
31 | | - */ |
32 | | - public $form_class; |
33 | | - |
34 | | - /** |
35 | 27 | * An array of form errors |
36 | 28 | * @var array $errors |
37 | 29 | */ |
— | — | @@ -57,7 +49,6 @@ |
58 | 50 | $me = get_called_class(); |
59 | 51 | parent::__construct( $me ); |
60 | 52 | $this->errors = $this->getPossibleErrors(); |
61 | | - $this->setFormClass(); |
62 | 53 | } |
63 | 54 | |
64 | 55 | /** |
— | — | @@ -314,63 +305,29 @@ |
315 | 306 | global $wgOut; |
316 | 307 | |
317 | 308 | $form_class = $this->getFormClass(); |
318 | | - $form_obj = new $form_class( $this->adapter, $error ); |
319 | | - $form = $form_obj->getForm(); |
320 | | - $wgOut->addHTML( $form ); |
321 | | - } |
322 | | - |
323 | | - /** |
324 | | - * Set the form class to use to generate the CC form |
325 | | - * |
326 | | - * @param string $class_name The class name of the form to use |
327 | | - */ |
328 | | - public function setFormClass( $class_name = NULL ) { |
329 | | - if ( !$class_name ) { |
330 | | - //TODO: This is the sort of thing we really ought to be handled in |
331 | | - //DonationData instead of all the way out here. |
332 | | - $defaultForm = $this->adapter->getGlobal( 'DefaultForm' ); |
333 | | - $form_class = $this->adapter->getData_Unstaged_Escaped( 'form_name' ); |
334 | | - if ( is_null( $form_class ) ){ |
335 | | - $form_class = $defaultForm; |
336 | | - } |
337 | | - |
338 | | - // make sure our form class exists before going on, if not try loading default form class |
339 | | - $class_name = "Gateway_Form_" . $form_class; |
340 | | - if ( !class_exists( $class_name ) ) { |
341 | | - $class_name_orig = $class_name; |
342 | | - $class_name = "Gateway_Form_" . $defaultForm; |
343 | | - if ( !class_exists( $class_name ) ) { |
344 | | - throw new MWException( 'Could not load form ' . $class_name_orig . ' nor default form ' . $class_name ); |
345 | | - } |
346 | | - } |
| 309 | + if ( $form_class && class_exists( $form_class ) ){ |
| 310 | + $form_obj = new $form_class( $this->adapter, $error ); |
| 311 | + $form = $form_obj->getForm(); |
| 312 | + $wgOut->addHTML( $form ); |
| 313 | + } else { |
| 314 | + throw new MWException( 'No valid form to load.' ); |
347 | 315 | } |
348 | | - $this->form_class = $class_name; |
349 | | - |
350 | | - //...this is just dumb now. |
351 | | - //TODO: Check who's using this get/set combo, and maybe nuke it all. |
352 | | - $this->adapter->setFormClass( $class_name ); |
353 | 316 | } |
354 | 317 | |
355 | 318 | /** |
356 | 319 | * Get the currently set form class |
357 | | - * |
358 | | - * Will set the form class if the form class not already set |
359 | | - * Using logic in setFormClass() |
360 | | - * @return string |
| 320 | + * @return mixed string containing the valid and enabled form class, otherwise false. |
361 | 321 | */ |
362 | 322 | public function getFormClass() { |
363 | | - if ( !isset( $this->form_class ) ) { |
364 | | - $this->setFormClass(); |
365 | | - } |
366 | | - return $this->form_class; |
| 323 | + return $this->adapter->getFormClass(); |
367 | 324 | } |
368 | 325 | |
369 | 326 | /** |
370 | | - * Get the currently set form class |
| 327 | + * displayResultsForDebug |
371 | 328 | * |
372 | | - * Will set the form class if the form class not already set |
373 | | - * Using logic in setFormClass() |
374 | | - * @return string |
| 329 | + * Displays useful information for debugging purposes. |
| 330 | + * Enable with $wgDonationInterfaceDisplayDebug, or the adapter equivalent. |
| 331 | + * @return null |
375 | 332 | */ |
376 | 333 | protected function displayResultsForDebug( $results = array() ) { |
377 | 334 | global $wgOut; |