r5270 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r5269‎ | r5270 | r5271 >
Date:18:23, 17 September 2004
Author:zhengzhu
Status:old
Tags:
Comment:
added a field called userVariant to user's options, to specify what language variant to use (e.g. Simplified or Traditional Chinese)
Modified paths:
  • /trunk/phase3/includes/SpecialPreferences.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialPreferences.php
@@ -27,7 +27,7 @@
2828 class PreferencesForm {
2929 var $mQuickbar, $mOldpass, $mNewpass, $mRetypePass, $mStubs;
3030 var $mRows, $mCols, $mSkin, $mMath, $mDate, $mUserEmail, $mEmailFlag, $mNick;
31 - var $mUserLanguage;
 31+ var $mUserLanguage, $mUserVariant;
3232 var $mSearch, $mRecent, $mHourDiff, $mSearchLines, $mSearchChars, $mAction;
3333 var $mReset, $mPosted, $mToggles, $mSearchNs, $mRealName, $mImageSize;
3434
@@ -53,6 +53,7 @@
5454 $this->mEmailFlag = $request->getCheck( 'wpEmailFlag' ) ? 1 : 0;
5555 $this->mNick = $request->getVal( 'wpNick' );
5656 $this->mUserLanguage = $request->getVal( 'wpUserLanguage' );
 57+ $this->mUserVariant = $request->getVal( 'wpUserVariant' );
5758 $this->mSearch = $request->getVal( 'wpSearch' );
5859 $this->mRecent = $request->getVal( 'wpRecent' );
5960 $this->mHourDiff = $request->getVal( 'wpHourDiff' );
@@ -178,6 +179,7 @@
179180 $wgUser->setEmail( $this->mUserEmail );
180181 $wgUser->setRealName( $this->mRealName );
181182 $wgUser->setOption( 'language', $this->mUserLanguage );
 183+ $wgUser->setOption( 'variant', $this->mUserVariant );
182184 $wgUser->setOption( 'nickname', $this->mNick );
183185 $wgUser->setOption( 'quickbar', $this->mQuickbar );
184186 $wgUser->setOption( 'skin', $this->mSkin );
@@ -222,6 +224,7 @@
223225 $this->mUserEmail = $wgUser->getEmail();
224226 $this->mRealName = ($wgAllowRealName) ? $wgUser->getRealName() : '';
225227 $this->mUserLanguage = $wgUser->getOption( 'language');
 228+ $this->mUserVariant = $wgUser->getOption( 'variant');
226229 if ( 1 == $wgUser->getOption( 'disablemail' ) ) { $this->mEmailFlag = 1; }
227230 else { $this->mEmailFlag = 0; }
228231 $this->mNick = $wgUser->getOption( 'nickname' );
@@ -357,6 +360,7 @@
358361 $yem = wfMsg( 'youremail' );
359362 $yrn = ($wgAllowRealName) ? wfMsg( 'yourrealname' ) : '';
360363 $yl = wfMsg( 'yourlanguage' );
 364+ $yv = wfMsg( 'yourvariant' );
361365 $emf = wfMsg( 'emailflag' );
362366 $ynn = wfMsg( 'yournick' );
363367 $stt = wfMsg ( 'stubthreshold' ) ;
@@ -398,6 +402,30 @@
399403 }
400404 $wgOut->addHtml("</label></div>\n" );
401405
 406+ /* see if there are multiple language variants to choose from*/
 407+ $variants = $wgLang->getVariants();
 408+ $size=sizeof($variants);
 409+
 410+ $variantArray=array();
 411+ foreach($variants as $v) {
 412+ $v = str_replace( '_', '-', strtolower($v));
 413+ print "v=$v\n";
 414+ if($name=$wgLanguageNames[$v]) {
 415+ $variantArray[$v] = $name;
 416+ }
 417+ }
 418+ $size=sizeof($variantArray);
 419+
 420+ if(sizeof($variantArray) > 1) {
 421+ $wgOut->addHtml("
 422+ <div><label>$yv: <select name=\"wpUserVariant\" />\n");
 423+ foreach($variantArray as $code => $name) {
 424+ $sel = ($code==$this->mUserVariant)? "selected" : "";
 425+ $wgOut->addHtml("\t<option value=\"$code\" $sel>$code - $name</option>\n");
 426+ }
 427+ $wgOut->addHtml("</label></div>\n");
 428+ }
 429+
402430 # Fields for changing password
403431 #
404432 $this->mOldpass = htmlspecialchars( $this->mOldpass );

Status & tagging log