* Fixed a bug where moving a page would cause the following SQL error when
[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 $this->mThumbSize = $request->getInt( 'wpThumbSize' );
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 $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 $wgLanguageNames, $wgDisableLangConversion;
387 global $wgEnotifWatchlist, $wgEnotifUserTalk,$wgEnotifMinorEdits;
388 global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress;
389 global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
390 global $wgContLanguageCode;
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 = ($wgEnotifMinorEdits) ? $this->getToggle( 'enotifminoredits' ) : '';
445 $enotifrevealaddr = ($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 $selectedLang = isset( $wgLanguageNames[$this->mUserLanguage] ) ? $this->mUserLanguage : $wgContLanguageCode;
494 $selbox = null;
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 $selbox .= "<option value=\"$code\"$sel>$code - $name</option>\n";
502 }
503 }
504 $wgOut->addHTML( $this->addRow( wfMsg('yourlanguage'), "<select name='wpUserLanguage'>$selbox</select>" ));
505
506 /* see if there are multiple language variants to choose from*/
507 if(!$wgDisableLangConversion) {
508 $variants = $wgContLang->getVariants();
509
510 foreach($variants as $v) {
511 $v = str_replace( '_', '-', strtolower($v));
512 if($name = $wgLanguageNames[$v]) {
513 $variantArray[$v] = $name;
514 }
515 }
516
517 $selbox = null;
518 foreach($variantArray as $code => $name) {
519 $sel = $code == $this->mUserVariant ? 'selected="selected"' : '';
520 $selbox .= "<option value=\"$code\" $sel>$code - $name</option>";
521 }
522
523 if(count($variantArray) > 1) {
524 $wgOut->addHtml(
525 $this->addRow( wfMsg( 'yourvariant' ), "<select name='wpUserVariant'>$selbox</select>" )
526 );
527 }
528 }
529 $wgOut->addHTML('</table>');
530
531 # Password
532 $this->mOldpass = htmlspecialchars( $this->mOldpass );
533 $this->mNewpass = htmlspecialchars( $this->mNewpass );
534 $this->mRetypePass = htmlspecialchars( $this->mRetypePass );
535
536 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'changepassword' ) . '</legend><table>');
537 $wgOut->addHTML(
538 $this->addRow( wfMsg( 'oldpassword' ), "<input type='password' name='wpOldpass' value=\"{$this->mOldpass}\" size='20' />" ) .
539 $this->addRow( wfMsg( 'newpassword' ), "<input type='password' name='wpNewpass' value=\"{$this->mNewpass}\" size='20' />" ) .
540 $this->addRow( wfMsg( 'retypenew' ), "<input type='password' name='wpRetypePass' value=\"{$this->mRetypePass}\" size='20' />" ) .
541 "</table>\n" .
542 $this->getToggle( "rememberpassword" ) . "</fieldset>\n\n" );
543
544 # <FIXME>
545 # Enotif
546 if ($wgEnableEmail) {
547 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'email' ) . '</legend>' );
548 $wgOut->addHTML(
549 $emailauthenticated.
550 $enotifrevealaddr.
551 $enotifwatchlistpages.
552 $enotifusertalkpages.
553 $enotifminoredits );
554 if ($wgEnableUserEmail) {
555 $emf = wfMsg( 'emailflag' );
556 $wgOut->addHTML(
557 "<div><label><input type='checkbox' $emfc value=\"1\" name=\"wpEmailFlag\" />$emf</label></div>" );
558 }
559
560 $wgOut->addHTML( '</fieldset>' );
561 }
562 # </FIXME>
563
564 if ($wgAllowRealName || $wgEnableEmail) {
565 $wgOut->addHTML("<div class='prefsectiontip'>");
566 $rn = $wgAllowRealName ? wfMsg('prefs-help-realname') : '';
567 $em = $wgEnableEmail ? '<br />' . wfMsg('prefs-help-email') : '';
568 $wgOut->addHTML( $rn . $em . '</div>');
569 }
570
571 $wgOut->addHTML( '</fieldset>' );
572
573 # Quickbar
574 #
575 if ($this->mSkin == 'cologneblue' || $this->mSkin == 'standard') {
576 $wgOut->addHtml( "<fieldset>\n<legend>" . wfMsg( 'qbsettings' ) . "</legend>\n" );
577 for ( $i = 0; $i < count( $qbs ); ++$i ) {
578 if ( $i == $this->mQuickbar ) { $checked = ' checked="checked"'; }
579 else { $checked = ""; }
580 $wgOut->addHTML( "<div><label><input type='radio' name='wpQuickbar' value=\"$i\"$checked />{$qbs[$i]}</label></div>\n" );
581 }
582 $wgOut->addHtml( "</fieldset>\n\n" );
583 }
584
585 # Skin
586 #
587 $wgOut->addHTML( "<fieldset>\n<legend>\n" . wfMsg('skin') . "</legend>\n" );
588 # Only show members of $wgValidSkinNames rather than
589 # $skinNames (skins is all skin names from Language.php)
590 foreach ($wgValidSkinNames as $skinkey => $skinname ) {
591 global $wgDefaultSkin;
592
593 $checked = $skinkey == $this->mSkin ? ' checked="checked"' : '';
594 $sn = isset( $skinNames[$skinkey] ) ? $skinNames[$skinkey] : $skinname;
595
596 if( $skinkey == $wgDefaultSkin )
597 $sn .= ' (' . wfMsg( 'default' ) . ')';
598 $wgOut->addHTML( "<input type='radio' name='wpSkin' value=\"$skinkey\"$checked /> {$sn}<br/>\n" );
599 }
600 $wgOut->addHTML( "</fieldset>\n\n" );
601
602 # Math
603 #
604 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('math') . '</legend>' );
605 foreach ( $mathopts as $k => $v ) {
606 $checked = $k == $this->mMath ? ' checked="checked"' : '';
607 $wgOut->addHTML( "<div><label><input type='radio' name='wpMath' value=\"$k\"$checked /> ".wfMsg($v)."</label></div>\n" );
608 }
609 $wgOut->addHTML( "</fieldset>\n\n" );
610
611 # Files
612 #
613 $wgOut->addHTML("<fieldset>
614 <legend>" . wfMsg( 'files' ) . "</legend>
615 <div><label>" . wfMsg('imagemaxsize') . "<select name=\"wpImageSize\">");
616
617 $imageLimitOptions = null;
618 foreach ( $wgImageLimits as $index => $limits ) {
619 $selected = ($index == $this->mImageSize) ? 'selected="selected"' : '';
620 $imageLimitOptions .= "<option value=\"{$index}\" {$selected}>{$limits[0]}x{$limits[1]}</option>\n";
621 }
622
623 $imageThumbOptions = null;
624 $wgOut->addHTML( "{$imageLimitOptions}</select></label></div>
625 <div><label>" . wfMsg('thumbsize') . "<select name=\"wpThumbSize\">");
626 foreach ( $wgThumbLimits as $index => $size ) {
627 $selected = ($index == $this->mThumbSize) ? 'selected="selected"' : '';
628 $imageThumbOptions .= "<option value=\"{$index}\" {$selected}>{$size}px</option>\n";
629 }
630 $wgOut->addHTML( "{$imageThumbOptions}</select></label></div></fieldset>\n\n");
631
632 # Date format
633 #
634 if ($dateopts) {
635 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('dateformat') . "</legend>\n" );
636 foreach($dateopts as $key => $option) {
637 ($key == $this->mDate) ? $checked = ' checked="checked"' : $checked = '';
638 $wgOut->addHTML( "<div><label><input type='radio' name=\"wpDate\" ".
639 "value=\"$key\"$checked />$option</label></div>\n" );
640 }
641 $wgOut->addHTML( "</fieldset>\n\n");
642 }
643
644 # Time zone
645 #
646
647 $nowlocal = $wgLang->time( $now = wfTimestampNow(), true );
648 $nowserver = $wgLang->time( $now, false );
649
650 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'timezonelegend' ) . '</legend><table>' .
651 $this->addRow( wfMsg( 'servertime' ), $nowserver ) .
652 $this->addRow( wfMsg( 'localtime' ), $nowlocal ) .
653 $this->addRow(
654 wfMsg( 'timezoneoffset' ),
655 "<input type='text' name='wpHourDiff' value=\"" . htmlspecialchars( $this->mHourDiff ) . "\" size='6' />"
656 ) . "<tr><td colspan='2'>
657 <input type='button' value=\"" . wfMsg( 'guesstimezone' ) ."\"
658 onclick='javascript:guessTimezone()' id='guesstimezonebutton' style='display:none;' />
659 </td></tr></table>
660 <div class='prefsectiontip'>ยน" . wfMsg( 'timezonetext' ) . "</div>
661 </fieldset>\n\n" );
662
663 # Editing
664 #
665 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'textboxsize' ) . '</legend>
666 <div>
667 <label>' . wfMsg( 'rows' ) . ": <input type='text' name='wpRows' value=\"{$this->mRows}\" size='6' /></label>
668 <label>" . wfMsg( 'columns' ) . ": <input type='text' name='wpCols' value=\"{$this->mCols}\" size='6' /></label>
669 </div>" .
670 $this->getToggles( array(
671 'editsection',
672 'editsectiononrightclick',
673 'editondblclick',
674 'editwidth',
675 'showtoolbar',
676 'previewonfirst',
677 'previewontop',
678 'watchdefault',
679 'minordefault',
680 'externaleditor',
681 'externaldiff' )
682 ) . '</fieldset>'
683 );
684
685 $wgOut->addHTML( '<fieldset><legend>' . htmlspecialchars(wfMsg('prefs-rc')) . '</legend>
686 <table>' .
687 $this->addRow(
688 wfMsg ( 'stubthreshold' ),
689 "<input type='text' name=\"wpStubs\" value=\"$this->mStubs\" size='6' />"
690 ) .
691 $this->addRow(
692 wfMsg( 'recentchangescount' ),
693 "<input type='text' name='wpRecent' value=\"$this->mRecent\" size='6' />"
694 ) .
695 '</table>' .
696 $this->getToggles( array(
697 'hideminor',
698 $wgRCShowWatchingUsers ? 'shownumberswatching' : false,
699 'usenewrc',
700 'rcusemodstyle',
701 array(
702 'showupdated',
703 wfMsg('updatedmarker')
704 ) )
705 ) . '</fieldset>'
706 );
707
708 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'searchresultshead' ) . '</legend><table>' .
709 $this->addRow( wfMsg( 'resultsperpage' ), "<input type='text' name='wpSearch' value=\"$this->mSearch\" size='4' />" ) .
710 $this->addRow( wfMsg( 'contextlines' ), "<input type='text' name='wpSearchLines' value=\"$this->mSearchLines\" size='4' />" ) .
711 $this->addRow( wfMsg( 'contextchars' ), "<input type='text' name='wpSearchChars' value=\"$this->mSearchChars\" size='4' />" ) .
712 "</table><fieldset><legend>" . wfMsg( 'defaultns' ) . "</legend>$ps</fieldset></fieldset>" );
713
714 # Misc
715 #
716 $wgOut->addHTML('<fieldset><legend>' . wfMsg('prefs-misc') . '</legend>');
717
718 foreach ( $togs as $tname ) {
719 if( !array_key_exists( $tname, $this->mUsedToggles ) ) {
720 $wgOut->addHTML( $this->getToggle( $tname ) );
721 }
722 }
723 $wgOut->addHTML( '</fieldset>' );
724
725 $token = $wgUser->editToken();
726 $wgOut->addHTML( "
727 <div id='prefsubmit'>
728 <div>
729 <input type='submit' name='wpSaveprefs' value=\"" . wfMsg( 'saveprefs' ) . "\" accesskey=\"".
730 wfMsg('accesskey-save')."\" title=\"[alt-".wfMsg('accesskey-save')."]\" />
731 <input type='submit' name='wpReset' value=\"" . wfMsg( 'resetprefs' ) . "\" />
732 </div>
733
734 </div>
735
736 <input type='hidden' name='wpEditToken' value='{$token}' />
737 </form>\n" );
738 }
739 }
740 ?>