$wgLoadBalancer->loadMasterPos();
wfProfileOut( $fname.'-database' );
+wfProfileIn( $fname.'-User' );
+
+# Extension setup functions
+# Entries should be added to this variable during the inclusion
+# of the extension file. This allows the extension to perform
+# any necessary initialisation in the fully initialised environment
+foreach ( $wgSkinExtensionFunctions as $func ) {
+ $func();
+}
+
+if( $wgCommandLineMode ) {
+ # Used for some maintenance scripts; user session cookies can screw things up
+ # when the database is in an in-between state.
+ $wgUser = new User();
+} else {
+ $wgUser = User::loadFromSession();
+}
+
+// FIXME : we don't know what the user entered (see SpecialPreferences.php [AV])
+if(isset($wgUser->mOptions['language'])) {
+ // Change language of the site
+ $wgLanguageCode = $wgUser->mOptions['language'];
+ // we will load messages from file instead of from database
+ $wgUseDatabaseMessages = false;
+ }
+
+wfProfileOut( $fname.'-User' );
wfProfileIn( $fname.'-language' );
require_once( 'languages/Language.php' );
-$wgMessageCache = new MessageCache;
+$wgMessageCache = new MessageCache;
$wgLangClass = 'Language' . str_replace( '-', '_', ucfirst( $wgLanguageCode ) );
if( ! class_exists( $wgLangClass ) || ($wgLanguageCode == 'en' && !$wgUseLatin1) ) {
unset( $wgLang );
$wgLang = $xxx;
}
+
+// now that we have a language object, set per language user defaults options
+// if we didn't grabbed them from database.
+if(!$wgUser->mDataLoaded) { $wgUser->loadDefaultFromLanguage(); }
+
wfProfileOut( $fname.'-language' );
wfProfileIn( $fname.'-MessageCache' );
$wgBlockCache = new BlockCache( true );
wfProfileOut( $fname.'-BlockCache' );
-wfProfileIn( $fname.'-User' );
-
-# Extension setup functions
-# Entries should be added to this variable during the inclusion
-# of the extension file. This allows the extension to perform
-# any necessary initialisation in the fully initialised environment
-foreach ( $wgSkinExtensionFunctions as $func ) {
- $func();
-}
-
-if( $wgCommandLineMode ) {
- # Used for some maintenance scripts; user session cookies can screw things up
- # when the database is in an in-between state.
- $wgUser = new User();
-} else {
- $wgUser = User::loadFromSession();
-}
-
-wfProfileOut( $fname.'-User' );
wfProfileIn( $fname.'-misc2' );
$wgDeferredUpdateList = array();
class PreferencesForm {
var $mQuickbar, $mOldpass, $mNewpass, $mRetypePass, $mStubs;
var $mRows, $mCols, $mSkin, $mMath, $mDate, $mUserEmail, $mEmailFlag, $mNick;
+ var $mUserLanguage;
var $mSearch, $mRecent, $mHourDiff, $mSearchLines, $mSearchChars, $mAction;
var $mReset, $mPosted, $mToggles, $mSearchNs, $mRealName;
$this->mMath = $request->getVal( 'wpMath' );
$this->mDate = $request->getVal( 'wpDate' );
$this->mUserEmail = $request->getVal( 'wpUserEmail' );
- $this->mRealName = ($wgAllowRealName) ? $request->getVal( 'wpRealName' ) : '';
+ $this->mRealName = ($wgAllowRealName) ? $request->getVal( 'wpRealName' ) : '';
$this->mEmailFlag = $request->getCheck( 'wpEmailFlag' ) ? 1 : 0;
$this->mNick = $request->getVal( 'wpNick' );
+ $this->mUserLanguage = $request->getVal( 'wpUserLanguage' );
$this->mSearch = $request->getVal( 'wpSearch' );
$this->mRecent = $request->getVal( 'wpRecent' );
$this->mHourDiff = $request->getVal( 'wpHourDiff' );
}
$wgUser->setEmail( $this->mUserEmail );
$wgUser->setRealName( $this->mRealName );
+ $wgUser->setOption( 'language', $this->mUserLanguage );
$wgUser->setOption( 'nickname', $this->mNick );
$wgUser->setOption( 'quickbar', $this->mQuickbar );
$wgUser->setOption( 'skin', $this->mSkin );
/**
* @access private
- */ function resetPrefs() {
+ */
+ function resetPrefs() {
global $wgUser, $wgLang, $wgAllowRealName;
$this->mOldpass = $this->mNewpass = $this->mRetypePass = '';
$this->mUserEmail = $wgUser->getEmail();
- $this->mRealName = ($wgAllowRealName) ? $wgUser->getRealName() : '';
+ $this->mRealName = ($wgAllowRealName) ? $wgUser->getRealName() : '';
+ $this->mUserLanguage = $wgUser->getOption( 'language');
if ( 1 == $wgUser->getOption( 'disablemail' ) ) { $this->mEmailFlag = 1; }
else { $this->mEmailFlag = 0; }
$this->mNick = $wgUser->getOption( 'nickname' );
$tzGuess = wfMsg( 'guesstimezone' );
$tzServerTime = wfMsg( 'servertime' );
$yem = wfMsg( 'youremail' );
- $yrn = ($wgAllowRealName) ? wfMsg( 'yourrealname' ) : '';
+ $yrn = ($wgAllowRealName) ? wfMsg( 'yourrealname' ) : '';
+ $yl = wfMsg( 'yourlanguage' );
$emf = wfMsg( 'emailflag' );
$ynn = wfMsg( 'yournick' );
$stt = wfMsg ( 'stubthreshold' ) ;
$wgOut->addHTML("
<div><label>$yem: <input type='text' name=\"wpUserEmail\" value=\"{$this->mUserEmail}\" size='20' /></label></div>
<div><label><input type='checkbox' $emfc value=\"1\" name=\"wpEmailFlag\" /> $emf</label></div>
- <div><label>$ynn: <input type='text' name=\"wpNick\" value=\"{$this->mNick}\" size='12' /></label></div>\n" );
+ <div><label>$ynn: <input type='text' name=\"wpNick\" value=\"{$this->mNick}\" size='12' /></label></div>
+ <div><label>$yl: <input type='text' name=\"wpUserLanguage\" value=\"{$this->mUserLanguage}\" size='8' /></label></div>\n" );
# Fields for changing password
#
/**
* Set properties to default
- * Used at construction.
+ * Used at construction. It will load per language default settings only
+ * if we have an available language object.
*/
function loadDefaults() {
global $wgLang, $wgIP;
$this->mRealName = $this->mEmail = '';
$this->mPassword = $this->mNewpassword = '';
$this->mRights = array();
- $defOpt = $wgLang->getDefaultUserOptions() ;
- foreach ( $defOpt as $oname => $val ) {
- $this->mOptions[$oname] = $val;
- }
+ // Getting user defaults only if we have an available language
+ if(isset($wgLang)) { $this->loadDefaultFromLanguage(); }
+
foreach ($wgNamespacesToBeSearchedDefault as $nsnum => $val) {
$this->mOptions['searchNs'.$nsnum] = $val;
}
$this->cookiePassword = '';
$this->mHash = false;
}
+
+ /**
+ * Used to load user options from a language.
+ * This is not in loadDefault() cause we sometime create user before having
+ * a language object.
+ */
+ function loadDefaultFromLanguage(){
+ global $wgLang;
+ $defOpt = $wgLang->getDefaultUserOptions() ;
+ foreach ( $defOpt as $oname => $val ) {
+ $this->mOptions[$oname] = $val;
+ }
+ }
/**
* Get blocking information
return ( 0 != $this->mNewtalk );
}
- function setNewtalk( $val )
- {
+ function setNewtalk( $val ) {
$this->loadFromDatabase();
$this->mNewtalk = $val;
$this->invalidateCache();