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