http://www.mediawiki.org/wiki/Special:Code/MediaWiki/76328

Revision: 76328
Author:   nimishg
Date:     2010-11-08 19:39:42 +0000 (Mon, 08 Nov 2010)
Log Message:
-----------
MFT: r76156

Modified Paths:
--------------
    branches/wmf/1.16wmf4/extensions/LandingCheck/LandingCheck.php
    branches/wmf/1.16wmf4/extensions/LandingCheck/SpecialLandingCheck.php

Modified: branches/wmf/1.16wmf4/extensions/LandingCheck/LandingCheck.php
===================================================================
--- branches/wmf/1.16wmf4/extensions/LandingCheck/LandingCheck.php      
2010-11-08 19:38:16 UTC (rev 76327)
+++ branches/wmf/1.16wmf4/extensions/LandingCheck/LandingCheck.php      
2010-11-08 19:39:42 UTC (rev 76328)
@@ -19,6 +19,10 @@
        'descriptionmsg' => 'landingcheck-desc',
 );
 
+// If there are any countries for which the country page should be the 
fallback rather than a
+// language page, add its country code to this array.
+$priorityCountries = array();
+
 $dir = dirname( __FILE__ ) . '/';
 
 $wgAutoloadClasses['SpecialLandingCheck'] = $dir . 'SpecialLandingCheck.php';

Modified: branches/wmf/1.16wmf4/extensions/LandingCheck/SpecialLandingCheck.php
===================================================================
--- branches/wmf/1.16wmf4/extensions/LandingCheck/SpecialLandingCheck.php       
2010-11-08 19:38:16 UTC (rev 76327)
+++ branches/wmf/1.16wmf4/extensions/LandingCheck/SpecialLandingCheck.php       
2010-11-08 19:39:42 UTC (rev 76328)
@@ -17,7 +17,7 @@
        }
        
        public function execute( $sub ) {
-               global $wgOut, $wgRequest;
+               global $wgOut, $wgRequest, $priorityCountries;
                
                // Pull in query string parameters
                $language = $wgRequest->getVal( 'language', 'en' );
@@ -32,16 +32,24 @@
                        'referrer' => $wgRequest->getHeader( 'referer' )
                ) );
                
-               // Build array of landing pages to check for
-               $targetTexts = array(
-                       $landingPage . '/' . $language . '/' . $country,
-                       $landingPage . '/' . $language
-               );
-               // Add fallback languages
-               $code = $language;
-               while ( $code !== 'en' ) {
-                       $code = Language::getFallbackFor( $code );
-                       $targetTexts[] = $landingPage . '/' . $code;
+               if ( in_array( $country, $priorityCountries ) ) {
+                       // Build array of landing pages to check for
+                       $targetTexts = array(
+                               $landingPage . '/' . $country . '/' . $language,
+                               $landingPage . '/' . $country
+                       );
+               } else {
+                       // Build array of landing pages to check for
+                       $targetTexts = array(
+                               $landingPage . '/' . $language . '/' . $country,
+                               $landingPage . '/' . $language
+                       );
+                       // Add fallback languages
+                       $code = $language;
+                       while ( $code !== 'en' ) {
+                               $code = Language::getFallbackFor( $code );
+                               $targetTexts[] = $landingPage . '/' . $code;
+                       }
                }
                
                // Go through the possible landing pages and redirect the user 
as soon as one is found to exist


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to