Page move undo feature
[lhc/web/wiklou.git] / includes / SpecialPreferences.php
1 <?php
2 /**
3 * Hold things related to displaying and saving user preferences.
4 * @package MediaWiki
5 * @subpackage SpecialPage
6 */
7
8 if( !defined( 'MEDIAWIKI' ) )
9 die();
10
11 /** to get a list of languages in setting user's language preference */
12 require_once('languages/Names.php');
13
14 /**
15 * Entry point that create the "Preferences" object
16 */
17 function wfSpecialPreferences() {
18 global $wgRequest;
19
20 $form = new PreferencesForm( $wgRequest );
21 $form->execute();
22 }
23
24 /**
25 * Preferences form handling
26 * This object will show the preferences form and can save it as well.
27 * @package MediaWiki
28 * @subpackage SpecialPage
29 */
30 class PreferencesForm {
31 var $mQuickbar, $mOldpass, $mNewpass, $mRetypePass, $mStubs;
32 var $mRows, $mCols, $mSkin, $mMath, $mDate, $mUserEmail, $mEmailFlag, $mNick;
33 var $mUserLanguage, $mUserVariant;
34 var $mSearch, $mRecent, $mHourDiff, $mSearchLines, $mSearchChars, $mAction;
35 var $mReset, $mPosted, $mToggles, $mSearchNs, $mRealName, $mImageSize;
36
37 /**
38 * Constructor
39 * Load some values
40 */
41 function PreferencesForm( &$request ) {
42 global $wgLang, $wgContLang, $wgUser, $wgAllowRealName;
43
44 $this->mQuickbar = $request->getVal( 'wpQuickbar' );
45 $this->mOldpass = $request->getVal( 'wpOldpass' );
46 $this->mNewpass = $request->getVal( 'wpNewpass' );
47 $this->mRetypePass =$request->getVal( 'wpRetypePass' );
48 $this->mStubs = $request->getVal( 'wpStubs' );
49 $this->mRows = $request->getVal( 'wpRows' );
50 $this->mCols = $request->getVal( 'wpCols' );
51 $this->mSkin = $request->getVal( 'wpSkin' );
52 $this->mMath = $request->getVal( 'wpMath' );
53 $this->mDate = $request->getVal( 'wpDate' );
54 $this->mUserEmail = $request->getVal( 'wpUserEmail' );
55 $this->mRealName = ($wgAllowRealName) ? $request->getVal( 'wpRealName' ) : '';
56 $this->mEmailFlag = $request->getCheck( 'wpEmailFlag' ) ? 1 : 0;
57 $this->mNick = $request->getVal( 'wpNick' );
58 $this->mUserLanguage = $request->getVal( 'wpUserLanguage' );
59 $this->mUserVariant = $request->getVal( 'wpUserVariant' );
60 $this->mSearch = $request->getVal( 'wpSearch' );
61 $this->mRecent = $request->getVal( 'wpRecent' );
62 $this->mHourDiff = $request->getVal( 'wpHourDiff' );
63 $this->mSearchLines = $request->getVal( 'wpSearchLines' );
64 $this->mSearchChars = $request->getVal( 'wpSearchChars' );
65 $this->mImageSize = $request->getVal( 'wpImageSize' );
66
67 $this->mAction = $request->getVal( 'action' );
68 $this->mReset = $request->getCheck( 'wpReset' );
69 $this->mPosted = $request->wasPosted();
70 $this->mSaveprefs = $request->getCheck( 'wpSaveprefs' ) &&
71 $this->mPosted &&
72 $wgUser->matchEditToken( $request->getVal( 'wpEditToken' ) );
73
74 # User toggles (the big ugly unsorted list of checkboxes)
75 $this->mToggles = array();
76 if ( $this->mPosted ) {
77 $togs = $wgLang->getUserToggles();
78 foreach ( $togs as $tname ) {
79 $this->mToggles[$tname] = $request->getCheck( "wpOp$tname" ) ? 1 : 0;
80 }
81 }
82
83 $this->mUsedToggles = array();
84
85 # Search namespace options
86 # Note: namespaces don't necessarily have consecutive keys
87 $this->mSearchNs = array();
88 if ( $this->mPosted ) {
89 $namespaces = $wgContLang->getNamespaces();
90 foreach ( $namespaces as $i => $namespace ) {
91 if ( $i >= 0 ) {
92 $this->mSearchNs[$i] = $request->getCheck( "wpNs$i" ) ? 1 : 0;
93 }
94 }
95 }
96
97 # Validate language
98 if ( !preg_match( '/^[a-z\-]*$/', $this->mUserLanguage ) ) {
99 $this->mUserLanguage = 'nolanguage';
100 }
101 }
102
103 function execute() {
104 global $wgUser, $wgOut;
105
106 if ( $wgUser->isAnon() ) {
107 $wgOut->errorpage( 'prefsnologin', 'prefsnologintext' );
108 return;
109 }
110 if ( wfReadOnly() ) {
111 $wgOut->readOnlyPage();
112 return;
113 }
114 if ( $this->mReset ) {
115 $this->resetPrefs();
116 $this->mainPrefsForm( wfMsg( 'prefsreset' ) );
117 } else if ( $this->mSaveprefs ) {
118 $this->savePreferences();
119 } else {
120 $this->resetPrefs();
121 $this->mainPrefsForm( '' );
122 }
123 }
124
125 /**
126 * @access private
127 */
128 function validateInt( &$val, $min=0, $max=0x7fffffff ) {
129 $val = intval($val);
130 $val = min($val, $max);
131 $val = max($val, $min);
132 return $val;
133 }
134
135 /**
136 * @access private
137 */
138 function validateIntOrNull( &$val, $min=0, $max=0x7fffffff ) {
139 $val = trim($val);
140 if($val === '') {
141 return $val;
142 } else {
143 return $this->validateInt( $val, $min, $max );
144 }
145 }
146
147 /**
148 * Used to validate the user inputed timezone before saving it as
149 * 'timeciorrection', will return '00:00' if fed bogus data.
150 * Note: It's not a 100% correct implementation timezone-wise, it will
151 * accept stuff like '14:30',
152 * @access private
153 * @param string $s the user input
154 * @return string
155 */
156 function validateTimeZone( $s ) {
157 if ( $s !== '' ) {
158 if ( strpos( $s, ':' ) ) {
159 # HH:MM
160 $array = explode( ':' , $s );
161 $hour = intval( $array[0] );
162 $minute = intval( $array[1] );
163 } else {
164 $minute = intval( $s * 60 );
165 $hour = intval( $minute / 60 );
166 $minute = abs( $minute ) % 60;
167 }
168 # Max is +14:00 and min is -12:00, see:
169 # http://en.wikipedia.org/wiki/Timezone
170 $hour = min( $hour, 14 );
171 $hour = max( $hour, -12 );
172 $minute = min( $minute, 59 );
173 $minute = max( $minute, 0 );
174 $s = sprintf( "%02d:%02d", $hour, $minute );
175 }
176 return $s;
177 }
178
179 /**
180 * @access private
181 */
182 function savePreferences() {
183 global $wgUser, $wgLang, $wgOut;
184 global $wgEnableUserEmail, $wgEnableEmail;
185 global $wgEmailAuthentication, $wgMinimalPasswordLength;
186
187 if ( '' != $this->mNewpass ) {
188 if ( $this->mNewpass != $this->mRetypePass ) {
189 $this->mainPrefsForm( wfMsg( 'badretype' ) );
190 return;
191 }
192
193 if ( strlen( $this->mNewpass ) < $wgMinimalPasswordLength ) {
194 $this->mainPrefsForm( wfMsg( 'passwordtooshort', $wgMinimalPasswordLength ) );
195 return;
196 }
197
198 if (!$wgUser->checkPassword( $this->mOldpass )) {
199 $this->mainPrefsForm( wfMsg( 'wrongpassword' ) );
200 return;
201 }
202 $wgUser->setPassword( $this->mNewpass );
203 }
204 $wgUser->setRealName( $this->mRealName );
205 $wgUser->setOption( 'language', $this->mUserLanguage );
206 $wgUser->setOption( 'variant', $this->mUserVariant );
207 $wgUser->setOption( 'nickname', $this->mNick );
208 $wgUser->setOption( 'quickbar', $this->mQuickbar );
209 $wgUser->setOption( 'skin', $this->mSkin );
210 $wgUser->setOption( 'math', $this->mMath );
211 $wgUser->setOption( 'date', $this->mDate );
212 $wgUser->setOption( 'searchlimit', $this->validateIntOrNull( $this->mSearch ) );
213 $wgUser->setOption( 'contextlines', $this->validateIntOrNull( $this->mSearchLines ) );
214 $wgUser->setOption( 'contextchars', $this->validateIntOrNull( $this->mSearchChars ) );
215 $wgUser->setOption( 'rclimit', $this->validateIntOrNull( $this->mRecent ) );
216 $wgUser->setOption( 'rows', $this->validateInt( $this->mRows, 4, 1000 ) );
217 $wgUser->setOption( 'cols', $this->validateInt( $this->mCols, 4, 1000 ) );
218 $wgUser->setOption( 'stubthreshold', $this->validateIntOrNull( $this->mStubs ) );
219 $wgUser->setOption( 'timecorrection', $this->validateTimeZone( $this->mHourDiff, -12, 14 ) );
220 $wgUser->setOption( 'imagesize', $this->mImageSize );
221
222 # Set search namespace options
223 foreach( $this->mSearchNs as $i => $value ) {
224 $wgUser->setOption( "searchNs{$i}", $value );
225 }
226
227 if( $wgEnableEmail && $wgEnableUserEmail ) {
228 $wgUser->setOption( 'disablemail', $this->mEmailFlag );
229 }
230
231 # Set user toggles
232 foreach ( $this->mToggles as $tname => $tvalue ) {
233 $wgUser->setOption( $tname, $tvalue );
234 }
235 $wgUser->setCookies();
236 $wgUser->saveSettings();
237
238 if( $wgEnableEmail ) {
239 $newadr = strtolower( $this->mUserEmail );
240 $oldadr = strtolower($wgUser->getEmail());
241 if (($newadr <> '') && ($newadr <> $oldadr)) { # the user has supplied a new email address on the login page
242 # prepare for authentication and mail a temporary password to newadr
243 require_once( 'SpecialUserlogin.php' );
244 if ( !$wgUser->isValidEmailAddr( $newadr ) ) {
245 $this->mainPrefsForm( wfMsg( 'invalidemailaddress' ) );
246 return;
247 }
248 $wgUser->mEmail = $newadr; # new behaviour: set this new emailaddr from login-page into user database record
249 $wgUser->mEmailAuthenticationtimestamp = 0; # but flag as "dirty" = unauthenticated
250 $wgUser->saveSettings();
251 if ($wgEmailAuthentication) {
252 # mail a temporary password to the dirty address
253 # on "save options", this user will be logged-out automatically
254 $error = LoginForm::mailPasswordInternal( $wgUser, true, $dummy );
255 if ($error === '') {
256 return LoginForm::mainLoginForm( wfMsg( 'passwordsentforemailauthentication', $wgUser->getName() ) );
257 } else {
258 return LoginForm::mainLoginForm( wfMsg( 'mailerror', $error ) );
259 }
260 # if user returns, that new email address gets authenticated in checkpassword()
261 }
262 } else {
263 $wgUser->setEmail( strtolower($this->mUserEmail) );
264 $wgUser->setCookies();
265 $wgUser->saveSettings();
266 }
267 }
268
269 $wgOut->setParserOptions( ParserOptions::newFromUser( $wgUser ) );
270 $po = ParserOptions::newFromUser( $wgUser );
271 $this->mainPrefsForm( wfMsg( 'savedprefs' ) );
272 }
273
274 /**
275 * @access private
276 */
277 function resetPrefs() {
278 global $wgUser, $wgLang, $wgContLang, $wgAllowRealName;
279
280 $this->mOldpass = $this->mNewpass = $this->mRetypePass = '';
281 $this->mUserEmail = $wgUser->getEmail();
282 $this->mUserEmailAuthenticationtimestamp = $wgUser->getEmailAuthenticationtimestamp();
283 $this->mRealName = ($wgAllowRealName) ? $wgUser->getRealName() : '';
284 $this->mUserLanguage = $wgUser->getOption( 'language' );
285 if( empty( $this->mUserLanguage ) ) {
286 # Quick hack for conversions, where this value is blank
287 global $wgContLanguageCode;
288 $this->mUserLanguage = $wgContLanguageCode;
289 }
290 $this->mUserVariant = $wgUser->getOption( 'variant');
291 if ( 1 == $wgUser->getOption( 'disablemail' ) ) { $this->mEmailFlag = 1; }
292 else { $this->mEmailFlag = 0; }
293 $this->mNick = $wgUser->getOption( 'nickname' );
294
295 $this->mQuickbar = $wgUser->getOption( 'quickbar' );
296 $this->mSkin = $wgUser->getOption( 'skin' );
297 $this->mMath = $wgUser->getOption( 'math' );
298 $this->mDate = $wgUser->getOption( 'date' );
299 $this->mRows = $wgUser->getOption( 'rows' );
300 $this->mCols = $wgUser->getOption( 'cols' );
301 $this->mStubs = $wgUser->getOption( 'stubthreshold' );
302 $this->mHourDiff = $wgUser->getOption( 'timecorrection' );
303 $this->mSearch = $wgUser->getOption( 'searchlimit' );
304 $this->mSearchLines = $wgUser->getOption( 'contextlines' );
305 $this->mSearchChars = $wgUser->getOption( 'contextchars' );
306 $this->mImageSize = $wgUser->getOption( 'imagesize' );
307 $this->mRecent = $wgUser->getOption( 'rclimit' );
308
309 $togs = $wgLang->getUserToggles();
310 foreach ( $togs as $tname ) {
311 $ttext = wfMsg('tog-'.$tname);
312 $this->mToggles[$tname] = $wgUser->getOption( $tname );
313 }
314
315 $namespaces = $wgContLang->getNamespaces();
316 foreach ( $namespaces as $i => $namespace ) {
317 if ( $i >= 0 ) {
318 $this->mSearchNs[$i] = $wgUser->getOption( 'searchNs'.$i );
319 }
320 }
321 }
322
323 /**
324 * @access private
325 */
326 function namespacesCheckboxes() {
327 global $wgContLang, $wgUser;
328
329 # Determine namespace checkboxes
330 $namespaces = $wgContLang->getNamespaces();
331 $r1 = '';
332
333 foreach ( $namespaces as $i => $name ) {
334 # Skip special or anything similar
335 if ( $i >= 0 ) {
336 $checked = '';
337 if ( $this->mSearchNs[$i] ) {
338 $checked = ' checked="checked"';
339 }
340 $name = str_replace( '_', ' ', $namespaces[$i] );
341 if ( '' == $name ) {
342 $name = wfMsg( 'blanknamespace' );
343 }
344
345 if ( 0 != $i ) {
346 $r1 .= ' ';
347 }
348 $r1 .= "<label><input type='checkbox' value=\"1\" name=\"" .
349 "wpNs$i\"{$checked} />{$name}</label>\n";
350 }
351 }
352
353 return $r1;
354 }
355
356
357 function getToggle( $tname, $trailer = false) {
358 global $wgUser, $wgLang;
359
360 $this->mUsedToggles[$tname] = true;
361 $ttext = $wgLang->getUserToggle( $tname );
362
363 if ( 1 == $wgUser->getOption( $tname ) ) {
364 $checked = ' checked="checked"';
365 } else {
366 $checked = '';
367 }
368 $trailer =($trailer) ? $trailer : '';
369 return "<div><input type='checkbox' value=\"1\" "
370 . "id=\"$tname\" name=\"wpOp$tname\"$checked /><label for=\"$tname\">$ttext</label>$trailer</div>\n";
371 }
372
373 /**
374 * @access private
375 */
376 function mainPrefsForm( $err ) {
377 global $wgUser, $wgOut, $wgLang, $wgContLang, $wgValidSkinNames;
378 global $wgAllowRealName, $wgImageLimits;
379 global $wgLanguageNames, $wgDisableLangConversion;
380 global $wgEmailNotificationForWatchlistPages, $wgEmailNotificationForUserTalkPages,$wgEmailNotificationForMinorEdits;
381 global $wgRCShowWatchingUsers, $wgEmailNotificationRevealPageEditorAddress;
382 global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
383 global $wgContLanguageCode;
384
385 $wgOut->setPageTitle( wfMsg( 'preferences' ) );
386 $wgOut->setArticleRelated( false );
387 $wgOut->setRobotpolicy( 'noindex,nofollow' );
388
389 if ( '' != $err ) {
390 $wgOut->addHTML( "<p class='error'>" . htmlspecialchars( $err ) . "</p>\n" );
391 }
392 $uname = $wgUser->getName();
393 $uid = $wgUser->getID();
394
395 $wgOut->addWikiText( wfMsg( 'prefslogintext', $uname, $uid ) );
396 $wgOut->addWikiText( wfMsg('clearyourcache'));
397
398 $qbs = $wgLang->getQuickbarSettings();
399 $skinNames = $wgLang->getSkinNames();
400 $mathopts = $wgLang->getMathNames();
401 $dateopts = $wgLang->getDateFormats();
402 $togs = $wgLang->getUserToggles();
403
404 $titleObj = Title::makeTitle( NS_SPECIAL, 'Preferences' );
405 $action = $titleObj->escapeLocalURL();
406
407 $qb = wfMsg( 'qbsettings' );
408 $cp = wfMsg( 'changepassword' );
409 $sk = wfMsg( 'skin' );
410 $math = wfMsg( 'math' );
411 $dateFormat = wfMsg('dateformat');
412 $opw = wfMsg( 'oldpassword' );
413 $npw = wfMsg( 'newpassword' );
414 $rpw = wfMsg( 'retypenew' );
415 $svp = wfMsg( 'saveprefs' );
416 $rsp = wfMsg( 'resetprefs' );
417 $tbs = wfMsg( 'textboxsize' );
418 $tbr = wfMsg( 'rows' );
419 $tbc = wfMsg( 'columns' );
420 $ltz = wfMsg( 'localtime' );
421 $timezone = wfMsg( 'timezonelegend' );
422 $tzt = wfMsg( 'timezonetext' );
423 $tzo = wfMsg( 'timezoneoffset' );
424 $tzGuess = wfMsg( 'guesstimezone' );
425 $tzServerTime = wfMsg( 'servertime' );
426 $yem = wfMsg( 'youremail' );
427 $yrn = ($wgAllowRealName) ? wfMsg( 'yourrealname' ) : '';
428 $yl = wfMsg( 'yourlanguage' );
429 $yv = wfMsg( 'yourvariant' );
430 $emf = wfMsg( 'emailflag' );
431 $ynn = wfMsg( 'yournick' );
432 $stt = wfMsg ( 'stubthreshold' ) ;
433 $srh = wfMsg( 'searchresultshead' );
434 $rpp = wfMsg( 'resultsperpage' );
435 $scl = wfMsg( 'contextlines' );
436 $scc = wfMsg( 'contextchars' );
437 $rcc = wfMsg( 'recentchangescount' );
438 $dsn = wfMsg( 'defaultns' );
439
440 $wgOut->addHTML( "<form id=\"preferences\" name=\"preferences\" action=\"$action\"
441 method=\"post\">" );
442
443 # First section: identity
444 # Email, etc.
445 #
446 $this->mUserEmail = htmlspecialchars( $this->mUserEmail );
447 $this->mRealName = htmlspecialchars( $this->mRealName );
448 $this->mNick = htmlspecialchars( $this->mNick );
449 if ( $this->mEmailFlag ) { $emfc = 'checked="checked"'; }
450 else { $emfc = ''; }
451
452 if ($wgEmailAuthentication && ($this->mUserEmail != '') ) {
453 if ($wgUser->getEmailAuthenticationtimestamp() != 0) {
454 $emailauthenticated = wfMsg('emailauthenticated',$wgLang->timeanddate($wgUser->getEmailAuthenticationtimestamp(), true ) ).'<br />';
455 $disabled = '';
456 } else {
457 $emailauthenticated = wfMsg('emailnotauthenticated').'<br />';
458 $disabled = ' '.wfMsg('disableduntilauthent');
459 }
460 } else {
461 $emailauthenticated = '';
462 }
463
464 if ($this->mUserEmail == '') {
465 $disabled = ' '.wfMsg('disablednoemail');
466 }
467
468 $ps = $this->namespacesCheckboxes();
469
470 $enotifwatchlistpages = ($wgEmailNotificationForWatchlistPages) ? $this->getToggle( 'enotifwatchlistpages', $disabled) : '';
471 $enotifusertalkpages = ($wgEmailNotificationForUserTalkPages) ? $this->getToggle( 'enotifusertalkpages', $disabled) : '';
472 $enotifminoredits = ($wgEmailNotificationForMinorEdits) ? $this->getToggle( 'enotifminoredits', $disabled) : '';
473 $enotifrevealaddr = ($wgEmailNotificationRevealPageEditorAddress) ? $this->getToggle( 'enotifrevealaddr', $disabled) : '';
474 $prefs_help_email_enotif = ( $wgEmailNotificationForWatchlistPages || $wgEmailNotificationForUserTalkPages) ? ' ' . wfMsg('prefs-help-email-enotif') : '';
475 $prefs_help_realname = '';
476
477 $wgOut->addHTML( "<fieldset>
478 <legend>".wfMsg('prefs-personal')."</legend>");
479
480 if ($wgAllowRealName) {
481 $wgOut->addHTML("<div><label>$yrn: <input type='text' name=\"wpRealName\" value=\"{$this->mRealName}\" size='20' /></label></div>");
482 $prefs_help_realname = wfMsg('prefs-help-realname').'<br />';
483 }
484
485 if( $wgEnableEmail ) {
486 $wgOut->addHTML("
487 <div><label>$yem: <input type='text' name=\"wpUserEmail\" value=\"{$this->mUserEmail}\" size='20' /></label></div>" );
488 if( $wgEnableUserEmail ) {
489 $wgOut->addHTML(
490 $emailauthenticated.
491 $enotifrevealaddr.
492 $enotifwatchlistpages.
493 $enotifusertalkpages.
494 $enotifminoredits.
495 "<div><label><input type='checkbox' $emfc value=\"1\" name=\"wpEmailFlag\" />$emf.$disabled</label></div>" );
496 }
497 }
498
499 $fancysig = $this->getToggle( 'fancysig' );
500 $wgOut->addHTML("
501 <div><label>$ynn: <input type='text' name=\"wpNick\" value=\"{$this->mNick}\" size='25' /></label></div>
502 <div>$fancysig<br /></div>
503 <div><label>$yl: <select name=\"wpUserLanguage\">\n");
504
505 /**
506 * If a bogus value is set, default to the content language.
507 * Otherwise, no default is selected and the user ends up
508 * with an Afrikaans interface since it's first in the list.
509 */
510 if( isset( $wgLanguageNames[$this->mUserLanguage] ) ) {
511 $selectedLang = $this->mUserLanguage;
512 } else {
513 $selectedLang = $wgContLanguageCode;
514 }
515 foreach($wgLanguageNames as $code => $name) {
516 global $IP;
517 /* only add languages that have a file */
518 $langfile="$IP/languages/Language".str_replace('-', '_', ucfirst($code)).".php";
519 if(file_exists($langfile) || $code == $wgContLanguageCode) {
520 $sel = ($code == $selectedLang)? 'selected="selected"' : '';
521 $wgOut->addHtml("\t<option value=\"$code\" $sel>$code - $name</option>\n");
522 }
523 }
524 $wgOut->addHtml("</select></label></div>\n" );
525
526 /* see if there are multiple language variants to choose from*/
527 if(!$wgDisableLangConversion) {
528 $variants = $wgContLang->getVariants();
529 $size=sizeof($variants);
530
531 $variantArray=array();
532 foreach($variants as $v) {
533 $v = str_replace( '_', '-', strtolower($v));
534 if($name=$wgLanguageNames[$v]) {
535 $variantArray[$v] = $name;
536 }
537 }
538 $size=sizeof($variantArray);
539
540 if(sizeof($variantArray) > 1) {
541 $wgOut->addHtml("
542 <div><label>$yv: <select name=\"wpUserVariant\">\n");
543 foreach($variantArray as $code => $name) {
544 $sel = ($code==$this->mUserVariant)? 'selected="selected"' : '';
545 $wgOut->addHtml("\t<option value=\"$code\" $sel>$code - $name</option>\n");
546 }
547 }
548 }
549 # Fields for changing password
550 #
551 $this->mOldpass = htmlspecialchars( $this->mOldpass );
552 $this->mNewpass = htmlspecialchars( $this->mNewpass );
553 $this->mRetypePass = htmlspecialchars( $this->mRetypePass );
554
555 $wgOut->addHTML( "<fieldset>
556 <legend>$cp</legend>
557 <div><label>$opw: <input type='password' name=\"wpOldpass\" value=\"{$this->mOldpass}\" size='20' /></label></div>
558 <div><label>$npw: <input type='password' name=\"wpNewpass\" value=\"{$this->mNewpass}\" size='20' /></label></div>
559 <div><label>$rpw: <input type='password' name=\"wpRetypePass\" value=\"{$this->mRetypePass}\" size='20' /></label></div>
560 " . $this->getToggle( "rememberpassword" ) . "
561 </fieldset>
562 <div class='prefsectiontip'>".$prefs_help_realname.wfMsg('prefs-help-email').$prefs_help_email_enotif."</div>\n</fieldset>\n" );
563
564
565 # Quickbar setting
566 #
567 $wgOut->addHtml( "<fieldset>\n<legend>$qb</legend>\n" );
568 for ( $i = 0; $i < count( $qbs ); ++$i ) {
569 if ( $i == $this->mQuickbar ) { $checked = ' checked="checked"'; }
570 else { $checked = ""; }
571 $wgOut->addHTML( "<div><label><input type='radio' name=\"wpQuickbar\"
572 value=\"$i\"$checked /> {$qbs[$i]}</label></div>\n" );
573 }
574 $wgOut->addHtml('<div class="prefsectiontip">'.wfMsg('qbsettingsnote').'</div>');
575 $wgOut->addHtml( "</fieldset>\n\n" );
576
577 # Skin setting
578 #
579 $wgOut->addHTML( "<fieldset>\n<legend>$sk</legend>\n" );
580 # Only show members of $wgValidSkinNames rather than
581 # $skinNames (skins is all skin names from Language.php)
582 foreach ($wgValidSkinNames as $skinkey => $skinname ) {
583 if ( $skinkey == $this->mSkin ) {
584 $checked = ' checked="checked"';
585 } else {
586 $checked = '';
587 }
588 if ( isset( $skinNames[$skinkey] ) ) {
589 $sn = $skinNames[$skinkey];
590 } else {
591 $sn = $skinname;
592 }
593 global $wgDefaultSkin;
594 if( $skinkey == $wgDefaultSkin ) {
595 $sn .= ' (' . wfMsg( 'default' ) . ')';
596 }
597 $wgOut->addHTML( "<div><label><input type='radio' name=\"wpSkin\"
598 value=\"$skinkey\"$checked /> {$sn}</label></div>\n" );
599 }
600 $wgOut->addHTML( "</fieldset>\n\n" );
601
602 # Math setting
603 #
604 $wgOut->addHTML( "<fieldset>\n<legend>$math</legend>\n" );
605 for ( $i = 0; $i < count( $mathopts ); ++$i ) {
606 if ( $i == $this->mMath ) { $checked = ' checked="checked"'; }
607 else { $checked = ""; }
608 $wgOut->addHTML( "<div><label><input type='radio' name=\"wpMath\"
609 value=\"$i\"$checked /> ".wfMsg($mathopts[$i])."</label></div>\n" );
610 }
611 $wgOut->addHTML( "</fieldset>\n\n" );
612
613 # Date format
614 #
615 if ($dateopts) {
616 $wgOut->addHTML( "<fieldset>\n<legend>$dateFormat</legend>\n" );
617 foreach($dateopts as $key => $option) {
618 ($key == $this->mDate) ? $checked = ' checked="checked"' : $checked = '';
619 $wgOut->addHTML( "<div><label><input type='radio' name=\"wpDate\" ".
620 "value=\"$key\"$checked />$option</label></div>\n" );
621 }
622 $wgOut->addHTML( "</fieldset>\n\n");
623 }
624
625 # Textbox rows, cols
626 #
627 $nowlocal = $wgLang->time( $now = wfTimestampNow(), true );
628 $nowserver = $wgLang->time( $now, false );
629 $wgOut->addHTML( "<fieldset>
630 <legend>$tbs</legend>\n
631 <div>
632 <label>$tbr: <input type='text' name=\"wpRows\" value=\"{$this->mRows}\" size='6' /></label>
633 <label>$tbc: <input type='text' name=\"wpCols\" value=\"{$this->mCols}\" size='6' /></label>
634 </div> " .
635 $this->getToggle( "editwidth" ) .
636 $this->getToggle( "showtoolbar" ) .
637 $this->getToggle( "previewonfirst" ) .
638 $this->getToggle( "previewontop" ) .
639 $this->getToggle( "watchdefault" ) .
640 $this->getToggle( "minordefault" ) .
641 $this->getToggle( "externaleditor" ) .
642 "
643 </fieldset>
644
645 <fieldset>
646 <legend>$timezone</legend>
647 <div><b>$tzServerTime:</b> $nowserver</div>
648 <div><b>$ltz:</b> $nowlocal</div>
649 <div><label>$tzo*: <input type='text' name=\"wpHourDiff\" value=\"" . htmlspecialchars( $this->mHourDiff ) . "\" size='6' /></label></div>
650 <div><input type=\"button\" value=\"$tzGuess\" onclick=\"javascript:guessTimezone()\" id=\"guesstimezonebutton\" style=\"display:none\" /></div>
651 <div class='prefsectiontip'>* {$tzt}</div>
652 </fieldset>\n\n" );
653
654 $shownumberswatching = ($wgRCShowWatchingUsers) ? $this->getToggle('shownumberswatching') : '';
655
656 $wgOut->addHTML( "
657 <fieldset><legend>".wfMsg('prefs-rc')."</legend>
658 <div><label>$rcc: <input type='text' name=\"wpRecent\" value=\"$this->mRecent\" size='6' /></label></div>" .
659 $this->getToggle( "hideminor" ) . $shownumberswatching .
660 $this->getToggle( "usenewrc" ) . $this->getToggle('showupdated', wfMsg('updatedmarker')) .
661 "<div><label>$stt: <input type='text' name=\"wpStubs\" value=\"$this->mStubs\" size='6' /></label></div>
662 <div><label>".wfMsg('imagemaxsize')."<select name=\"wpImageSize\">");
663
664 $imageLimitOptions='';
665 foreach ( $wgImageLimits as $index => $limits ) {
666 $selected = ($index == $this->mImageSize) ? 'selected="selected"' : '';
667 $imageLimitOptions .= "<option value=\"{$index}\" {$selected}>{$limits[0]}x{$limits[1]}</option>\n";
668 }
669 $wgOut->addHTML( "{$imageLimitOptions}</select></label></div>
670
671 </fieldset>
672
673 <fieldset>
674 <legend>$srh</legend>
675 <div><label>$rpp: <input type='text' name=\"wpSearch\" value=\"$this->mSearch\" size='6' /></label></div>
676 <div><label>$scl: <input type='text' name=\"wpSearchLines\" value=\"$this->mSearchLines\" size='6' /></label></div>
677 <div><label>$scc: <input type='text' name=\"wpSearchChars\" value=\"$this->mSearchChars\" size='6' /></label></div>
678
679 <fieldset>
680 <legend>$dsn</legend>
681 $ps
682 </fieldset>
683 </fieldset>
684 " );
685
686 # Various checkbox options
687 #
688 $wgOut->addHTML("<fieldset><legend>".wfMsg('prefs-misc')."</legend>");
689 foreach ( $togs as $tname ) {
690 if( !array_key_exists( $tname, $this->mUsedToggles ) ) {
691 $wgOut->addHTML( $this->getToggle( $tname ) );
692 }
693 }
694 $wgOut->addHTML( "</fieldset>\n\n" );
695
696 $token = htmlspecialchars( $wgUser->editToken() );
697 $wgOut->addHTML( "
698 <div id='prefsubmit'>
699 <div>
700 <input type='submit' name=\"wpSaveprefs\" value=\"$svp\" accesskey=\"".
701 wfMsg('accesskey-save')."\" title=\"[alt-".wfMsg('accesskey-save')."]\" />
702 <input type='submit' name=\"wpReset\" value=\"$rsp\" />
703 </div>
704
705 </div>
706
707 <input type='hidden' name='wpEditToken' value=\"{$token}\" />
708 </form>\n" );
709 }
710 }
711 ?>