- global $wgContLanguageCode, $wgRequest, $wgUser, $wgContLang;
- $code = $wgRequest->getVal('uselang', $wgUser->getOption('language') );
-
- // if variant is explicitely selected, use it instead the one from wgUser
- // see bug #7605
- if($wgContLang->hasVariants()){
- $variant = $wgContLang->getPreferredVariant();
- if($variant != $wgContLanguageCode)
- $code = $variant;
- }
-
- # Validate $code
- if( empty( $code ) || !preg_match( '/^[a-z-]+$/', $code ) ) {
- wfDebug( "Invalid user language code\n" );
- $code = $wgContLanguageCode;
- }
-
- if( $code === $wgContLanguageCode ) {
- return $wgContLang;
- } else {
- $obj = Language::factory( $code );
- return $obj;
- }
- }
-}
-class StubUser extends StubObject {
- function __construct() {
- parent::__construct( 'wgUser' );
- }
-
- function __call( $name, $args ) {
- return $this->_call( $name, $args );
- }
-
- function _newObject() {
- global $wgCommandLineMode;
- if( $wgCommandLineMode ) {
- $user = new User;
- } else {
- $user = User::newFromSession();
- wfRunHooks('AutoAuthenticate',array(&$user));
- }
- return $user;