Index: trunk/extensions/LandingCheck/LandingCheck.php |
— | — | @@ -19,6 +19,10 @@ |
20 | 20 | 'descriptionmsg' => 'landingcheck-desc', |
21 | 21 | ); |
22 | 22 | |
| 23 | +// If there are any countries for which the country page should be the fallback rather than a |
| 24 | +// language page, add its country code to this array. |
| 25 | +$priorityCountries = array(); |
| 26 | + |
23 | 27 | $dir = dirname( __FILE__ ) . '/'; |
24 | 28 | |
25 | 29 | $wgAutoloadClasses['SpecialLandingCheck'] = $dir . 'SpecialLandingCheck.php'; |
Index: trunk/extensions/LandingCheck/SpecialLandingCheck.php |
— | — | @@ -17,7 +17,7 @@ |
18 | 18 | } |
19 | 19 | |
20 | 20 | public function execute( $sub ) { |
21 | | - global $wgOut, $wgRequest; |
| 21 | + global $wgOut, $wgRequest, $priorityCountries; |
22 | 22 | |
23 | 23 | // Pull in query string parameters |
24 | 24 | $language = $wgRequest->getVal( 'language', 'en' ); |
— | — | @@ -32,16 +32,24 @@ |
33 | 33 | 'referrer' => $wgRequest->getHeader( 'referer' ) |
34 | 34 | ) ); |
35 | 35 | |
36 | | - // Build array of landing pages to check for |
37 | | - $targetTexts = array( |
38 | | - $landingPage . '/' . $language . '/' . $country, |
39 | | - $landingPage . '/' . $language |
40 | | - ); |
41 | | - // Add fallback languages |
42 | | - $code = $language; |
43 | | - while ( $code !== 'en' ) { |
44 | | - $code = Language::getFallbackFor( $code ); |
45 | | - $targetTexts[] = $landingPage . '/' . $code; |
| 36 | + if ( in_array( $country, $priorityCountries ) ) { |
| 37 | + // Build array of landing pages to check for |
| 38 | + $targetTexts = array( |
| 39 | + $landingPage . '/' . $country . '/' . $language, |
| 40 | + $landingPage . '/' . $country |
| 41 | + ); |
| 42 | + } else { |
| 43 | + // Build array of landing pages to check for |
| 44 | + $targetTexts = array( |
| 45 | + $landingPage . '/' . $language . '/' . $country, |
| 46 | + $landingPage . '/' . $language |
| 47 | + ); |
| 48 | + // Add fallback languages |
| 49 | + $code = $language; |
| 50 | + while ( $code !== 'en' ) { |
| 51 | + $code = Language::getFallbackFor( $code ); |
| 52 | + $targetTexts[] = $landingPage . '/' . $code; |
| 53 | + } |
46 | 54 | } |
47 | 55 | |
48 | 56 | // Go through the possible landing pages and redirect the user as soon as one is found to exist |