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