* (bug 2262) Hide math preferences when TeX is not enabled
[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 /**
12 * Entry point that create the "Preferences" object
13 */
14 function wfSpecialPreferences() {
15 global $wgRequest;
16
17 $form = new PreferencesForm( $wgRequest );
18 $form->execute();
19 }
20
21 /**
22 * Preferences form handling
23 * This object will show the preferences form and can save it as well.
24 * @package MediaWiki
25 * @subpackage SpecialPage
26 */
27 class PreferencesForm {
28 var $mQuickbar, $mOldpass, $mNewpass, $mRetypePass, $mStubs;
29 var $mRows, $mCols, $mSkin, $mMath, $mDate, $mUserEmail, $mEmailFlag, $mNick;
30 var $mUserLanguage, $mUserVariant;
31 var $mSearch, $mRecent, $mHourDiff, $mSearchLines, $mSearchChars, $mAction;
32 var $mReset, $mPosted, $mToggles, $mSearchNs, $mRealName, $mImageSize;
33
34 /**
35 * Constructor
36 * Load some values
37 */
38 function PreferencesForm( &$request ) {
39 global $wgLang, $wgContLang, $wgUser, $wgAllowRealName;
40
41 $this->mQuickbar = $request->getVal( 'wpQuickbar' );
42 $this->mOldpass = $request->getVal( 'wpOldpass' );
43 $this->mNewpass = $request->getVal( 'wpNewpass' );
44 $this->mRetypePass =$request->getVal( 'wpRetypePass' );
45 $this->mStubs = $request->getVal( 'wpStubs' );
46 $this->mRows = $request->getVal( 'wpRows' );
47 $this->mCols = $request->getVal( 'wpCols' );
48 $this->mSkin = $request->getVal( 'wpSkin' );
49 $this->mMath = $request->getVal( 'wpMath' );
50 $this->mDate = $request->getVal( 'wpDate' );
51 $this->mUserEmail = $request->getVal( 'wpUserEmail' );
52 $this->mRealName = $wgAllowRealName ? $request->getVal( 'wpRealName' ) : '';
53 $this->mEmailFlag = $request->getCheck( 'wpEmailFlag' ) ? 1 : 0;
54 $this->mNick = $request->getVal( 'wpNick' );
55 $this->mUserLanguage = $request->getVal( 'wpUserLanguage' );
56 $this->mUserVariant = $request->getVal( 'wpUserVariant' );
57 $this->mSearch = $request->getVal( 'wpSearch' );
58 $this->mRecent = $request->getVal( 'wpRecent' );
59 $this->mHourDiff = $request->getVal( 'wpHourDiff' );
60 $this->mSearchLines = $request->getVal( 'wpSearchLines' );
61 $this->mSearchChars = $request->getVal( 'wpSearchChars' );
62 $this->mImageSize = $request->getVal( 'wpImageSize' );
63 $this->mThumbSize = $request->getInt( 'wpThumbSize' );
64 $this->mAction = $request->getVal( 'action' );
65 $this->mReset = $request->getCheck( 'wpReset' );
66 $this->mPosted = $request->wasPosted();
67 $this->mSaveprefs = $request->getCheck( 'wpSaveprefs' ) &&
68 $this->mPosted &&
69 $wgUser->matchEditToken( $request->getVal( 'wpEditToken' ) );
70
71 # User toggles (the big ugly unsorted list of checkboxes)
72 $this->mToggles = array();
73 if ( $this->mPosted ) {
74 $togs = $wgLang->getUserToggles();
75 foreach ( $togs as $tname ) {
76 $this->mToggles[$tname] = $request->getCheck( "wpOp$tname" ) ? 1 : 0;
77 }
78 }
79
80 $this->mUsedToggles = array();
81
82 # Search namespace options
83 # Note: namespaces don't necessarily have consecutive keys
84 $this->mSearchNs = array();
85 if ( $this->mPosted ) {
86 $namespaces = $wgContLang->getNamespaces();
87 foreach ( $namespaces as $i => $namespace ) {
88 if ( $i >= 0 ) {
89 $this->mSearchNs[$i] = $request->getCheck( "wpNs$i" ) ? 1 : 0;
90 }
91 }
92 }
93
94 # Validate language
95 if ( !preg_match( '/^[a-z\-]*$/', $this->mUserLanguage ) ) {
96 $this->mUserLanguage = 'nolanguage';
97 }
98 }
99
100 function execute() {
101 global $wgUser, $wgOut;
102
103 if ( $wgUser->isAnon() ) {
104 $wgOut->errorpage( 'prefsnologin', 'prefsnologintext' );
105 return;
106 }
107 if ( wfReadOnly() ) {
108 $wgOut->readOnlyPage();
109 return;
110 }
111 if ( $this->mReset ) {
112 $this->resetPrefs();
113 $this->mainPrefsForm( wfMsg( 'prefsreset' ) );
114 } else if ( $this->mSaveprefs ) {
115 $this->savePreferences();
116 } else {
117 $this->resetPrefs();
118 $this->mainPrefsForm( '' );
119 }
120 }
121
122 /**
123 * @access private
124 */
125 function validateInt( &$val, $min=0, $max=0x7fffffff ) {
126 $val = intval($val);
127 $val = min($val, $max);
128 $val = max($val, $min);
129 return $val;
130 }
131
132 /**
133 * @access private
134 */
135 function validateIntOrNull( &$val, $min=0, $max=0x7fffffff ) {
136 $val = trim($val);
137 if($val === '') {
138 return $val;
139 } else {
140 return $this->validateInt( $val, $min, $max );
141 }
142 }
143
144 /**
145 * Used to validate the user inputed timezone before saving it as
146 * 'timeciorrection', will return '00:00' if fed bogus data.
147 * Note: It's not a 100% correct implementation timezone-wise, it will
148 * accept stuff like '14:30',
149 * @access private
150 * @param string $s the user input
151 * @return string
152 */
153 function validateTimeZone( $s ) {
154 if ( $s !== '' ) {
155 if ( strpos( $s, ':' ) ) {
156 # HH:MM
157 $array = explode( ':' , $s );
158 $hour = intval( $array[0] );
159 $minute = intval( $array[1] );
160 } else {
161 $minute = intval( $s * 60 );
162 $hour = intval( $minute / 60 );
163 $minute = abs( $minute ) % 60;
164 }
165 # Max is +14:00 and min is -12:00, see:
166 # http://en.wikipedia.org/wiki/Timezone
167 $hour = min( $hour, 14 );
168 $hour = max( $hour, -12 );
169 $minute = min( $minute, 59 );
170 $minute = max( $minute, 0 );
171 $s = sprintf( "%02d:%02d", $hour, $minute );
172 }
173 return $s;
174 }
175
176 /**
177 * @access private
178 */
179 function savePreferences() {
180 global $wgUser, $wgLang, $wgOut;
181 global $wgEnableUserEmail, $wgEnableEmail;
182 global $wgEmailAuthentication, $wgMinimalPasswordLength;
183
184 if ( '' != $this->mNewpass ) {
185 if ( $this->mNewpass != $this->mRetypePass ) {
186 $this->mainPrefsForm( wfMsg( 'badretype' ) );
187 return;
188 }
189
190 if ( strlen( $this->mNewpass ) < $wgMinimalPasswordLength ) {
191 $this->mainPrefsForm( wfMsg( 'passwordtooshort', $wgMinimalPasswordLength ) );
192 return;
193 }
194
195 if (!$wgUser->checkPassword( $this->mOldpass )) {
196 $this->mainPrefsForm( wfMsg( 'wrongpassword' ) );
197 return;
198 }
199 $wgUser->setPassword( $this->mNewpass );
200 }
201 $wgUser->setRealName( $this->mRealName );
202 $wgUser->setOption( 'language', $this->mUserLanguage );
203 $wgUser->setOption( 'variant', $this->mUserVariant );
204 $wgUser->setOption( 'nickname', $this->mNick );
205 $wgUser->setOption( 'quickbar', $this->mQuickbar );
206 $wgUser->setOption( 'skin', $this->mSkin );
207 global $wgUseTeX;
208 if( $wgUseTeX ) {
209 $wgUser->setOption( 'math', $this->mMath );
210 }
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 $wgUser->setOption( 'thumbsize', $this->mThumbSize );
222
223 # Set search namespace options
224 foreach( $this->mSearchNs as $i => $value ) {
225 $wgUser->setOption( "searchNs{$i}", $value );
226 }
227
228 if( $wgEnableEmail && $wgEnableUserEmail ) {
229 $wgUser->setOption( 'disablemail', $this->mEmailFlag );
230 }
231
232 # Set user toggles
233 foreach ( $this->mToggles as $tname => $tvalue ) {
234 $wgUser->setOption( $tname, $tvalue );
235 }
236 $wgUser->setCookies();
237 $wgUser->saveSettings();
238
239 $error = wfMsg( 'savedprefs' );
240 if( $wgEnableEmail ) {
241 $newadr = $this->mUserEmail;
242 $oldadr = $wgUser->getEmail();
243 if( ($newadr != '') && ($newadr != $oldadr) ) {
244 # the user has supplied a new email address on the login page
245 if( $wgUser->isValidEmailAddr( $newadr ) ) {
246 $wgUser->mEmail = $newadr; # new behaviour: set this new emailaddr from login-page into user database record
247 $wgUser->mEmailAuthenticated = null; # but flag as "dirty" = unauthenticated
248 $wgUser->saveSettings();
249 if ($wgEmailAuthentication) {
250 # Mail a temporary password to the dirty address.
251 # User can come back through the confirmation URL to re-enable email.
252 $result = $wgUser->sendConfirmationMail();
253 if( WikiError::isError( $result ) ) {
254 $error = wfMsg( 'mailerror', $result->toString() );
255 } else {
256 $error = wfMsg( 'eauthentsent', $wgUser->getName() );
257 }
258 }
259 } else {
260 $error = wfMsg( 'invalidemailaddress' );
261 }
262 } else {
263 $wgUser->setEmail( $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( $error );
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 $this->mEmailFlag = $wgUser->getOption( 'disablemail' ) == 1 ? 1 : 0;
292 $this->mNick = $wgUser->getOption( 'nickname' );
293
294 $this->mQuickbar = $wgUser->getOption( 'quickbar' );
295 $this->mSkin = $wgUser->getOption( 'skin' );
296 $this->mMath = $wgUser->getOption( 'math' );
297 $this->mDate = $wgUser->getOption( 'date' );
298 $this->mRows = $wgUser->getOption( 'rows' );
299 $this->mCols = $wgUser->getOption( 'cols' );
300 $this->mStubs = $wgUser->getOption( 'stubthreshold' );
301 $this->mHourDiff = $wgUser->getOption( 'timecorrection' );
302 $this->mSearch = $wgUser->getOption( 'searchlimit' );
303 $this->mSearchLines = $wgUser->getOption( 'contextlines' );
304 $this->mSearchChars = $wgUser->getOption( 'contextchars' );
305 $this->mImageSize = $wgUser->getOption( 'imagesize' );
306 $this->mThumbSize = $wgUser->getOption( 'thumbsize' );
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 >= NS_MAIN ) {
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 = null;
332
333 foreach ( $namespaces as $i => $name ) {
334 if ($i < 0)
335 continue;
336 $checked = $this->mSearchNs[$i] ? "checked='checked'" : '';
337 $name = str_replace( '_', ' ', $namespaces[$i] );
338
339 if ( empty($name) )
340 $name = wfMsg( 'blanknamespace' );
341
342 $r1 .= "<label><input type='checkbox' value='1' name='wpNs$i' {$checked}/>{$name}</label>\n";
343 }
344 return $r1;
345 }
346
347
348 function getToggle( $tname, $trailer = false) {
349 global $wgUser, $wgLang;
350
351 $this->mUsedToggles[$tname] = true;
352 $ttext = $wgLang->getUserToggle( $tname );
353
354 $checked = $wgUser->getOption( $tname ) == 1 ? ' checked="checked"' : '';
355 $trailer = $trailer ? $trailer : '';
356 return "<div class='toggle'><input type='checkbox' value='1' id=\"$tname\" name=\"wpOp$tname\"$checked />" .
357 " <span class='toggletext'><label for=\"$tname\">$ttext</label>$trailer</span></div>";
358 }
359
360 function getToggles( $items ) {
361 $out = "";
362 foreach( $items as $item ) {
363 if( $item === false )
364 continue;
365 if( is_array( $item ) ) {
366 list( $key, $trailer ) = $item;
367 } else {
368 $key = $item;
369 $trailer = false;
370 }
371 $out .= $this->getToggle( $key, $trailer );
372 }
373 return $out;
374 }
375
376 function addRow($td1, $td2) {
377 return "<tr><td align='right'>$td1</td><td align='left'>$td2</td></tr>";
378 }
379
380 /**
381 * @access private
382 */
383 function mainPrefsForm( $err ) {
384 global $wgUser, $wgOut, $wgLang, $wgContLang, $wgValidSkinNames;
385 global $wgAllowRealName, $wgImageLimits, $wgThumbLimits;
386 global $wgDisableLangConversion;
387 global $wgEnotifWatchlist, $wgEnotifUserTalk,$wgEnotifMinorEdits;
388 global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress;
389 global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
390 global $wgContLanguageCode, $wgDefaultSkin, $wgSkipSkins;
391
392 $wgOut->setPageTitle( wfMsg( 'preferences' ) );
393 $wgOut->setArticleRelated( false );
394 $wgOut->setRobotpolicy( 'noindex,nofollow' );
395
396 if ( '' != $err ) {
397 $wgOut->addHTML( "<p class='error'>" . htmlspecialchars( $err ) . "</p>\n" );
398 }
399 $uname = $wgUser->getName();
400 $uid = $wgUser->getID();
401
402 $wgOut->addWikiText( wfMsg( 'prefslogintext', $uname, $uid ) );
403 $wgOut->addWikiText( wfMsg('clearyourcache'));
404
405 $qbs = $wgLang->getQuickbarSettings();
406 $skinNames = $wgLang->getSkinNames();
407 $mathopts = $wgLang->getMathNames();
408 $dateopts = $wgLang->getDateFormats();
409 $togs = $wgLang->getUserToggles();
410
411 $titleObj = Title::makeTitle( NS_SPECIAL, 'Preferences' );
412 $action = $titleObj->escapeLocalURL();
413
414
415 # Enotif
416 # <FIXME>
417 $this->mUserEmail = htmlspecialchars( $this->mUserEmail );
418 $this->mRealName = htmlspecialchars( $this->mRealName );
419 $this->mNick = htmlspecialchars( $this->mNick );
420 if ( $this->mEmailFlag ) { $emfc = 'checked="checked"'; }
421 else { $emfc = ''; }
422
423 if ($wgEmailAuthentication && ($this->mUserEmail != '') ) {
424 if( $wgUser->getEmailAuthenticationTimestamp() ) {
425 $emailauthenticated = wfMsg('emailauthenticated',$wgLang->timeanddate($wgUser->getEmailAuthenticationTimestamp(), true ) ).'<br />';
426 } else {
427 $skin = $wgUser->getSkin();
428 $emailauthenticated = wfMsg('emailnotauthenticated').'<br />' .
429 $skin->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Confirmemail' ),
430 wfMsg( 'emailconfirmlink' ) );
431 }
432 } else {
433 $emailauthenticated = '';
434 }
435
436 if ($this->mUserEmail == '') {
437 $emailauthenticated = wfMsg( 'noemailprefs' );
438 }
439
440 $ps = $this->namespacesCheckboxes();
441
442 $enotifwatchlistpages = ($wgEnotifWatchlist) ? $this->getToggle( 'enotifwatchlistpages' ) : '';
443 $enotifusertalkpages = ($wgEnotifUserTalk) ? $this->getToggle( 'enotifusertalkpages' ) : '';
444 $enotifminoredits = ($wgEnotifWatchlist && $wgEnotifMinorEdits) ? $this->getToggle( 'enotifminoredits' ) : '';
445 $enotifrevealaddr = (($wgEnotifWatchlist || $wgEnotifUserTalk) && $wgEnotifRevealEditorAddress) ? $this->getToggle( 'enotifrevealaddr' ) : '';
446 $prefs_help_email_enotif = ( $wgEnotifWatchlist || $wgEnotifUserTalk) ? ' ' . wfMsg('prefs-help-email-enotif') : '';
447 $prefs_help_realname = '';
448
449 # </FIXME>
450
451 $wgOut->addHTML( "<form id='preferences' name='preferences' action=\"$action\" method='post'>" );
452
453 # User data
454 #
455
456 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('prefs-personal') . "</legend>\n<table>\n");
457
458 if ($wgAllowRealName) {
459 $wgOut->addHTML(
460 $this->addRow(
461 wfMsg('yourrealname'),
462 "<input type='text' name='wpRealName' value=\"{$this->mRealName}\" size='25' />"
463 )
464 );
465 }
466 if ($wgEnableEmail) {
467 $wgOut->addHTML(
468 $this->addRow(
469 wfMsg( 'youremail' ),
470 "<input type='text' name='wpUserEmail' value=\"{$this->mUserEmail}\" size='25' />"
471 )
472 );
473 }
474
475 $wgOut->addHTML(
476 $this->addRow(
477 wfMsg( 'yournick' ),
478 "<input type='text' name='wpNick' value=\"{$this->mNick}\" size='25' />"
479 ) .
480 # FIXME: The <input> part should be where the &nbsp; is, getToggle() needs
481 # to be changed to out return its output in two parts. -รฆvar
482 $this->addRow(
483 '&nbsp;',
484 $this->getToggle( 'fancysig' )
485 )
486 );
487
488 /**
489 * If a bogus value is set, default to the content language.
490 * Otherwise, no default is selected and the user ends up
491 * with an Afrikaans interface since it's first in the list.
492 */
493 $languages = $wgLang->getLanguageNames();
494 $selectedLang = isset( $languages[$this->mUserLanguage] ) ? $this->mUserLanguage : $wgContLanguageCode;
495 $selbox = null;
496 foreach($languages as $code => $name) {
497 global $IP;
498 /* only add languages that have a file */
499 $langfile="$IP/languages/Language".str_replace('-', '_', ucfirst($code)).".php";
500 if(file_exists($langfile) || $code == $wgContLanguageCode) {
501 $sel = ($code == $selectedLang)? ' selected="selected"' : '';
502 $selbox .= "<option value=\"$code\"$sel>$code - $name</option>\n";
503 }
504 }
505 $wgOut->addHTML( $this->addRow( wfMsg('yourlanguage'), "<select name='wpUserLanguage'>$selbox</select>" ));
506
507 /* see if there are multiple language variants to choose from*/
508 if(!$wgDisableLangConversion) {
509 $variants = $wgContLang->getVariants();
510
511 foreach($variants as $v) {
512 $v = str_replace( '_', '-', strtolower($v));
513 if($name = $languages[$v]) {
514 $variantArray[$v] = $name;
515 }
516 }
517
518 $selbox = null;
519 foreach($variantArray as $code => $name) {
520 $sel = $code == $this->mUserVariant ? 'selected="selected"' : '';
521 $selbox .= "<option value=\"$code\" $sel>$code - $name</option>";
522 }
523
524 if(count($variantArray) > 1) {
525 $wgOut->addHtml(
526 $this->addRow( wfMsg( 'yourvariant' ), "<select name='wpUserVariant'>$selbox</select>" )
527 );
528 }
529 }
530 $wgOut->addHTML('</table>');
531
532 # Password
533 $this->mOldpass = htmlspecialchars( $this->mOldpass );
534 $this->mNewpass = htmlspecialchars( $this->mNewpass );
535 $this->mRetypePass = htmlspecialchars( $this->mRetypePass );
536
537 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'changepassword' ) . '</legend><table>');
538 $wgOut->addHTML(
539 $this->addRow( wfMsg( 'oldpassword' ), "<input type='password' name='wpOldpass' value=\"{$this->mOldpass}\" size='20' />" ) .
540 $this->addRow( wfMsg( 'newpassword' ), "<input type='password' name='wpNewpass' value=\"{$this->mNewpass}\" size='20' />" ) .
541 $this->addRow( wfMsg( 'retypenew' ), "<input type='password' name='wpRetypePass' value=\"{$this->mRetypePass}\" size='20' />" ) .
542 "</table>\n" .
543 $this->getToggle( "rememberpassword" ) . "</fieldset>\n\n" );
544
545 # <FIXME>
546 # Enotif
547 if ($wgEnableEmail) {
548 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'email' ) . '</legend>' );
549 $wgOut->addHTML(
550 $emailauthenticated.
551 $enotifrevealaddr.
552 $enotifwatchlistpages.
553 $enotifusertalkpages.
554 $enotifminoredits );
555 if ($wgEnableUserEmail) {
556 $emf = wfMsg( 'emailflag' );
557 $wgOut->addHTML(
558 "<div><label><input type='checkbox' $emfc value=\"1\" name=\"wpEmailFlag\" />$emf</label></div>" );
559 }
560
561 $wgOut->addHTML( '</fieldset>' );
562 }
563 # </FIXME>
564
565 if ($wgAllowRealName || $wgEnableEmail) {
566 $wgOut->addHTML("<div class='prefsectiontip'>");
567 $rn = $wgAllowRealName ? wfMsg('prefs-help-realname') : '';
568 $em = $wgEnableEmail ? '<br />' . wfMsg('prefs-help-email') : '';
569 $wgOut->addHTML( $rn . $em . '</div>');
570 }
571
572 $wgOut->addHTML( '</fieldset>' );
573
574 # Quickbar
575 #
576 if ($this->mSkin == 'cologneblue' || $this->mSkin == 'standard') {
577 $wgOut->addHtml( "<fieldset>\n<legend>" . wfMsg( 'qbsettings' ) . "</legend>\n" );
578 for ( $i = 0; $i < count( $qbs ); ++$i ) {
579 if ( $i == $this->mQuickbar ) { $checked = ' checked="checked"'; }
580 else { $checked = ""; }
581 $wgOut->addHTML( "<div><label><input type='radio' name='wpQuickbar' value=\"$i\"$checked />{$qbs[$i]}</label></div>\n" );
582 }
583 $wgOut->addHtml( "</fieldset>\n\n" );
584 }
585
586 # Skin
587 #
588 $wgOut->addHTML( "<fieldset>\n<legend>\n" . wfMsg('skin') . "</legend>\n" );
589 # Only show members of $wgValidSkinNames rather than
590 # $skinNames (skins is all skin names from Language.php)
591 foreach ($wgValidSkinNames as $skinkey => $skinname ) {
592 if ( in_array( $skinkey, $wgSkipSkins ) ) {
593 continue;
594 }
595 $checked = $skinkey == $this->mSkin ? ' checked="checked"' : '';
596 $sn = isset( $skinNames[$skinkey] ) ? $skinNames[$skinkey] : $skinname;
597
598 if( $skinkey == $wgDefaultSkin )
599 $sn .= ' (' . wfMsg( 'default' ) . ')';
600 $wgOut->addHTML( "<input type='radio' name='wpSkin' value=\"$skinkey\"$checked /> {$sn}<br/>\n" );
601 }
602 $wgOut->addHTML( "</fieldset>\n\n" );
603
604 # Math
605 #
606 global $wgUseTeX;
607 if( $wgUseTeX ) {
608 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('math') . '</legend>' );
609 foreach ( $mathopts as $k => $v ) {
610 $checked = $k == $this->mMath ? ' checked="checked"' : '';
611 $wgOut->addHTML( "<div><label><input type='radio' name='wpMath' value=\"$k\"$checked /> ".wfMsg($v)."</label></div>\n" );
612 }
613 $wgOut->addHTML( "</fieldset>\n\n" );
614 }
615
616 # Files
617 #
618 $wgOut->addHTML("<fieldset>
619 <legend>" . wfMsg( 'files' ) . "</legend>
620 <div><label>" . wfMsg('imagemaxsize') . "<select name=\"wpImageSize\">");
621
622 $imageLimitOptions = null;
623 foreach ( $wgImageLimits as $index => $limits ) {
624 $selected = ($index == $this->mImageSize) ? 'selected="selected"' : '';
625 $imageLimitOptions .= "<option value=\"{$index}\" {$selected}>{$limits[0]}x{$limits[1]}</option>\n";
626 }
627
628 $imageThumbOptions = null;
629 $wgOut->addHTML( "{$imageLimitOptions}</select></label></div>
630 <div><label>" . wfMsg('thumbsize') . "<select name=\"wpThumbSize\">");
631 foreach ( $wgThumbLimits as $index => $size ) {
632 $selected = ($index == $this->mThumbSize) ? 'selected="selected"' : '';
633 $imageThumbOptions .= "<option value=\"{$index}\" {$selected}>{$size}px</option>\n";
634 }
635 $wgOut->addHTML( "{$imageThumbOptions}</select></label></div></fieldset>\n\n");
636
637 # Date format
638 #
639 if ($dateopts) {
640 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('dateformat') . "</legend>\n" );
641 foreach($dateopts as $key => $option) {
642 ($key == $this->mDate) ? $checked = ' checked="checked"' : $checked = '';
643 $wgOut->addHTML( "<div><label><input type='radio' name=\"wpDate\" ".
644 "value=\"$key\"$checked />$option</label></div>\n" );
645 }
646 $wgOut->addHTML( "</fieldset>\n\n");
647 }
648
649 # Time zone
650 #
651
652 $nowlocal = $wgLang->time( $now = wfTimestampNow(), true );
653 $nowserver = $wgLang->time( $now, false );
654
655 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'timezonelegend' ) . '</legend><table>' .
656 $this->addRow( wfMsg( 'servertime' ), $nowserver ) .
657 $this->addRow( wfMsg( 'localtime' ), $nowlocal ) .
658 $this->addRow(
659 wfMsg( 'timezoneoffset' ),
660 "<input type='text' name='wpHourDiff' value=\"" . htmlspecialchars( $this->mHourDiff ) . "\" size='6' />"
661 ) . "<tr><td colspan='2'>
662 <input type='button' value=\"" . wfMsg( 'guesstimezone' ) ."\"
663 onclick='javascript:guessTimezone()' id='guesstimezonebutton' style='display:none;' />
664 </td></tr></table>
665 <div class='prefsectiontip'>ยน" . wfMsg( 'timezonetext' ) . "</div>
666 </fieldset>\n\n" );
667
668 # Editing
669 #
670 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'textboxsize' ) . '</legend>
671 <div>
672 <label>' . wfMsg( 'rows' ) . ": <input type='text' name='wpRows' value=\"{$this->mRows}\" size='6' /></label>
673 <label>" . wfMsg( 'columns' ) . ": <input type='text' name='wpCols' value=\"{$this->mCols}\" size='6' /></label>
674 </div>" .
675 $this->getToggles( array(
676 'editsection',
677 'editsectiononrightclick',
678 'editondblclick',
679 'editwidth',
680 'showtoolbar',
681 'previewonfirst',
682 'previewontop',
683 'watchdefault',
684 'minordefault',
685 'externaleditor',
686 'externaldiff' )
687 ) . '</fieldset>'
688 );
689
690 $wgOut->addHTML( '<fieldset><legend>' . htmlspecialchars(wfMsg('prefs-rc')) . '</legend>
691 <table>' .
692 $this->addRow(
693 wfMsg ( 'stubthreshold' ),
694 "<input type='text' name=\"wpStubs\" value=\"$this->mStubs\" size='6' />"
695 ) .
696 $this->addRow(
697 wfMsg( 'recentchangescount' ),
698 "<input type='text' name='wpRecent' value=\"$this->mRecent\" size='6' />"
699 ) .
700 '</table>' .
701 $this->getToggles( array(
702 'hideminor',
703 $wgRCShowWatchingUsers ? 'shownumberswatching' : false,
704 'usenewrc',
705 'rcusemodstyle' )
706 ) . '</fieldset>'
707 );
708
709 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'searchresultshead' ) . '</legend><table>' .
710 $this->addRow( wfMsg( 'resultsperpage' ), "<input type='text' name='wpSearch' value=\"$this->mSearch\" size='4' />" ) .
711 $this->addRow( wfMsg( 'contextlines' ), "<input type='text' name='wpSearchLines' value=\"$this->mSearchLines\" size='4' />" ) .
712 $this->addRow( wfMsg( 'contextchars' ), "<input type='text' name='wpSearchChars' value=\"$this->mSearchChars\" size='4' />" ) .
713 "</table><fieldset><legend>" . wfMsg( 'defaultns' ) . "</legend>$ps</fieldset></fieldset>" );
714
715 # Misc
716 #
717 $wgOut->addHTML('<fieldset><legend>' . wfMsg('prefs-misc') . '</legend>');
718
719 foreach ( $togs as $tname ) {
720 if( !array_key_exists( $tname, $this->mUsedToggles ) ) {
721 $wgOut->addHTML( $this->getToggle( $tname ) );
722 }
723 }
724 $wgOut->addHTML( '</fieldset>' );
725
726 $token = $wgUser->editToken();
727 $wgOut->addHTML( "
728 <div id='prefsubmit'>
729 <div>
730 <input type='submit' name='wpSaveprefs' value=\"" . wfMsg( 'saveprefs' ) . "\" accesskey=\"".
731 wfMsg('accesskey-save')."\" title=\"[alt-".wfMsg('accesskey-save')."]\" />
732 <input type='submit' name='wpReset' value=\"" . wfMsg( 'resetprefs' ) . "\" />
733 </div>
734
735 </div>
736
737 <input type='hidden' name='wpEditToken' value='{$token}' />
738 </form>\n" );
739 }
740 }
741 ?>