Index: trunk/extensions/DonationInterface/gateway_common/DonationData.php |
— | — | @@ -52,7 +52,7 @@ |
53 | 53 | */ |
54 | 54 | 'country2' => ( strlen( $wgRequest->getText( 'country2' ) ) ) ? $wgRequest->getText( 'country2' ) : $wgRequest->getText( 'country' ), |
55 | 55 | 'size' => $wgRequest->getText( 'size' ), |
56 | | - 'premium_language' => $wgRequest->getText( 'premium_language', "en" ), |
| 56 | + 'premium_language' => $wgRequest->getText( 'premium_language', null ), |
57 | 57 | 'card_num' => str_replace( ' ', '', $wgRequest->getText( 'card_num' ) ), |
58 | 58 | 'card_type' => $wgRequest->getText( 'card_type' ), |
59 | 59 | 'expiration' => $wgRequest->getText( 'mos' ) . substr( $wgRequest->getText( 'year' ), 2, 2 ), |
— | — | @@ -71,8 +71,9 @@ |
72 | 72 | 'utm_source_id' => $wgRequest->getVal( 'utm_source_id', null ), |
73 | 73 | 'utm_medium' => $wgRequest->getText( 'utm_medium' ), |
74 | 74 | 'utm_campaign' => $wgRequest->getText( 'utm_campaign' ), |
75 | | - // try to honor the user-set language (uselang), otherwise the language set in the URL (language) |
76 | | - 'language' => $wgRequest->getText( 'uselang', $wgRequest->getText( 'language' ) ), |
| 75 | + // Pull both of these here. We can logic out which one to use in the normalize bits. |
| 76 | + 'language' => $wgRequest->getText( 'language', null ), |
| 77 | + 'uselang' => $wgRequest->getText( 'uselang', null ), |
77 | 78 | 'comment-option' => $wgRequest->getText( 'comment-option' ), |
78 | 79 | 'comment' => $wgRequest->getText( 'comment' ), |
79 | 80 | 'email-opt' => $wgRequest->getText( 'email-opt' ), |
— | — | @@ -237,6 +238,11 @@ |
238 | 239 | } |
239 | 240 | } |
240 | 241 | |
| 242 | + /** |
| 243 | + * Sets a key in the normalized data array, to a new value. |
| 244 | + * @param string $key The key you want to set. |
| 245 | + * @param string $val The value you'd like to assign to the key. |
| 246 | + */ |
241 | 247 | function setVal( $key, $val ) { |
242 | 248 | $this->normalized[$key] = $val; |
243 | 249 | } |
— | — | @@ -264,6 +270,7 @@ |
265 | 271 | 'optout', |
266 | 272 | 'anonymous', |
267 | 273 | 'language', |
| 274 | + 'premium_language', |
268 | 275 | 'contribution_tracking_id', //sort of... |
269 | 276 | 'currency_code', |
270 | 277 | ); |
— | — | @@ -473,14 +480,32 @@ |
474 | 481 | * normalizeAndSanitize helper function. |
475 | 482 | * If the language has not yet been set or is not valid, pulls the language code |
476 | 483 | * from the current global language object. |
| 484 | + * Also sets the premium_language as the calculated language if it's not |
| 485 | + * already set coming in (had been defaulting to english). |
477 | 486 | */ |
478 | 487 | function setLanguage() { |
479 | 488 | global $wgLang; |
480 | | - if ( !$this->isSomething( 'language' ) |
| 489 | + $language = false; |
| 490 | + |
| 491 | + if ( $this->isSomething( 'uselang' ) ) { |
| 492 | + $language = $this->getVal( 'uselang' ); |
| 493 | + } elseif ( $this->isSomething( 'language' ) ) { |
| 494 | + $language = $this->getVal( 'language' ); |
| 495 | + } |
| 496 | + |
| 497 | + if ( $language == false |
481 | 498 | || !Language::isValidBuiltInCode( $this->normalized['language'] ) ) |
482 | 499 | { |
483 | | - $this->setVal( 'language', $wgLang->getCode() ); |
| 500 | + $language = $wgLang->getCode() ; |
484 | 501 | } |
| 502 | + |
| 503 | + $this->setVal( 'language', $language ); |
| 504 | + $this->expunge( 'uselang' ); |
| 505 | + |
| 506 | + if ( !$this->isSomething( 'premium_language' ) ){ |
| 507 | + $this->setVal( 'premium_language', $language ); |
| 508 | + } |
| 509 | + |
485 | 510 | } |
486 | 511 | |
487 | 512 | /** |