- 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() && in_array($code, $wgContLang->getVariants()) ){
- $variant = $wgContLang->getPreferredVariant();
- if( $variant != $wgContLanguageCode )
- $code = $variant;
- }
-
- # Validate $code
- if( empty( $code ) || !preg_match( '/^[a-z-]+$/', $code ) || ( $code === 'qqq' ) ) {
- wfDebug( "Invalid user language code\n" );
- $code = $wgContLanguageCode;
- }
-
- if( $code === $wgContLanguageCode ) {
- return $wgContLang;
- } else {
- $obj = Language::factory( $code );
- return $obj;
- }
- }
-}
-
-/**
- * Stub object for the user. The initialisation of the will depend of
- * $wgCommandLineMode. If it's true, it will be an anonymous user and if it's
- * false, the user will be loaded from credidentails provided by cookies. This
- * object have to be in $wgUser global.
- */
-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();
- }
- return $user;