Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoColumnLetter2.php |
— | — | @@ -82,7 +82,7 @@ |
83 | 83 | } |
84 | 84 | |
85 | 85 | protected function generateBillingFields() { |
86 | | - global $wgScriptPath, $wgPayflowProGatewayPaypalURL, $wgRequest; |
| 86 | + global $wgScriptPath, $wgRequest; |
87 | 87 | $scriptPath = "$wgScriptPath/extensions/DonationInterface/payflowpro_gateway/includes"; |
88 | 88 | |
89 | 89 | $form = ''; |
— | — | @@ -107,7 +107,7 @@ |
108 | 108 | if ( !$this->paypal ) { |
109 | 109 | // PayPal button |
110 | 110 | // make sure we have a paypal url set to redirect the user to before displaying the button |
111 | | - if ( strlen( $wgPayflowProGatewayPaypalURL ) ) { |
| 111 | + if ( strlen( $this->gateway->getGlobal( "PaypalURL" ) ) ) { |
112 | 112 | $form .= '<tr>'; |
113 | 113 | $form .= '<td class="label"></td>'; |
114 | 114 | $form .= '<td>'; |
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoColumnLetter3.php |
— | — | @@ -82,7 +82,7 @@ |
83 | 83 | } |
84 | 84 | |
85 | 85 | protected function generateBillingFields() { |
86 | | - global $wgScriptPath, $wgPayflowProGatewayPaypalURL, $wgRequest; |
| 86 | + global $wgScriptPath, $wgRequest; |
87 | 87 | $scriptPath = "$wgScriptPath/extensions/DonationInterface/payflowpro_gateway/includes"; |
88 | 88 | |
89 | 89 | $form = ''; |
— | — | @@ -107,7 +107,7 @@ |
108 | 108 | if ( !$this->paypal ) { |
109 | 109 | // PayPal button |
110 | 110 | // make sure we have a paypal url set to redirect the user to before displaying the button |
111 | | - if ( strlen( $wgPayflowProGatewayPaypalURL ) ) { |
| 111 | + if ( strlen( $this->gateway->getGlobal( "PaypalURL" ) ) ) { |
112 | 112 | $form .= '<tr>'; |
113 | 113 | $form .= '<td class="label"></td>'; |
114 | 114 | $form .= '<td>'; |
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoColumnLetter4.php |
— | — | @@ -82,7 +82,7 @@ |
83 | 83 | } |
84 | 84 | |
85 | 85 | protected function generateBillingFields() { |
86 | | - global $wgScriptPath, $wgPayflowProGatewayPaypalURL, $wgRequest; |
| 86 | + global $wgScriptPath, $wgRequest; |
87 | 87 | $scriptPath = "$wgScriptPath/extensions/DonationInterface/payflowpro_gateway/includes"; |
88 | 88 | |
89 | 89 | $form = ''; |
— | — | @@ -107,7 +107,7 @@ |
108 | 108 | if ( !$this->paypal ) { |
109 | 109 | // PayPal button |
110 | 110 | // make sure we have a paypal url set to redirect the user to before displaying the button |
111 | | - if ( strlen( $wgPayflowProGatewayPaypalURL ) ) { |
| 111 | + if ( strlen( $this->gateway->getGlobal( "PaypalURL" ) ) ) { |
112 | 112 | $form .= '<tr>'; |
113 | 113 | $form .= '<td class="label"></td>'; |
114 | 114 | $form .= '<td>'; |
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoColumnLetter5.php |
— | — | @@ -79,7 +79,7 @@ |
80 | 80 | } |
81 | 81 | |
82 | 82 | protected function generateBillingFields() { |
83 | | - global $wgScriptPath, $wgPayflowProGatewayPaypalURL, $wgRequest; |
| 83 | + global $wgScriptPath, $wgRequest; |
84 | 84 | $scriptPath = "$wgScriptPath/extensions/DonationInterface/payflowpro_gateway/includes"; |
85 | 85 | |
86 | 86 | $form = ''; |
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoColumnLetter6.php |
— | — | @@ -79,7 +79,7 @@ |
80 | 80 | } |
81 | 81 | |
82 | 82 | protected function generateBillingFields() { |
83 | | - global $wgScriptPath, $wgPayflowProGatewayPaypalURL, $wgRequest; |
| 83 | + global $wgScriptPath, $wgRequest; |
84 | 84 | $scriptPath = "$wgScriptPath/extensions/DonationInterface/payflowpro_gateway/includes"; |
85 | 85 | |
86 | 86 | $form = ''; |
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoColumnLetter7.php |
— | — | @@ -192,7 +192,7 @@ |
193 | 193 | } |
194 | 194 | |
195 | 195 | protected function generateBillingFields() { |
196 | | - global $wgScriptPath, $wgPayflowProGatewayPaypalURL, $wgRequest; |
| 196 | + global $wgScriptPath, $wgRequest; |
197 | 197 | $scriptPath = "$wgScriptPath/extensions/DonationInterface/payflowpro_gateway/includes"; |
198 | 198 | |
199 | 199 | $form = ''; |
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoColumnPayPal.php |
— | — | @@ -58,7 +58,6 @@ |
59 | 59 | } |
60 | 60 | |
61 | 61 | protected function generatePersonalFields() { |
62 | | - global $wgPayflowProGatewayPaypalURL; |
63 | 62 | $form = ''; |
64 | 63 | |
65 | 64 | // name |
— | — | @@ -83,7 +82,7 @@ |
84 | 83 | $form .= $this->getAmountField(); |
85 | 84 | |
86 | 85 | // PayPal button |
87 | | - if ( strlen( $wgPayflowProGatewayPaypalURL ) ) { |
| 86 | + if ( strlen( $this->gateway->getGlobal( "PaypalURL" ) ) ) { |
88 | 87 | $form .= $this->getPaypalButton(); |
89 | 88 | } |
90 | 89 | |
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/Form.php |
— | — | @@ -50,12 +50,12 @@ |
51 | 51 | abstract function getForm(); |
52 | 52 | |
53 | 53 | public function __construct( &$data, &$error, &$gateway ) { |
54 | | - global $wgDonationInterfaceTest, $wgOut; |
| 54 | + global $wgOut; |
55 | 55 | |
56 | | - $this->test = $wgDonationInterfaceTest; |
| 56 | + $this->gateway = & $gateway; |
| 57 | + $this->test = $this->gateway->getGlobal( "Test" ); |
57 | 58 | $this->form_data = & $data; |
58 | 59 | $this->form_errors = & $error; |
59 | | - $this->gateway = & $gateway; |
60 | 60 | |
61 | 61 | /** |
62 | 62 | * add form-specific css - the path can be set in child classes |
— | — | @@ -456,8 +456,7 @@ |
457 | 457 | } |
458 | 458 | |
459 | 459 | protected function getCardnumberField() { |
460 | | - global $wgDonationInterfaceTest; |
461 | | - $card_num = ( $wgDonationInterfaceTest ) ? $this->form_data['card_num'] : ''; |
| 460 | + $card_num = ( $this->gateway->getGlobal( "Test" ) ) ? $this->form_data['card_num'] : ''; |
462 | 461 | $form = ''; |
463 | 462 | if ( $this->form_errors['card_num'] ) { |
464 | 463 | $form .= '<tr>'; |
— | — | @@ -478,8 +477,7 @@ |
479 | 478 | } |
480 | 479 | |
481 | 480 | protected function getCvvField() { |
482 | | - global $wgDonationInterfaceTest; |
483 | | - $cvv = ( $wgDonationInterfaceTest ) ? $this->form_data['cvv'] : ''; |
| 481 | + $cvv = ( $this->gateway->getGlobal( "Test" ) ) ? $this->form_data['cvv'] : ''; |
484 | 482 | |
485 | 483 | $form = '<tr>'; |
486 | 484 | $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['cvv'] . '</span></td>'; |
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoColumnLetter.php |
— | — | @@ -82,7 +82,7 @@ |
83 | 83 | } |
84 | 84 | |
85 | 85 | protected function generateBillingFields() { |
86 | | - global $wgScriptPath, $wgPayflowProGatewayPaypalURL; |
| 86 | + global $wgScriptPath; |
87 | 87 | $scriptPath = "$wgScriptPath/extensions/DonationInterface/payflowpro_gateway/includes"; |
88 | 88 | |
89 | 89 | $form = ''; |
— | — | @@ -111,7 +111,7 @@ |
112 | 112 | if ( !$this->paypal ) { |
113 | 113 | // PayPal button |
114 | 114 | // make sure we have a paypal url set to redirect the user to before displaying the button |
115 | | - if ( strlen( $wgPayflowProGatewayPaypalURL ) ) { |
| 115 | + if ( strlen( $this->gateway->getGlobal( "PaypalURL" ) ) ) { |
116 | 116 | $form .= '<tr>'; |
117 | 117 | $form .= '<td class="label"></td>'; |
118 | 118 | $form .= '<td class="paypal-button">'; |
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnLetter3.php |
— | — | @@ -193,7 +193,7 @@ |
194 | 194 | } |
195 | 195 | |
196 | 196 | protected function generateBillingFields() { |
197 | | - global $wgScriptPath, $wgDonationInterfaceTest; |
| 197 | + global $wgScriptPath; |
198 | 198 | |
199 | 199 | $form = ''; |
200 | 200 | |
— | — | @@ -238,7 +238,7 @@ |
239 | 239 | $form .= '</tr>'; |
240 | 240 | |
241 | 241 | // card number |
242 | | - $card_num = ( $wgDonationInterfaceTest ) ? $this->form_data[ 'card_num' ] : ''; |
| 242 | + $card_num = ( $this->gateway->getGlobal( "Test" ) ) ? $this->form_data[ 'card_num' ] : ''; |
243 | 243 | $form .= ''; |
244 | 244 | if ( $this->form_errors['card_num'] ) { |
245 | 245 | $form .= '<tr>'; |
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/RapidHtml.php |
— | — | @@ -229,6 +229,7 @@ |
230 | 230 | * @param string $file_name |
231 | 231 | */ |
232 | 232 | public function set_html_file_path( $file_name ) { |
| 233 | + //This ONE TIME, this is okay, because we actually want to compare to the default HTML form dir as well. |
233 | 234 | global $wgDonationInterfaceHtmlFormDir; |
234 | 235 | |
235 | 236 | $g = $this->gateway; |
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnPremiumUS.php |
— | — | @@ -174,7 +174,7 @@ |
175 | 175 | } |
176 | 176 | |
177 | 177 | protected function generateBillingFields() { |
178 | | - global $wgScriptPath, $wgDonationInterfaceTest; |
| 178 | + global $wgScriptPath; |
179 | 179 | |
180 | 180 | $form = ''; |
181 | 181 | |
— | — | @@ -216,7 +216,7 @@ |
217 | 217 | $form .= '</tr>'; |
218 | 218 | |
219 | 219 | // card number |
220 | | - $card_num = ( $wgDonationInterfaceTest ) ? $this->form_data[ 'card_num' ] : ''; |
| 220 | + $card_num = ( $this->gateway->getGlobal( "Test" ) ) ? $this->form_data[ 'card_num' ] : ''; |
221 | 221 | $form .= ''; |
222 | 222 | if ( $this->form_errors['card_num'] ) { |
223 | 223 | $form .= '<tr>'; |
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/OneStepTwoColumn.php |
— | — | @@ -192,14 +192,14 @@ |
193 | 193 | } |
194 | 194 | |
195 | 195 | protected function generateBannerHeader() { |
196 | | - global $wgPayflowProGatewayHeader, $wgOut, $wgRequest; |
| 196 | + global $wgOut, $wgRequest; |
197 | 197 | $template = ''; |
198 | 198 | |
199 | 199 | // intro text |
200 | 200 | if ( $wgRequest->getText( 'masthead', false ) ) { |
201 | 201 | $template = $wgOut->parse( '{{' . $wgRequest->getText( 'masthead' ) . '/' . $this->form_data[ 'language' ] . '}}' ); |
202 | | - } elseif ( $wgPayflowProGatewayHeader ) { |
203 | | - $header = str_replace( '@language', $this->form_data[ 'language' ], $wgPayflowProGatewayHeader ); |
| 202 | + } elseif ( $this->gateway->getGlobal( "Header" ) ) { |
| 203 | + $header = str_replace( '@language', $this->form_data[ 'language' ], $this->gateway->getGlobal( "Header" ) ); |
204 | 204 | $template = $wgOut->parse( $header ); |
205 | 205 | } |
206 | 206 | |
Index: branches/fundraising/extensions/DonationInterface/gateway_common/gateway.adapter.php |
— | — | @@ -109,17 +109,13 @@ |
110 | 110 | const GLOBAL_PREFIX = 'wgDonationGateway'; //...for example. |
111 | 111 | |
112 | 112 | public function __construct() { |
113 | | - global $wgDonationInterfaceTest; //this is so the forms can see it. |
114 | | - //TODO: Alter the forms so they don't need the global? |
115 | 113 | if ( !self::getGlobal( 'Test' ) ) { |
116 | 114 | $this->url = self::getGlobal( 'URL' ); |
117 | | - $wgDonationInterfaceTest = false; |
118 | 115 | } else { |
119 | 116 | $this->url = self::getGlobal( 'TestingURL' ); |
120 | | - $wgDonationInterfaceTest = true; |
121 | 117 | } |
122 | 118 | |
123 | | - $this->dataObj = new DonationData( get_called_class(), $wgDonationInterfaceTest ); |
| 119 | + $this->dataObj = new DonationData( get_called_class(), self::getGlobal( 'Test' ) ); |
124 | 120 | |
125 | 121 | $this->postdata = $this->dataObj->getData(); |
126 | 122 | //TODO: Fix this a bit. |
— | — | @@ -196,19 +192,42 @@ |
197 | 193 | return $this->dataObj->isCache(); |
198 | 194 | } |
199 | 195 | |
| 196 | + /** |
| 197 | + * This function is important. |
| 198 | + * All the globals in Donation Interface should be accessed in this manner |
| 199 | + * if they are meant to have a default value, but can be overridden by any |
| 200 | + * of the gateways. It will check to see if a gateway-specific global |
| 201 | + * exists, and if one is not set, it will pull the default from the |
| 202 | + * wgDonationInterface definitions. Through this function, it is no longer |
| 203 | + * necessary to define gateway-specific globals in LocalSettings unless you |
| 204 | + * wish to override the default value for all gateways. |
| 205 | + * @staticvar array $gotten A cache of all the globals we've already... |
| 206 | + * gotten. |
| 207 | + * @param type $varname The global value we're looking for. It will first |
| 208 | + * look for a global named for the instantiated gateway's GLOBAL_PREFIX, |
| 209 | + * plus the $varname value. If that doesn't come up with anything that has |
| 210 | + * been set, it will use the default value for all of donation interface, |
| 211 | + * stored in $wgDonationInterface . $varname. |
| 212 | + * @return mixed The configured value for that gateway if it exists. If not, |
| 213 | + * the configured value for Donation Interface if it exists or not. |
| 214 | + */ |
200 | 215 | static function getGlobal( $varname ) { |
201 | 216 | static $gotten = array( ); //cache. |
202 | | - $globalname = self::getGlobalPrefix() . $varname; |
203 | | - if ( !array_key_exists( $globalname, $gotten ) ) { |
| 217 | + if ( !array_key_exists( $varname, $gotten ) ) { |
| 218 | + $globalname = self::getGlobalPrefix() . $varname; |
204 | 219 | global $$globalname; |
205 | | - $gotten[$globalname] = $$globalname; |
| 220 | + if ( !isset( $$globalname )) { |
| 221 | + $globalname = "wgDonationInterface" . $varname; |
| 222 | + global $$globalname; //set or not. This is fine. |
| 223 | + } |
| 224 | + $gotten[$varname] = $$globalname; |
206 | 225 | } |
207 | | - return $gotten[$globalname]; |
| 226 | + return $gotten[$varname]; |
208 | 227 | } |
209 | 228 | |
210 | 229 | function getValue( $gateway_field_name, $token = false ) { |
211 | 230 | if ( empty( $this->transactions ) ) { |
212 | | - //TODO: These dies should all just throw fatal errors instead. |
| 231 | + //TODO: These dies should all throw exceptions or something less completely fatal. |
213 | 232 | die( 'Transactions structure is empty! Aborting.' ); |
214 | 233 | } |
215 | 234 | //How do we determine the value of a field asked for in a particular transaction? |
— | — | @@ -416,8 +435,7 @@ |
417 | 436 | } |
418 | 437 | |
419 | 438 | if ( is_array( $statuses ) ) { //only then will we consider doing this again. |
420 | | - global $wgDonationInterfaceRetrySeconds; //TODO: Deal with this global in the new usual way, once the DI install mess gets cleaned up |
421 | | - if ( $this->getStopwatch( __FUNCTION__ ) < $wgDonationInterfaceRetrySeconds ) { |
| 439 | + if ( $this->getStopwatch( __FUNCTION__ ) < self::getGlobal( "RetrySeconds" ) ) { |
422 | 440 | if ( $txn_ok === false ) { |
423 | 441 | $stopflag = false; |
424 | 442 | } else { |
— | — | @@ -880,8 +898,6 @@ |
881 | 899 | } |
882 | 900 | |
883 | 901 | function getPaypalRedirectURL() { |
884 | | - global $wgDonationInterfacePaypalURL; |
885 | | - |
886 | 902 | $utm_source = $this->getData( 'utm_source' ); |
887 | 903 | |
888 | 904 | // update the utm source to set the payment instrument to pp rather than cc |
— | — | @@ -899,7 +915,7 @@ |
900 | 916 | //update contribution tracking |
901 | 917 | $this->dataObj->updateContributionTracking( true ); |
902 | 918 | |
903 | | - $ret = $wgDonationInterfacePaypalURL . "/" . $this->postdata['language'] . "?gateway=paypal&" . http_build_query( $this->postdata ); |
| 919 | + $ret = self::getGlobal( "PaypalURL" ) . "/" . $this->postdata['language'] . "?gateway=paypal&" . http_build_query( $this->postdata ); |
904 | 920 | self::log( $ret ); |
905 | 921 | return $ret; |
906 | 922 | } |
Index: branches/fundraising/extensions/DonationInterface/gateway_common/GatewayForm.php |
— | — | @@ -334,8 +334,8 @@ |
335 | 335 | } |
336 | 336 | |
337 | 337 | function displayResultsForDebug( $results ) { |
338 | | - global $wgOut, $wgDonationInterfaceDisplayDebug; |
339 | | - if ( $wgDonationInterfaceDisplayDebug !== true ){ |
| 338 | + global $wgOut; |
| 339 | + if ( $this->adapter->getGlobal( 'DisplayDebug' ) !== true ){ |
340 | 340 | return; |
341 | 341 | } |
342 | 342 | $wgOut->addHTML( $results['message'] ); |
— | — | @@ -496,10 +496,10 @@ |
497 | 497 | * This would make this a lot less hack-ish |
498 | 498 | */ |
499 | 499 | public function paypalRedirect() { |
500 | | - global $wgOut, $wgDonationInterfacePaypalURL; |
| 500 | + global $wgOut; |
501 | 501 | |
502 | 502 | // if we don't have a URL enabled throw a graceful error to the user |
503 | | - if ( !strlen( $wgDonationInterfacePaypalURL ) ) { |
| 503 | + if ( !strlen( $this->adapter->getGlobal( 'PaypalURL' ) ) ) { |
504 | 504 | $gateway_identifier = $this->adapter->getIdentifier(); |
505 | 505 | $this->errors['general']['nopaypal'] = wfMsg( $gateway_identifier . '_gateway-error-msg-nopaypal' ); |
506 | 506 | return; |