r76156 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76155‎ | r76156 | r76157 >
Date:22:42, 5 November 2010
Author:kaldari
Status:deferred
Tags:
Comment:
adding support for chapter overriding
Modified paths:
  • /trunk/extensions/LandingCheck/LandingCheck.php (modified) (history)
  • /trunk/extensions/LandingCheck/SpecialLandingCheck.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LandingCheck/LandingCheck.php
@@ -19,6 +19,10 @@
2020 'descriptionmsg' => 'landingcheck-desc',
2121 );
2222
 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+
2327 $dir = dirname( __FILE__ ) . '/';
2428
2529 $wgAutoloadClasses['SpecialLandingCheck'] = $dir . 'SpecialLandingCheck.php';
Index: trunk/extensions/LandingCheck/SpecialLandingCheck.php
@@ -17,7 +17,7 @@
1818 }
1919
2020 public function execute( $sub ) {
21 - global $wgOut, $wgRequest;
 21+ global $wgOut, $wgRequest, $priorityCountries;
2222
2323 // Pull in query string parameters
2424 $language = $wgRequest->getVal( 'language', 'en' );
@@ -32,16 +32,24 @@
3333 'referrer' => $wgRequest->getHeader( 'referer' )
3434 ) );
3535
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+ }
4654 }
4755
4856 // Go through the possible landing pages and redirect the user as soon as one is found to exist

Follow-up revisions

RevisionCommit summaryAuthorDate
r76328MFT: r76156nimishg19:39, 8 November 2010

Status & tagging log