Commits

Anonymous committed db674de

fix order of parser calls; getPageLang first. remove commented out code.

Comments (0)

Files changed (1)

LangSwitch/LangSwitch.php

     global $wgLsInstance, $wgHooks;
     $wgLsInstance = new wfLangSwitch;
     
-    $wgHooks['ParserFirstCallInit'][] = array( &$wgLsInstance, 'registerParser' );
     $wgHooks['ParserFirstCallInit'][] = array( &$wgLsInstance, 'getPageLang' );
-    
+    $wgHooks['ParserFirstCallInit'][] = array( &$wgLsInstance, 'registerParser' );
+
     $wgHooks['ParserGetVariableValueSwitch'][] = array( &$wgLsInstance, 'getLangVar');
     $wgHooks['MagicWordwgVariableIDs'][] = array( &$wgLsInstance, 'declareMagicVar');
     $wgHooks['LanguageGetMagic'][] = array( &$wgLsInstance, 'registerMagic');
     
     function registerParser( &$parser ) {
         $parser->setFunctionHook( 'langswitch', array( &$this, 'parseLang' ), SFH_OBJECT_ARGS );
-        # $parser->setFunctionHook( 'setpagelang', array( &$this, 'setLang' ), SFH_NO_HASH );
-        # $parser->setFunctionHook( 'getLangVar', array( &$this, 'getLangVar' ), SFH_NO_HASH );
         return true;
     }
         
             $sub = substr( strrchr($title, '/'), 1); # Return last occurence of "/xxx", then return "/xxx" without its first character.
             if ( in_array( $sub, array('en', 'ru', 'fr') ) ) {
                 $this->pageLang = $sub;
-                # return $sub;
             }
             else {
                 $this->pageLang = 'en';
-                # return 'en';
             }
         }
         else { 
             # If there isn't, skip ze nonsense and set lang to 'en'.
             $this->pageLang = 'en';
-            # return 'en';
         }
         return true;
     }