00001 <?php
00011 function wfSpecialPreferences() {
00012 global $wgRequest;
00013
00014 $form = new PreferencesForm( $wgRequest );
00015 $form->execute();
00016 }
00017
00023 class PreferencesForm {
00024 var $mQuickbar, $mStubs;
00025 var $mRows, $mCols, $mSkin, $mMath, $mDate, $mUserEmail, $mEmailFlag, $mNick;
00026 var $mUserLanguage, $mUserVariant;
00027 var $mSearch, $mRecent, $mRecentDays, $mTimeZone, $mHourDiff, $mSearchLines, $mSearchChars, $mAction;
00028 var $mReset, $mPosted, $mToggles, $mSearchNs, $mRealName, $mImageSize;
00029 var $mUnderline, $mWatchlistEdits, $mGender;
00030
00035 function __construct( &$request ) {
00036 global $wgContLang, $wgUser, $wgAllowRealName;
00037
00038 $this->mQuickbar = $request->getVal( 'wpQuickbar' );
00039 $this->mStubs = $request->getVal( 'wpStubs' );
00040 $this->mRows = $request->getVal( 'wpRows' );
00041 $this->mCols = $request->getVal( 'wpCols' );
00042 $this->mSkin = Skin::normalizeKey( $request->getVal( 'wpSkin' ) );
00043 $this->mMath = $request->getVal( 'wpMath' );
00044 $this->mDate = $request->getVal( 'wpDate' );
00045 $this->mUserEmail = $request->getVal( 'wpUserEmail' );
00046 $this->mRealName = $wgAllowRealName ? $request->getVal( 'wpRealName' ) : '';
00047 $this->mEmailFlag = $request->getCheck( 'wpEmailFlag' ) ? 0 : 1;
00048 $this->mNick = $request->getVal( 'wpNick' );
00049 $this->mUserLanguage = $request->getVal( 'wpUserLanguage' );
00050 $this->mUserVariant = $request->getVal( 'wpUserVariant' );
00051 $this->mSearch = $request->getVal( 'wpSearch' );
00052 $this->mRecent = $request->getVal( 'wpRecent' );
00053 $this->mRecentDays = $request->getVal( 'wpRecentDays' );
00054 $this->mTimeZone = $request->getVal( 'wpTimeZone' );
00055 $this->mHourDiff = $request->getVal( 'wpHourDiff' );
00056 $this->mSearchLines = $request->getVal( 'wpSearchLines' );
00057 $this->mSearchChars = $request->getVal( 'wpSearchChars' );
00058 $this->mImageSize = $request->getVal( 'wpImageSize' );
00059 $this->mThumbSize = $request->getInt( 'wpThumbSize' );
00060 $this->mUnderline = $request->getInt( 'wpOpunderline' );
00061 $this->mAction = $request->getVal( 'action' );
00062 $this->mReset = $request->getCheck( 'wpReset' );
00063 $this->mRestoreprefs = $request->getCheck( 'wpRestore' );
00064 $this->mPosted = $request->wasPosted();
00065 $this->mSuccess = $request->getCheck( 'success' );
00066 $this->mWatchlistDays = $request->getVal( 'wpWatchlistDays' );
00067 $this->mWatchlistEdits = $request->getVal( 'wpWatchlistEdits' );
00068 $this->mDisableMWSuggest = $request->getCheck( 'wpDisableMWSuggest' );
00069 $this->mGender = $request->getVal( 'wpGender' );
00070
00071 $this->mSaveprefs = $request->getCheck( 'wpSaveprefs' ) &&
00072 $this->mPosted &&
00073 $wgUser->matchEditToken( $request->getVal( 'wpEditToken' ) );
00074
00075 # User toggles (the big ugly unsorted list of checkboxes)
00076 $this->mToggles = array();
00077 if ( $this->mPosted ) {
00078 $togs = User::getToggles();
00079 foreach ( $togs as $tname ) {
00080 $this->mToggles[$tname] = $request->getCheck( "wpOp$tname" ) ? 1 : 0;
00081 }
00082 }
00083
00084 $this->mUsedToggles = array();
00085
00086 # Search namespace options
00087 # Note: namespaces don't necessarily have consecutive keys
00088 $this->mSearchNs = array();
00089 if ( $this->mPosted ) {
00090 $namespaces = $wgContLang->getNamespaces();
00091 foreach ( $namespaces as $i => $namespace ) {
00092 if ( $i >= 0 ) {
00093 $this->mSearchNs[$i] = $request->getCheck( "wpNs$i" ) ? 1 : 0;
00094 }
00095 }
00096 }
00097
00098 # Validate language
00099 if ( !preg_match( '/^[a-z\-]*$/', $this->mUserLanguage ) ) {
00100 $this->mUserLanguage = 'nolanguage';
00101 }
00102
00103 wfRunHooks( 'InitPreferencesForm', array( $this, $request ) );
00104 }
00105
00106 function execute() {
00107 global $wgUser, $wgOut, $wgTitle;
00108
00109 if ( $wgUser->isAnon() ) {
00110 $wgOut->showErrorPage( 'prefsnologin', 'prefsnologintext', array($wgTitle->getPrefixedDBkey()) );
00111 return;
00112 }
00113 if ( wfReadOnly() ) {
00114 $wgOut->readOnlyPage();
00115 return;
00116 }
00117 if ( $this->mReset ) {
00118 $this->resetPrefs();
00119 $this->mainPrefsForm( 'reset', wfMsg( 'prefsreset' ) );
00120 } else if ( $this->mSaveprefs ) {
00121 $this->savePreferences();
00122 } else if ( $this->mRestoreprefs ) {
00123 $this->restorePreferences();
00124 } else {
00125 $this->resetPrefs();
00126 $this->mainPrefsForm( '' );
00127 }
00128 }
00132 function validateInt( &$val, $min=0, $max=0x7fffffff ) {
00133 $val = intval($val);
00134 $val = min($val, $max);
00135 $val = max($val, $min);
00136 return $val;
00137 }
00138
00142 function validateFloat( &$val, $min, $max=0x7fffffff ) {
00143 $val = floatval( $val );
00144 $val = min( $val, $max );
00145 $val = max( $val, $min );
00146 return( $val );
00147 }
00148
00152 function validateIntOrNull( &$val, $min=0, $max=0x7fffffff ) {
00153 $val = trim($val);
00154 if($val === '') {
00155 return null;
00156 } else {
00157 return $this->validateInt( $val, $min, $max );
00158 }
00159 }
00160
00164 function validateDate( $val ) {
00165 global $wgLang, $wgContLang;
00166 if ( $val !== false && (
00167 in_array( $val, (array)$wgLang->getDatePreferences() ) ||
00168 in_array( $val, (array)$wgContLang->getDatePreferences() ) ) )
00169 {
00170 return $val;
00171 } else {
00172 return $wgLang->getDefaultDateFormat();
00173 }
00174 }
00175
00184 function validateTimeZone( $tz, $s ) {
00185 $data = explode( '|', $tz, 3 );
00186 switch ( $data[0] ) {
00187 case 'ZoneInfo':
00188 case 'System':
00189 return $tz;
00190 case 'Offset':
00191 default:
00192 $data = explode( ':', $s, 2 );
00193 $minDiff = 0;
00194 if( count( $data ) == 2 ) {
00195 $data[0] = intval( $data[0] );
00196 $data[1] = intval( $data[1] );
00197 $minDiff = abs( $data[0] ) * 60 + $data[1];
00198 if ( $data[0] < 0 ) $minDiff = -$minDiff;
00199 } else {
00200 $minDiff = intval( $data[0] ) * 60;
00201 }
00202
00203 # Max is +14:00 and min is -12:00, see:
00204 # http://en.wikipedia.org/wiki/Timezone
00205 $minDiff = min( $minDiff, 840 ); # 14:00
00206 $minDiff = max( $minDiff, -720 ); # -12:00
00207 return 'Offset|'.$minDiff;
00208 }
00209 }
00210
00211 function validateGender( $val ) {
00212 $valid = array( 'male', 'female', 'unknown' );
00213 if ( in_array($val, $valid) ) {
00214 return $val;
00215 } else {
00216 return User::getDefaultOption( 'gender' );
00217 }
00218 }
00219
00223 function savePreferences() {
00224 global $wgUser, $wgOut, $wgParser;
00225 global $wgEnableUserEmail, $wgEnableEmail;
00226 global $wgEmailAuthentication, $wgRCMaxAge;
00227 global $wgAuth, $wgEmailConfirmToEdit;
00228
00229 $wgUser->setRealName( $this->mRealName );
00230 $oldOptions = $wgUser->mOptions;
00231
00232 if( $wgUser->getOption( 'language' ) !== $this->mUserLanguage ) {
00233 $needRedirect = true;
00234 } else {
00235 $needRedirect = false;
00236 }
00237
00238 # Validate the signature and clean it up as needed
00239 global $wgMaxSigChars;
00240 if( mb_strlen( $this->mNick ) > $wgMaxSigChars ) {
00241 global $wgLang;
00242 $this->mainPrefsForm( 'error',
00243 wfMsgExt( 'badsiglength', 'parsemag', $wgLang->formatNum( $wgMaxSigChars ) ) );
00244 return;
00245 } elseif( $this->mToggles['fancysig'] ) {
00246 if( $wgParser->validateSig( $this->mNick ) !== false ) {
00247 $this->mNick = $wgParser->cleanSig( $this->mNick );
00248 } else {
00249 $this->mainPrefsForm( 'error', wfMsg( 'badsig' ) );
00250 return;
00251 }
00252 } else {
00253
00254 $this->mNick = $wgParser->cleanSigInSig( $this->mNick );
00255 }
00256
00257 $wgUser->setOption( 'language', $this->mUserLanguage );
00258 $wgUser->setOption( 'variant', $this->mUserVariant );
00259 $wgUser->setOption( 'nickname', $this->mNick );
00260 $wgUser->setOption( 'quickbar', $this->mQuickbar );
00261 global $wgAllowUserSkin;
00262 if( $wgAllowUserSkin ) {
00263 $wgUser->setOption( 'skin', $this->mSkin );
00264 }
00265 global $wgUseTeX;
00266 if( $wgUseTeX ) {
00267 $wgUser->setOption( 'math', $this->mMath );
00268 }
00269 $wgUser->setOption( 'date', $this->validateDate( $this->mDate ) );
00270 $wgUser->setOption( 'searchlimit', $this->validateIntOrNull( $this->mSearch ) );
00271 $wgUser->setOption( 'contextlines', $this->validateIntOrNull( $this->mSearchLines ) );
00272 $wgUser->setOption( 'contextchars', $this->validateIntOrNull( $this->mSearchChars ) );
00273 $wgUser->setOption( 'rclimit', $this->validateIntOrNull( $this->mRecent ) );
00274 $wgUser->setOption( 'rcdays', $this->validateInt($this->mRecentDays, 1, ceil($wgRCMaxAge / (3600*24))));
00275 $wgUser->setOption( 'wllimit', $this->validateIntOrNull( $this->mWatchlistEdits, 0, 1000 ) );
00276 $wgUser->setOption( 'rows', $this->validateInt( $this->mRows, 4, 1000 ) );
00277 $wgUser->setOption( 'cols', $this->validateInt( $this->mCols, 4, 1000 ) );
00278 $wgUser->setOption( 'stubthreshold', $this->validateIntOrNull( $this->mStubs ) );
00279 $wgUser->setOption( 'timecorrection', $this->validateTimeZone( $this->mTimeZone, $this->mHourDiff ) );
00280 $wgUser->setOption( 'imagesize', $this->mImageSize );
00281 $wgUser->setOption( 'thumbsize', $this->mThumbSize );
00282 $wgUser->setOption( 'underline', $this->validateInt($this->mUnderline, 0, 2) );
00283 $wgUser->setOption( 'watchlistdays', $this->validateFloat( $this->mWatchlistDays, 0, 7 ) );
00284 $wgUser->setOption( 'disablesuggest', $this->mDisableMWSuggest );
00285 $wgUser->setOption( 'gender', $this->validateGender( $this->mGender ) );
00286
00287 # Set search namespace options
00288 foreach( $this->mSearchNs as $i => $value ) {
00289 $wgUser->setOption( "searchNs{$i}", $value );
00290 }
00291
00292 if( $wgEnableEmail && $wgEnableUserEmail ) {
00293 $wgUser->setOption( 'disablemail', $this->mEmailFlag );
00294 }
00295
00296 # Set user toggles
00297 foreach ( $this->mToggles as $tname => $tvalue ) {
00298 $wgUser->setOption( $tname, $tvalue );
00299 }
00300
00301 $error = false;
00302 if( $wgEnableEmail ) {
00303 $newadr = $this->mUserEmail;
00304 $oldadr = $wgUser->getEmail();
00305 if( ($newadr != '') && ($newadr != $oldadr) ) {
00306 # the user has supplied a new email address on the login page
00307 if( $wgUser->isValidEmailAddr( $newadr ) ) {
00308 # new behaviour: set this new emailaddr from login-page into user database record
00309 $wgUser->setEmail( $newadr );
00310 # but flag as "dirty" = unauthenticated
00311 $wgUser->invalidateEmail();
00312 if ($wgEmailAuthentication) {
00313 # Mail a temporary password to the dirty address.
00314 # User can come back through the confirmation URL to re-enable email.
00315 $result = $wgUser->sendConfirmationMail();
00316 if( WikiError::isError( $result ) ) {
00317 $error = wfMsg( 'mailerror', htmlspecialchars( $result->getMessage() ) );
00318 } else {
00319 $error = wfMsg( 'eauthentsent', $wgUser->getName() );
00320 }
00321 }
00322 } else {
00323 $error = wfMsg( 'invalidemailaddress' );
00324 }
00325 } else {
00326 if( $wgEmailConfirmToEdit && empty( $newadr ) ) {
00327 $this->mainPrefsForm( 'error', wfMsg( 'noemailtitle' ) );
00328 return;
00329 }
00330 $wgUser->setEmail( $this->mUserEmail );
00331 }
00332 if( $oldadr != $newadr ) {
00333 wfRunHooks( 'PrefsEmailAudit', array( $wgUser, $oldadr, $newadr ) );
00334 }
00335 }
00336
00337 if( !$wgAuth->updateExternalDB( $wgUser ) ){
00338 $this->mainPrefsForm( 'error', wfMsg( 'externaldberror' ) );
00339 return;
00340 }
00341
00342 $msg = '';
00343 if ( !wfRunHooks( 'SavePreferences', array( $this, $wgUser, &$msg, $oldOptions ) ) ) {
00344 $this->mainPrefsForm( 'error', $msg );
00345 return;
00346 }
00347
00348 $wgUser->setCookies();
00349 $wgUser->saveSettings();
00350
00351 if( $needRedirect && $error === false ) {
00352 $title = SpecialPage::getTitleFor( 'Preferences' );
00353 $wgOut->redirect( $title->getFullURL( 'success' ) );
00354 return;
00355 }
00356
00357 $wgOut->parserOptions( ParserOptions::newFromUser( $wgUser ) );
00358 $this->mainPrefsForm( $error === false ? 'success' : 'error', $error);
00359 }
00360
00364 function resetPrefs() {
00365 global $wgUser, $wgLang, $wgContLang, $wgContLanguageCode, $wgAllowRealName, $wgLocalTZoffset;
00366
00367 $this->mUserEmail = $wgUser->getEmail();
00368 $this->mUserEmailAuthenticationtimestamp = $wgUser->getEmailAuthenticationtimestamp();
00369 $this->mRealName = ($wgAllowRealName) ? $wgUser->getRealName() : '';
00370
00371 # language value might be blank, default to content language
00372 $this->mUserLanguage = $wgUser->getOption( 'language', $wgContLanguageCode );
00373
00374 $this->mUserVariant = $wgUser->getOption( 'variant');
00375 $this->mEmailFlag = $wgUser->getOption( 'disablemail' ) == 1 ? 1 : 0;
00376 $this->mNick = $wgUser->getOption( 'nickname' );
00377
00378 $this->mQuickbar = $wgUser->getOption( 'quickbar' );
00379 $this->mSkin = Skin::normalizeKey( $wgUser->getOption( 'skin' ) );
00380 $this->mMath = $wgUser->getOption( 'math' );
00381 $this->mDate = $wgUser->getDatePreference();
00382 $this->mRows = $wgUser->getOption( 'rows' );
00383 $this->mCols = $wgUser->getOption( 'cols' );
00384 $this->mStubs = $wgUser->getOption( 'stubthreshold' );
00385
00386 $tz = $wgUser->getOption( 'timecorrection' );
00387 $data = explode( '|', $tz, 3 );
00388 $minDiff = null;
00389 switch ( $data[0] ) {
00390 case 'ZoneInfo':
00391 $this->mTimeZone = $tz;
00392 # Check if the specified TZ exists, and change to 'Offset' if
00393 # not.
00394 if ( !function_exists('timezone_open') || @timezone_open( $data[2] ) === false ) {
00395 $this->mTimeZone = 'Offset';
00396 $minDiff = intval( $data[1] );
00397 }
00398 break;
00399 case '':
00400 case 'System':
00401 $this->mTimeZone = 'System|'.$wgLocalTZoffset;
00402 break;
00403 case 'Offset':
00404 $this->mTimeZone = 'Offset';
00405 $minDiff = intval( $data[1] );
00406 break;
00407 default:
00408 $this->mTimeZone = 'Offset';
00409 $data = explode( ':', $tz, 2 );
00410 if( count( $data ) == 2 ) {
00411 $data[0] = intval( $data[0] );
00412 $data[1] = intval( $data[1] );
00413 $minDiff = abs( $data[0] ) * 60 + $data[1];
00414 if ( $data[0] < 0 ) $minDiff = -$minDiff;
00415 } else {
00416 $minDiff = intval( $data[0] ) * 60;
00417 }
00418 break;
00419 }
00420 if ( is_null( $minDiff ) ) {
00421 $this->mHourDiff = '';
00422 } else {
00423 $this->mHourDiff = sprintf( '%+03d:%02d', floor($minDiff/60), abs($minDiff)%60 );
00424 }
00425
00426 $this->mSearch = $wgUser->getOption( 'searchlimit' );
00427 $this->mSearchLines = $wgUser->getOption( 'contextlines' );
00428 $this->mSearchChars = $wgUser->getOption( 'contextchars' );
00429 $this->mImageSize = $wgUser->getOption( 'imagesize' );
00430 $this->mThumbSize = $wgUser->getOption( 'thumbsize' );
00431 $this->mRecent = $wgUser->getOption( 'rclimit' );
00432 $this->mRecentDays = $wgUser->getOption( 'rcdays' );
00433 $this->mWatchlistEdits = $wgUser->getOption( 'wllimit' );
00434 $this->mUnderline = $wgUser->getOption( 'underline' );
00435 $this->mWatchlistDays = $wgUser->getOption( 'watchlistdays' );
00436 $this->mDisableMWSuggest = $wgUser->getBoolOption( 'disablesuggest' );
00437 $this->mGender = $wgUser->getOption( 'gender' );
00438
00439 $togs = User::getToggles();
00440 foreach ( $togs as $tname ) {
00441 $this->mToggles[$tname] = $wgUser->getOption( $tname );
00442 }
00443
00444 $namespaces = $wgContLang->getNamespaces();
00445 foreach ( $namespaces as $i => $namespace ) {
00446 if ( $i >= NS_MAIN ) {
00447 $this->mSearchNs[$i] = $wgUser->getOption( 'searchNs'.$i );
00448 }
00449 }
00450
00451 wfRunHooks( 'ResetPreferences', array( $this, $wgUser ) );
00452 }
00453
00457 function restorePreferences() {
00458 global $wgUser, $wgOut;
00459 $wgUser->restoreOptions();
00460 $wgUser->setCookies();
00461 $wgUser->saveSettings();
00462 $title = SpecialPage::getTitleFor( 'Preferences' );
00463 $wgOut->redirect( $title->getFullURL( 'success' ) );
00464 }
00465
00469 function namespacesCheckboxes() {
00470 global $wgContLang;
00471
00472 # Determine namespace checkboxes
00473 $namespaces = $wgContLang->getNamespaces();
00474 $r1 = null;
00475
00476 foreach ( $namespaces as $i => $name ) {
00477 if ($i < 0)
00478 continue;
00479 $checked = $this->mSearchNs[$i] ? "checked='checked'" : '';
00480 $name = str_replace( '_', ' ', $namespaces[$i] );
00481
00482 if ( empty($name) )
00483 $name = wfMsg( 'blanknamespace' );
00484
00485 $r1 .= "<input type='checkbox' value='1' name='wpNs$i' id='wpNs$i' {$checked}/> <label for='wpNs$i'>{$name}</label><br />\n";
00486 }
00487 return $r1;
00488 }
00489
00490
00491 function getToggle( $tname, $trailer = false, $disabled = false ) {
00492 global $wgUser, $wgLang;
00493
00494 $this->mUsedToggles[$tname] = true;
00495 $ttext = $wgLang->getUserToggle( $tname );
00496
00497 $checked = $wgUser->getOption( $tname ) == 1 ? ' checked="checked"' : '';
00498 $disabled = $disabled ? ' disabled="disabled"' : '';
00499 $trailer = $trailer ? $trailer : '';
00500 return "<div class='toggle'><input type='checkbox' value='1' id=\"$tname\" name=\"wpOp$tname\"$checked$disabled />" .
00501 " <span class='toggletext'><label for=\"$tname\">$ttext</label>$trailer</span></div>\n";
00502 }
00503
00504 function getToggles( $items ) {
00505 $out = "";
00506 foreach( $items as $item ) {
00507 if( $item === false )
00508 continue;
00509 if( is_array( $item ) ) {
00510 list( $key, $trailer ) = $item;
00511 } else {
00512 $key = $item;
00513 $trailer = false;
00514 }
00515 $out .= $this->getToggle( $key, $trailer );
00516 }
00517 return $out;
00518 }
00519
00520 function addRow($td1, $td2) {
00521 return "<tr><td class='mw-label'>$td1</td><td class='mw-input'>$td2</td></tr>";
00522 }
00523
00531 function tableRow( $td1, $td2 = null, $td3 = null ) {
00532
00533 if ( is_null( $td3 ) ) {
00534 $td3 = '';
00535 } else {
00536 $td3 = Xml::tags( 'tr', null,
00537 Xml::tags( 'td', array( 'class' => 'pref-label', 'colspan' => '2' ), $td3 )
00538 );
00539 }
00540
00541 if ( is_null( $td2 ) ) {
00542 $td1 = Xml::tags( 'td', array( 'class' => 'pref-label', 'colspan' => '2' ), $td1 );
00543 $td2 = '';
00544 } else {
00545 $td1 = Xml::tags( 'td', array( 'class' => 'pref-label' ), $td1 );
00546 $td2 = Xml::tags( 'td', array( 'class' => 'pref-input' ), $td2 );
00547 }
00548
00549 return Xml::tags( 'tr', null, $td1 . $td2 ). $td3 . "\n";
00550
00551 }
00552
00556 function mainPrefsForm( $status , $message = '' ) {
00557 global $wgUser, $wgOut, $wgLang, $wgContLang, $wgAuth;
00558 global $wgAllowRealName, $wgImageLimits, $wgThumbLimits;
00559 global $wgDisableLangConversion, $wgDisableTitleConversion;
00560 global $wgEnotifWatchlist, $wgEnotifUserTalk,$wgEnotifMinorEdits;
00561 global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress;
00562 global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
00563 global $wgContLanguageCode, $wgDefaultSkin, $wgCookieExpiration;
00564 global $wgEmailConfirmToEdit, $wgEnableMWSuggest, $wgLocalTZoffset;
00565
00566 $wgOut->setPageTitle( wfMsg( 'preferences' ) );
00567 $wgOut->setArticleRelated( false );
00568 $wgOut->setRobotPolicy( 'noindex,nofollow' );
00569 $wgOut->addScriptFile( 'prefs.js' );
00570
00571 $wgOut->disallowUserJs(); # Prevent hijacked user scripts from sniffing passwords etc.
00572
00573 if ( $this->mSuccess || 'success' == $status ) {
00574 $wgOut->wrapWikiMsg( '<div class="successbox"><strong>$1</strong></div>', 'savedprefs' );
00575 } else if ( 'error' == $status ) {
00576 $wgOut->addWikiText( '<div class="errorbox"><strong>' . $message . '</strong></div>' );
00577 } else if ( '' != $status ) {
00578 $wgOut->addWikiText( $message . "\n----" );
00579 }
00580
00581 $qbs = $wgLang->getQuickbarSettings();
00582 $mathopts = $wgLang->getMathNames();
00583 $dateopts = $wgLang->getDatePreferences();
00584 $togs = User::getToggles();
00585
00586 $titleObj = SpecialPage::getTitleFor( 'Preferences' );
00587
00588 # Pre-expire some toggles so they won't show if disabled
00589 $this->mUsedToggles[ 'shownumberswatching' ] = true;
00590 $this->mUsedToggles[ 'showupdated' ] = true;
00591 $this->mUsedToggles[ 'enotifwatchlistpages' ] = true;
00592 $this->mUsedToggles[ 'enotifusertalkpages' ] = true;
00593 $this->mUsedToggles[ 'enotifminoredits' ] = true;
00594 $this->mUsedToggles[ 'enotifrevealaddr' ] = true;
00595 $this->mUsedToggles[ 'ccmeonemails' ] = true;
00596 $this->mUsedToggles[ 'uselivepreview' ] = true;
00597 $this->mUsedToggles[ 'noconvertlink' ] = true;
00598
00599
00600 if ( !$this->mEmailFlag ) { $emfc = 'checked="checked"'; }
00601 else { $emfc = ''; }
00602
00603
00604 if ($wgEmailAuthentication && ($this->mUserEmail != '') ) {
00605 if( $wgUser->getEmailAuthenticationTimestamp() ) {
00606
00607
00608
00609 $time = $wgLang->timeAndDate( $wgUser->getEmailAuthenticationTimestamp(), true );
00610 $d = $wgLang->date( $wgUser->getEmailAuthenticationTimestamp(), true );
00611 $t = $wgLang->time( $wgUser->getEmailAuthenticationTimestamp(), true );
00612 $emailauthenticated = wfMsg('emailauthenticated', $time, $d, $t ).'<br />';
00613 $disableEmailPrefs = false;
00614 } else {
00615 $disableEmailPrefs = true;
00616 $skin = $wgUser->getSkin();
00617 $emailauthenticated = wfMsg('emailnotauthenticated').'<br />' .
00618 $skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Confirmemail' ),
00619 wfMsg( 'emailconfirmlink' ) ) . '<br />';
00620 }
00621 } else {
00622 $emailauthenticated = '';
00623 $disableEmailPrefs = false;
00624 }
00625
00626 if ($this->mUserEmail == '') {
00627 $emailauthenticated = wfMsg( 'noemailprefs' ) . '<br />';
00628 }
00629
00630 $ps = $this->namespacesCheckboxes();
00631
00632 $enotifwatchlistpages = ($wgEnotifWatchlist) ? $this->getToggle( 'enotifwatchlistpages', false, $disableEmailPrefs ) : '';
00633 $enotifusertalkpages = ($wgEnotifUserTalk) ? $this->getToggle( 'enotifusertalkpages', false, $disableEmailPrefs ) : '';
00634 $enotifminoredits = ($wgEnotifWatchlist && $wgEnotifMinorEdits) ? $this->getToggle( 'enotifminoredits', false, $disableEmailPrefs ) : '';
00635 $enotifrevealaddr = (($wgEnotifWatchlist || $wgEnotifUserTalk) && $wgEnotifRevealEditorAddress) ? $this->getToggle( 'enotifrevealaddr', false, $disableEmailPrefs ) : '';
00636
00637 # </FIXME>
00638
00639 $wgOut->addHTML(
00640 Xml::openElement( 'form', array(
00641 'action' => $titleObj->getLocalUrl(),
00642 'method' => 'post',
00643 'id' => 'mw-preferences-form',
00644 ) ) .
00645 Xml::openElement( 'div', array( 'id' => 'preferences' ) )
00646 );
00647
00648 # User data
00649
00650 $wgOut->addHTML(
00651 Xml::fieldset( wfMsg('prefs-personal') ) .
00652 Xml::openElement( 'table' ) .
00653 $this->tableRow( Xml::element( 'h2', null, wfMsg( 'prefs-personal' ) ) )
00654 );
00655
00656 # Get groups to which the user belongs
00657 $userEffectiveGroups = $wgUser->getEffectiveGroups();
00658 $userEffectiveGroupsArray = array();
00659 foreach( $userEffectiveGroups as $ueg ) {
00660 if( $ueg == '*' ) {
00661
00662 continue;
00663 }
00664 $userEffectiveGroupsArray[] = User::makeGroupLinkHTML( $ueg );
00665 }
00666 asort( $userEffectiveGroupsArray );
00667
00668 $sk = $wgUser->getSkin();
00669 $toolLinks = array();
00670 $toolLinks[] = $sk->makeKnownLinkObj( SpecialPage::getTitleFor( 'ListGroupRights' ), wfMsg( 'listgrouprights' ) );
00671 # At the moment one tool link only but be prepared for the future...
00672 # FIXME: Add a link to Special:Userrights for users who are allowed to use it.
00673 # $wgUser->isAllowed( 'userrights' ) seems to strict in some cases
00674
00675 $userInformationHtml =
00676 $this->tableRow( wfMsgHtml( 'username' ), htmlspecialchars( $wgUser->getName() ) ) .
00677 $this->tableRow( wfMsgHtml( 'uid' ), htmlspecialchars( $wgUser->getId() ) ) .
00678
00679 $this->tableRow(
00680 wfMsgExt( 'prefs-memberingroups', array( 'parseinline' ), count( $userEffectiveGroupsArray ) ),
00681 $wgLang->commaList( $userEffectiveGroupsArray ) .
00682 '<br />(' . $wgLang->pipeList( $toolLinks ) . ')'
00683 ) .
00684
00685 $this->tableRow(
00686 wfMsgHtml( 'prefs-edits' ),
00687 $wgLang->formatNum( $wgUser->getEditCount() )
00688 );
00689
00690 if( wfRunHooks( 'PreferencesUserInformationPanel', array( $this, &$userInformationHtml ) ) ) {
00691 $wgOut->addHTML( $userInformationHtml );
00692 }
00693
00694 if ( $wgAllowRealName ) {
00695 $wgOut->addHTML(
00696 $this->tableRow(
00697 Xml::label( wfMsg('yourrealname'), 'wpRealName' ),
00698 Xml::input( 'wpRealName', 25, $this->mRealName, array( 'id' => 'wpRealName' ) ),
00699 Xml::tags('div', array( 'class' => 'prefsectiontip' ),
00700 wfMsgExt( 'prefs-help-realname', 'parseinline' )
00701 )
00702 )
00703 );
00704 }
00705 if ( $wgEnableEmail ) {
00706 $wgOut->addHTML(
00707 $this->tableRow(
00708 Xml::label( wfMsg('youremail'), 'wpUserEmail' ),
00709 Xml::input( 'wpUserEmail', 25, $this->mUserEmail, array( 'id' => 'wpUserEmail' ) ),
00710 Xml::tags('div', array( 'class' => 'prefsectiontip' ),
00711 wfMsgExt( $wgEmailConfirmToEdit ? 'prefs-help-email-required' : 'prefs-help-email', 'parseinline' )
00712 )
00713 )
00714 );
00715 }
00716
00717 global $wgParser, $wgMaxSigChars;
00718 if( mb_strlen( $this->mNick ) > $wgMaxSigChars ) {
00719 $invalidSig = $this->tableRow(
00720 ' ',
00721 Xml::element( 'span', array( 'class' => 'error' ),
00722 wfMsgExt( 'badsiglength', 'parsemag', $wgLang->formatNum( $wgMaxSigChars ) ) )
00723 );
00724 } elseif( !empty( $this->mToggles['fancysig'] ) &&
00725 false === $wgParser->validateSig( $this->mNick ) ) {
00726 $invalidSig = $this->tableRow(
00727 ' ',
00728 Xml::element( 'span', array( 'class' => 'error' ), wfMsg( 'badsig' ) )
00729 );
00730 } else {
00731 $invalidSig = '';
00732 }
00733
00734 $wgOut->addHTML(
00735 $this->tableRow(
00736 Xml::label( wfMsg( 'yournick' ), 'wpNick' ),
00737 Xml::input( 'wpNick', 25, $this->mNick,
00738 array(
00739 'id' => 'wpNick',
00740
00741
00742
00743
00744 'maxlength' => $wgMaxSigChars ) )
00745 ) .
00746 $invalidSig .
00747 $this->tableRow( ' ', $this->getToggle( 'fancysig' ) )
00748 );
00749
00750 $gender = new XMLSelect( 'wpGender', 'wpGender', $this->mGender );
00751 $gender->addOption( wfMsg( 'gender-unknown' ), 'unknown' );
00752 $gender->addOption( wfMsg( 'gender-male' ), 'male' );
00753 $gender->addOption( wfMsg( 'gender-female' ), 'female' );
00754
00755 $wgOut->addHTML(
00756 $this->tableRow(
00757 Xml::label( wfMsg( 'yourgender' ), 'wpGender' ),
00758 $gender->getHTML(),
00759 Xml::tags( 'div', array( 'class' => 'prefsectiontip' ),
00760 wfMsgExt( 'prefs-help-gender', 'parseinline' )
00761 )
00762 )
00763 );
00764
00765 list( $lsLabel, $lsSelect) = Xml::languageSelector( $this->mUserLanguage, false );
00766 $wgOut->addHTML(
00767 $this->tableRow( $lsLabel, $lsSelect )
00768 );
00769
00770
00771 if(!$wgDisableLangConversion) {
00772 $variants = $wgContLang->getVariants();
00773 $variantArray = array();
00774
00775 $languages = Language::getLanguageNames( true );
00776 foreach($variants as $v) {
00777 $v = str_replace( '_', '-', strtolower($v));
00778 if( array_key_exists( $v, $languages ) ) {
00779
00780 $variantArray[$v] = $languages[$v];
00781 }
00782 }
00783
00784 $options = "\n";
00785 foreach( $variantArray as $code => $name ) {
00786 $selected = ($code == $this->mUserVariant);
00787 $options .= Xml::option( "$code - $name", $code, $selected ) . "\n";
00788 }
00789
00790 if(count($variantArray) > 1) {
00791 $wgOut->addHTML(
00792 $this->tableRow(
00793 Xml::label( wfMsg( 'yourvariant' ), 'wpUserVariant' ),
00794 Xml::tags( 'select',
00795 array( 'name' => 'wpUserVariant', 'id' => 'wpUserVariant' ),
00796 $options
00797 )
00798 )
00799 );
00800 }
00801
00802 if(count($variantArray) > 1 && !$wgDisableLangConversion && !$wgDisableTitleConversion) {
00803 $wgOut->addHTML(
00804 Xml::tags( 'tr', null,
00805 Xml::tags( 'td', array( 'colspan' => '2' ),
00806 $this->getToggle( "noconvertlink" )
00807 )
00808 )
00809 );
00810 }
00811 }
00812
00813 # Password
00814 if( $wgAuth->allowPasswordChange() ) {
00815 $link = $wgUser->getSkin()->link( SpecialPage::getTitleFor( 'ResetPass' ), wfMsgHtml( 'prefs-resetpass' ),
00816 array() , array( 'returnto' => SpecialPage::getTitleFor( 'Preferences' )->getPrefixedText() ) );
00817 $wgOut->addHTML(
00818 $this->tableRow( Xml::element( 'h2', null, wfMsg( 'changepassword' ) ) ) .
00819 $this->tableRow( '<ul><li>' . $link . '</li></ul>' ) );
00820 }
00821
00822 # <FIXME>
00823 # Enotif
00824 if ( $wgEnableEmail ) {
00825
00826 $moreEmail = '';
00827 if ($wgEnableUserEmail) {
00828
00829
00830 $emf = wfMsg( 'allowemail' );
00831 $disabled = $disableEmailPrefs ? ' disabled="disabled"' : '';
00832 $moreEmail =
00833 "<input type='checkbox' $emfc $disabled value='1' name='wpEmailFlag' id='wpEmailFlag' /> <label for='wpEmailFlag'>$emf</label>" .
00834 $this->getToggle( 'ccmeonemails', '', $disableEmailPrefs );
00835 }
00836
00837
00838 $wgOut->addHTML(
00839 $this->tableRow( Xml::element( 'h2', null, wfMsg( 'email' ) ) ) .
00840 $this->tableRow(
00841 $emailauthenticated.
00842 $enotifrevealaddr.
00843 $enotifwatchlistpages.
00844 $enotifusertalkpages.
00845 $enotifminoredits.
00846 $moreEmail
00847 )
00848 );
00849 }
00850 # </FIXME>
00851
00852 $wgOut->addHTML(
00853 Xml::closeElement( 'table' ) .
00854 Xml::closeElement( 'fieldset' )
00855 );
00856
00857
00858 # Quickbar
00859 #
00860 if ($this->mSkin == 'cologneblue' || $this->mSkin == 'standard') {
00861 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg( 'qbsettings' ) . "</legend>\n" );
00862 for ( $i = 0; $i < count( $qbs ); ++$i ) {
00863 if ( $i == $this->mQuickbar ) { $checked = ' checked="checked"'; }
00864 else { $checked = ""; }
00865 $wgOut->addHTML( "<div><label><input type='radio' name='wpQuickbar' value=\"$i\"$checked />{$qbs[$i]}</label></div>\n" );
00866 }
00867 $wgOut->addHTML( "</fieldset>\n\n" );
00868 } else {
00869 # Need to output a hidden option even if the relevant skin is not in use,
00870 # otherwise the preference will get reset to 0 on submit
00871 $wgOut->addHTML( Xml::hidden( 'wpQuickbar', $this->mQuickbar ) );
00872 }
00873
00874 # Skin
00875 #
00876 global $wgAllowUserSkin;
00877 if( $wgAllowUserSkin ) {
00878 $wgOut->addHTML( "<fieldset>\n<legend>\n" . wfMsg( 'skin' ) . "</legend>\n" );
00879 $mptitle = Title::newMainPage();
00880 $previewtext = wfMsg( 'skin-preview' );
00881 # Only show members of Skin::getSkinNames() rather than
00882 # $skinNames (skins is all skin names from Language.php)
00883 $validSkinNames = Skin::getUsableSkins();
00884 # Sort by UI skin name. First though need to update validSkinNames as sometimes
00885 # the skinkey & UI skinname differ (e.g. "standard" skinkey is "Classic" in the UI).
00886 foreach ( $validSkinNames as $skinkey => &$skinname ) {
00887 $msgName = "skinname-{$skinkey}";
00888 $localisedSkinName = wfMsg( $msgName );
00889 if ( !wfEmptyMsg( $msgName, $localisedSkinName ) ) {
00890 $skinname = $localisedSkinName;
00891 }
00892 }
00893 asort($validSkinNames);
00894 foreach( $validSkinNames as $skinkey => $sn ) {
00895 $checked = $skinkey == $this->mSkin ? ' checked="checked"' : '';
00896 $mplink = htmlspecialchars( $mptitle->getLocalURL( "useskin=$skinkey" ) );
00897 $previewlink = "(<a target='_blank' href=\"$mplink\">$previewtext</a>)";
00898 $extraLinks = '';
00899 global $wgAllowUserCss, $wgAllowUserJs;
00900 if( $wgAllowUserCss ) {
00901 $cssPage = Title::makeTitleSafe( NS_USER, $wgUser->getName().'/'.$skinkey.'.css' );
00902 $customCSS = $sk->makeLinkObj( $cssPage, wfMsgExt('prefs-custom-css', array() ) );
00903 $extraLinks .= " ($customCSS)";
00904 }
00905 if( $wgAllowUserJs ) {
00906 $jsPage = Title::makeTitleSafe( NS_USER, $wgUser->getName().'/'.$skinkey.'.js' );
00907 $customJS = $sk->makeLinkObj( $jsPage, wfMsgHtml('prefs-custom-js') );
00908 $extraLinks .= " ($customJS)";
00909 }
00910 if( $skinkey == $wgDefaultSkin )
00911 $sn .= ' (' . wfMsg( 'default' ) . ')';
00912 $wgOut->addHTML( "<input type='radio' name='wpSkin' id=\"wpSkin$skinkey\" value=\"$skinkey\"$checked />
00913 <label for=\"wpSkin$skinkey\">{$sn}</label> $previewlink{$extraLinks}<br />\n" );
00914 }
00915 $wgOut->addHTML( "</fieldset>\n\n" );
00916 }
00917
00918 # Math
00919 #
00920 global $wgUseTeX;
00921 if( $wgUseTeX ) {
00922 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('math') . '</legend>' );
00923 foreach ( $mathopts as $k => $v ) {
00924 $checked = ($k == $this->mMath);
00925 $wgOut->addHTML(
00926 Xml::openElement( 'div' ) .
00927 Xml::radioLabel( wfMsg( $v ), 'wpMath', $k, "mw-sp-math-$k", $checked ) .
00928 Xml::closeElement( 'div' ) . "\n"
00929 );
00930 }
00931 $wgOut->addHTML( "</fieldset>\n\n" );
00932 }
00933
00934 # Files
00935 #
00936 $imageLimitOptions = null;
00937 foreach ( $wgImageLimits as $index => $limits ) {
00938 $selected = ($index == $this->mImageSize);
00939 $imageLimitOptions .= Xml::option( "{$limits[0]}×{$limits[1]}" .
00940 wfMsg('unit-pixel'), $index, $selected );
00941 }
00942
00943 $imageThumbOptions = null;
00944 foreach ( $wgThumbLimits as $index => $size ) {
00945 $selected = ($index == $this->mThumbSize);
00946 $imageThumbOptions .= Xml::option($size . wfMsg('unit-pixel'), $index,
00947 $selected);
00948 }
00949
00950 $imageSizeId = 'wpImageSize';
00951 $thumbSizeId = 'wpThumbSize';
00952 $wgOut->addHTML(
00953 Xml::fieldset( wfMsg( 'files' ) ) . "\n" .
00954 Xml::openElement( 'table' ) .
00955 '<tr>
00956 <td class="mw-label">' .
00957 Xml::label( wfMsg( 'imagemaxsize' ), $imageSizeId ) .
00958 '</td>
00959 <td class="mw-input">' .
00960 Xml::openElement( 'select', array( 'name' => $imageSizeId, 'id' => $imageSizeId ) ) .
00961 $imageLimitOptions .
00962 Xml::closeElement( 'select' ) .
00963 '</td>
00964 </tr><tr>
00965 <td class="mw-label">' .
00966 Xml::label( wfMsg( 'thumbsize' ), $thumbSizeId ) .
00967 '</td>
00968 <td class="mw-input">' .
00969 Xml::openElement( 'select', array( 'name' => $thumbSizeId, 'id' => $thumbSizeId ) ) .
00970 $imageThumbOptions .
00971 Xml::closeElement( 'select' ) .
00972 '</td>
00973 </tr>' .
00974 Xml::closeElement( 'table' ) .
00975 Xml::closeElement( 'fieldset' )
00976 );
00977
00978 # Date format
00979 #
00980 # Date/Time
00981 #
00982
00983 $wgOut->addHTML(
00984 Xml::openElement( 'fieldset' ) .
00985 Xml::element( 'legend', null, wfMsg( 'datetime' ) ) . "\n"
00986 );
00987
00988 if ($dateopts) {
00989 $wgOut->addHTML(
00990 Xml::openElement( 'fieldset' ) .
00991 Xml::element( 'legend', null, wfMsg( 'dateformat' ) ) . "\n"
00992 );
00993 $idCnt = 0;
00994 $epoch = '20010115161234'; # Wikipedia day
00995 foreach( $dateopts as $key ) {
00996 if( $key == 'default' ) {
00997 $formatted = wfMsg( 'datedefault' );
00998 } else {
00999 $formatted = $wgLang->timeanddate( $epoch, false, $key );
01000 }
01001 $wgOut->addHTML(
01002 Xml::tags( 'div', null,
01003 Xml::radioLabel( $formatted, 'wpDate', $key, "wpDate$idCnt", $key == $this->mDate )
01004 ) . "\n"
01005 );
01006 $idCnt++;
01007 }
01008 $wgOut->addHTML( Xml::closeElement( 'fieldset' ) . "\n" );
01009 }
01010
01011 $nowlocal = Xml::openElement( 'span', array( 'id' => 'wpLocalTime' ) ) .
01012 $wgLang->time( $now = wfTimestampNow(), true ) .
01013 Xml::closeElement( 'span' );
01014 $nowserver = $wgLang->time( $now, false ) .
01015 Xml::hidden( 'wpServerTime', substr( $now, 8, 2 ) * 60 + substr( $now, 10, 2 ) );
01016
01017 $wgOut->addHTML(
01018 Xml::openElement( 'fieldset' ) .
01019 Xml::element( 'legend', null, wfMsg( 'timezonelegend' ) ) .
01020 Xml::openElement( 'table' ) .
01021 $this->addRow( wfMsg( 'servertime' ), $nowserver ) .
01022 $this->addRow( wfMsg( 'localtime' ), $nowlocal )
01023 );
01024 $opt = Xml::openElement( 'select', array(
01025 'name' => 'wpTimeZone',
01026 'id' => 'wpTimeZone',
01027 'onchange' => 'javascript:updateTimezoneSelection(false)' ) );
01028 $opt .= Xml::option( wfMsg( 'timezoneuseserverdefault' ), "System|$wgLocalTZoffset", $this->mTimeZone === "System|$wgLocalTZoffset" );
01029 $opt .= Xml::option( wfMsg( 'timezoneuseoffset' ), 'Offset', $this->mTimeZone === 'Offset' );
01030
01031 if ( function_exists( 'timezone_identifiers_list' ) ) {
01032 # Read timezone list
01033 $tzs = timezone_identifiers_list();
01034 sort( $tzs );
01035
01036 # Precache localized region names
01037 $tzRegions = array();
01038 $tzRegions['Africa'] = wfMsg( 'timezoneregion-africa' );
01039 $tzRegions['America'] = wfMsg( 'timezoneregion-america' );
01040 $tzRegions['Antarctica'] = wfMsg( 'timezoneregion-antarctica' );
01041 $tzRegions['Arctic'] = wfMsg( 'timezoneregion-arctic' );
01042 $tzRegions['Asia'] = wfMsg( 'timezoneregion-asia' );
01043 $tzRegions['Atlantic'] = wfMsg( 'timezoneregion-atlantic' );
01044 $tzRegions['Australia'] = wfMsg( 'timezoneregion-australia' );
01045 $tzRegions['Europe'] = wfMsg( 'timezoneregion-europe' );
01046 $tzRegions['Indian'] = wfMsg( 'timezoneregion-indian' );
01047 $tzRegions['Pacific'] = wfMsg( 'timezoneregion-pacific' );
01048 asort( $tzRegions );
01049
01050 $selZone = explode( '|', $this->mTimeZone, 3 );
01051 $selZone = ( $selZone[0] == 'ZoneInfo' ) ? $selZone[2] : null;
01052 $now = date_create( 'now' );
01053 $optgroup = '';
01054
01055 foreach ( $tzs as $tz ) {
01056 $z = explode( '/', $tz, 2 );
01057
01058 # timezone_identifiers_list() returns a number of
01059 # backwards-compatibility entries. This filters them out of the
01060 # list presented to the user.
01061 if ( count( $z ) != 2 || !array_key_exists( $z[0], $tzRegions ) )
01062 continue;
01063
01064 # Localize region
01065 $z[0] = $tzRegions[$z[0]];
01066
01067 # Create region groups
01068 if ( $optgroup != $z[0] ) {
01069 if ( $optgroup !== '' ) {
01070 $opt .= Xml::closeElement( 'optgroup' );
01071 }
01072 $optgroup = $z[0];
01073 $opt .= Xml::openElement( 'optgroup', array( 'label' => $z[0] ) ) . "\n";
01074 }
01075
01076 $minDiff = floor( timezone_offset_get( timezone_open( $tz ), $now ) / 60 );
01077 $opt .= Xml::option( str_replace( '_', ' ', $z[0] . '/' . $z[1] ), "ZoneInfo|$minDiff|$tz", $selZone === $tz, array( 'label' => $z[1] ) ) . "\n";
01078 }
01079 if ( $optgroup !== '' ) $opt .= Xml::closeElement( 'optgroup' );
01080 }
01081 $opt .= Xml::closeElement( 'select' );
01082 $wgOut->addHTML(
01083 $this->addRow(
01084 Xml::label( wfMsg( 'timezoneselect' ), 'wpTimeZone' ),
01085 $opt )
01086 );
01087 $wgOut->addHTML(
01088 $this->addRow(
01089 Xml::label( wfMsg( 'timezoneoffset' ), 'wpHourDiff' ),
01090 Xml::input( 'wpHourDiff', 6, $this->mHourDiff, array(
01091 'id' => 'wpHourDiff',
01092 'onfocus' => 'javascript:updateTimezoneSelection(true)',
01093 'onblur' => 'javascript:updateTimezoneSelection(false)' ) ) ) .
01094 "<tr>
01095 <td></td>
01096 <td class='mw-submit'>" .
01097 Xml::element( 'input',
01098 array( 'type' => 'button',
01099 'value' => wfMsg( 'guesstimezone' ),
01100 'onclick' => 'javascript:guessTimezone()',
01101 'id' => 'guesstimezonebutton',
01102 'style' => 'display:none;' ) ) .
01103 "</td>
01104 </tr>" .
01105 Xml::closeElement( 'table' ) .
01106 Xml::tags( 'div', array( 'class' => 'prefsectiontip' ), wfMsgExt( 'timezonetext', 'parseinline' ) ).
01107 Xml::closeElement( 'fieldset' ) .
01108 Xml::closeElement( 'fieldset' ) . "\n\n"
01109 );
01110
01111 # Editing
01112 #
01113 global $wgLivePreview;
01114 $wgOut->addHTML(
01115 Xml::fieldset( wfMsg( 'textboxsize' ) ) .
01116 wfMsgHTML( 'prefs-edit-boxsize' ) . ' ' .
01117 Xml::inputLabel( wfMsg( 'rows' ), 'wpRows', 'wpRows', 3, $this->mRows ) . ' ' .
01118 Xml::inputLabel( wfMsg( 'columns' ), 'wpCols', 'wpCols', 3, $this->mCols ) .
01119 $this->getToggles( array(
01120 'editsection',
01121 'editsectiononrightclick',
01122 'editondblclick',
01123 'editwidth',
01124 'showtoolbar',
01125 'previewonfirst',
01126 'previewontop',
01127 'minordefault',
01128 'externaleditor',
01129 'externaldiff',
01130 $wgLivePreview ? 'uselivepreview' : false,
01131 'forceeditsummary',
01132 ) )
01133 );
01134
01135 $wgOut->addHTML( Xml::closeElement( 'fieldset' ) );
01136
01137 # Recent changes
01138 global $wgRCMaxAge, $wgUseRCPatrol;
01139 $wgOut->addHTML(
01140 Xml::fieldset( wfMsg( 'prefs-rc' ) ) .
01141 Xml::openElement( 'table' ) .
01142 '<tr>
01143 <td class="mw-label">' .
01144 Xml::label( wfMsg( 'recentchangesdays' ), 'wpRecentDays' ) .
01145 '</td>
01146 <td class="mw-input">' .
01147 Xml::input( 'wpRecentDays', 3, $this->mRecentDays, array( 'id' => 'wpRecentDays' ) ) . ' ' .
01148 wfMsgExt( 'recentchangesdays-max', 'parsemag',
01149 $wgLang->formatNum( ceil( $wgRCMaxAge / ( 3600 * 24 ) ) ) ) .
01150 '</td>
01151 </tr><tr>
01152 <td class="mw-label">' .
01153 Xml::label( wfMsg( 'recentchangescount' ), 'wpRecent' ) .
01154 '</td>
01155 <td class="mw-input">' .
01156 Xml::input( 'wpRecent', 3, $this->mRecent, array( 'id' => 'wpRecent' ) ) .
01157 '</td>
01158 </tr>' .
01159 Xml::closeElement( 'table' ) .
01160 '<br />'
01161 );
01162
01163 $toggles[] = 'hideminor';
01164 if( $wgUseRCPatrol ) {
01165 $toggles[] = 'hidepatrolled';
01166 $toggles[] = 'newpageshidepatrolled';
01167 }
01168 if( $wgRCShowWatchingUsers ) $toggles[] = 'shownumberswatching';
01169 $toggles[] = 'usenewrc';
01170
01171 $wgOut->addHTML(
01172 $this->getToggles( $toggles ) .
01173 Xml::closeElement( 'fieldset' )
01174 );
01175
01176 # Watchlist
01177 $watchlistToggles = array( 'watchlisthideminor', 'watchlisthidebots', 'watchlisthideown',
01178 'watchlisthideanons', 'watchlisthideliu' );
01179 if( $wgUseRCPatrol ) $watchlistToggles[] = 'watchlisthidepatrolled';
01180
01181 $wgOut->addHTML(
01182 Xml::fieldset( wfMsg( 'prefs-watchlist' ) ) .
01183 Xml::inputLabel( wfMsg( 'prefs-watchlist-days' ), 'wpWatchlistDays', 'wpWatchlistDays', 3, $this->mWatchlistDays ) . ' ' .
01184 wfMsgHTML( 'prefs-watchlist-days-max' ) .
01185 '<br /><br />' .
01186 $this->getToggle( 'extendwatchlist' ) .
01187 Xml::inputLabel( wfMsg( 'prefs-watchlist-edits' ), 'wpWatchlistEdits', 'wpWatchlistEdits', 3, $this->mWatchlistEdits ) . ' ' .
01188 wfMsgHTML( 'prefs-watchlist-edits-max' ) .
01189 '<br /><br />' .
01190 $this->getToggles( $watchlistToggles )
01191 );
01192
01193 if( $wgUser->isAllowed( 'createpage' ) || $wgUser->isAllowed( 'createtalk' ) ) {
01194 $wgOut->addHTML( $this->getToggle( 'watchcreations' ) );
01195 }
01196
01197 foreach( array( 'edit' => 'watchdefault', 'move' => 'watchmoves', 'delete' => 'watchdeletion' ) as $action => $toggle ) {
01198 if( $wgUser->isAllowed( $action ) )
01199 $wgOut->addHTML( $this->getToggle( $toggle ) );
01200 }
01201 $this->mUsedToggles['watchcreations'] = true;
01202 $this->mUsedToggles['watchdefault'] = true;
01203 $this->mUsedToggles['watchmoves'] = true;
01204 $this->mUsedToggles['watchdeletion'] = true;
01205
01206 $wgOut->addHTML( Xml::closeElement( 'fieldset' ) );
01207
01208 # Search
01209 $mwsuggest = $wgEnableMWSuggest ?
01210 $this->addRow(
01211 Xml::label( wfMsg( 'mwsuggest-disable' ), 'wpDisableMWSuggest' ),
01212 Xml::check( 'wpDisableMWSuggest', $this->mDisableMWSuggest, array( 'id' => 'wpDisableMWSuggest' ) )
01213 ) : '';
01214 $wgOut->addHTML(
01215
01216 Xml::openElement( 'fieldset' ) .
01217 Xml::element( 'legend', null, wfMsg( 'searchresultshead' ) ) .
01218
01219 Xml::openElement( 'fieldset' ) .
01220 Xml::element( 'legend', null, wfMsg( 'prefs-searchoptions' ) ) .
01221 Xml::openElement( 'table' ) .
01222 $this->addRow(
01223 Xml::label( wfMsg( 'resultsperpage' ), 'wpSearch' ),
01224 Xml::input( 'wpSearch', 4, $this->mSearch, array( 'id' => 'wpSearch' ) )
01225 ) .
01226 $this->addRow(
01227 Xml::label( wfMsg( 'contextlines' ), 'wpSearchLines' ),
01228 Xml::input( 'wpSearchLines', 4, $this->mSearchLines, array( 'id' => 'wpSearchLines' ) )
01229 ) .
01230 $this->addRow(
01231 Xml::label( wfMsg( 'contextchars' ), 'wpSearchChars' ),
01232 Xml::input( 'wpSearchChars', 4, $this->mSearchChars, array( 'id' => 'wpSearchChars' ) )
01233 ) .
01234 $mwsuggest .
01235 Xml::closeElement( 'table' ) .
01236 Xml::closeElement( 'fieldset' ) .
01237
01238 Xml::openElement( 'fieldset' ) .
01239 Xml::element( 'legend', null, wfMsg( 'prefs-namespaces' ) ) .
01240 wfMsgExt( 'defaultns', array( 'parse' ) ) .
01241 $ps .
01242 Xml::closeElement( 'fieldset' ) .
01243
01244 Xml::closeElement( 'fieldset' )
01245 );
01246
01247 # Misc
01248 #
01249 $uopt = $wgUser->getOption( 'underline' );
01250 $wgOut->addHTML(
01251 Xml::fieldset( wfMsg( 'prefs-misc' ) ) .
01252 Xml::openElement( 'table' ) .
01253 '<tr>
01254 <td class="mw-label">' .
01255
01256 Xml::tags( 'label', array( 'for' => 'wpStubs' ), wfMsg( 'stub-threshold' ) ) .
01257 '</td>
01258 <td class="mw-input">' .
01259 Xml::input( 'wpStubs', 6, $this->mStubs, array( 'id' => 'wpStubs' ) ) .
01260 '</td>
01261 </tr><tr>
01262 <td class="mw-label">' .
01263 Xml::label( wfMsg( 'tog-underline' ), 'wpOpunderline' ) .
01264 '</td>
01265 <td class="mw-input">' .
01266 Xml::openElement( 'select', array( 'id' => 'wpOpunderline', 'name' => 'wpOpunderline' ) ) .
01267 Xml::option( wfMsg ( 'underline-never' ), '0', $uopt == 0 ) .
01268 Xml::option( wfMsg ( 'underline-always' ), '1', $uopt == 1 ) .
01269 Xml::option( wfMsg ( 'underline-default' ), '2', $uopt == 2 ) .
01270 Xml::closeElement( 'select' ) .
01271 '</td>
01272 </tr>' .
01273 Xml::closeElement( 'table' )
01274 );
01275
01276 # And now the rest = Misc.
01277 foreach ( $togs as $tname ) {
01278 if( !array_key_exists( $tname, $this->mUsedToggles ) ) {
01279 if( $tname == 'norollbackdiff' && $wgUser->isAllowed( 'rollback' ) )
01280 $wgOut->addHTML( $this->getToggle( $tname ) );
01281 else
01282 $wgOut->addHTML( $this->getToggle( $tname ) );
01283 }
01284 }
01285
01286 $wgOut->addHTML( '</fieldset>' );
01287
01288 wfRunHooks( 'RenderPreferencesForm', array( $this, $wgOut ) );
01289
01290 $token = htmlspecialchars( $wgUser->editToken() );
01291 $skin = $wgUser->getSkin();
01292 $rtl = $wgContLang->isRTL() ? 'left' : 'right';
01293 $wgOut->addHTML( "
01294 <table id='prefsubmit' cellpadding='0' width='100%' style='background:none;'><tr>
01295 <td><input type='submit' name='wpSaveprefs' class='btnSavePrefs' value=\"" . wfMsgHtml( 'saveprefs' ) .
01296 '"'.$skin->tooltipAndAccesskey('save')." />
01297 <input type='submit' name='wpReset' value=\"" . wfMsgHtml( 'resetprefs' ) . "\" /></td>
01298 <td align='$rtl'><input type='submit' name='wpRestore' value=\"" . wfMsgHtml( 'restoreprefs' ) . "\" /></td>
01299 </tr></table>
01300
01301 <input type='hidden' name='wpEditToken' value=\"{$token}\" />
01302 </div></form>\n" );
01303
01304 $wgOut->addHTML( Xml::tags( 'div', array( 'class' => "prefcache" ),
01305 wfMsgExt( 'clearyourcache', 'parseinline' ) )
01306 );
01307 }
01308 }