698216b4462012cadce12bd5a82d68109dd4eeea
[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 $wgUser->setOption( 'math', $this->mMath );
208 $wgUser->setOption( 'date', $this->mDate );
209 $wgUser->setOption( 'searchlimit', $this->validateIntOrNull( $this->mSearch ) );
210 $wgUser->setOption( 'contextlines', $this->validateIntOrNull( $this->mSearchLines ) );
211 $wgUser->setOption( 'contextchars', $this->validateIntOrNull( $this->mSearchChars ) );
212 $wgUser->setOption( 'rclimit', $this->validateIntOrNull( $this->mRecent ) );
213 $wgUser->setOption( 'rows', $this->validateInt( $this->mRows, 4, 1000 ) );
214 $wgUser->setOption( 'cols', $this->validateInt( $this->mCols, 4, 1000 ) );
215 $wgUser->setOption( 'stubthreshold', $this->validateIntOrNull( $this->mStubs ) );
216 $wgUser->setOption( 'timecorrection', $this->validateTimeZone( $this->mHourDiff, -12, 14 ) );
217 $wgUser->setOption( 'imagesize', $this->mImageSize );
218 $wgUser->setOption( 'thumbsize', $this->mThumbSize );
219
220 # Set search namespace options
221 foreach( $this->mSearchNs as $i => $value ) {
222 $wgUser->setOption( "searchNs{$i}", $value );
223 }
224
225 if( $wgEnableEmail && $wgEnableUserEmail ) {
226 $wgUser->setOption( 'disablemail', $this->mEmailFlag );
227 }
228
229 # Set user toggles
230 foreach ( $this->mToggles as $tname => $tvalue ) {
231 $wgUser->setOption( $tname, $tvalue );
232 }
233 $wgUser->setCookies();
234 $wgUser->saveSettings();
235
236 $error = wfMsg( 'savedprefs' );
237 if( $wgEnableEmail ) {
238 $newadr = $this->mUserEmail;
239 $oldadr = $wgUser->getEmail();
240 if( ($newadr != '') && ($newadr != $oldadr) ) {
241 # the user has supplied a new email address on the login page
242 if( $wgUser->isValidEmailAddr( $newadr ) ) {
243 $wgUser->mEmail = $newadr; # new behaviour: set this new emailaddr from login-page into user database record
244 $wgUser->mEmailAuthenticated = null; # but flag as "dirty" = unauthenticated
245 $wgUser->saveSettings();
246 if ($wgEmailAuthentication) {
247 # Mail a temporary password to the dirty address.
248 # User can come back through the confirmation URL to re-enable email.
249 $result = $wgUser->sendConfirmationMail();
250 if( WikiError::isError( $result ) ) {
251 $error = wfMsg( 'mailerror', $result->toString() );
252 } else {
253 $error = wfMsg( 'eauthentsent', $wgUser->getName() );
254 }
255 }
256 } else {
257 $error = wfMsg( 'invalidemailaddress' );
258 }
259 } else {
260 $wgUser->setEmail( $this->mUserEmail );
261 $wgUser->setCookies();
262 $wgUser->saveSettings();
263 }
264 }
265
266 $wgOut->setParserOptions( ParserOptions::newFromUser( $wgUser ) );
267 $po = ParserOptions::newFromUser( $wgUser );
268 $this->mainPrefsForm( $error );
269 }
270
271 /**
272 * @access private
273 */
274 function resetPrefs() {
275 global $wgUser, $wgLang, $wgContLang, $wgAllowRealName;
276
277 $this->mOldpass = $this->mNewpass = $this->mRetypePass = '';
278 $this->mUserEmail = $wgUser->getEmail();
279 $this->mUserEmailAuthenticationtimestamp = $wgUser->getEmailAuthenticationtimestamp();
280 $this->mRealName = ($wgAllowRealName) ? $wgUser->getRealName() : '';
281 $this->mUserLanguage = $wgUser->getOption( 'language' );
282 if( empty( $this->mUserLanguage ) ) {
283 # Quick hack for conversions, where this value is blank
284 global $wgContLanguageCode;
285 $this->mUserLanguage = $wgContLanguageCode;
286 }
287 $this->mUserVariant = $wgUser->getOption( 'variant');
288 $this->mEmailFlag = $wgUser->getOption( 'disablemail' ) == 1 ? 1 : 0;
289 $this->mNick = $wgUser->getOption( 'nickname' );
290
291 $this->mQuickbar = $wgUser->getOption( 'quickbar' );
292 $this->mSkin = $wgUser->getOption( 'skin' );
293 $this->mMath = $wgUser->getOption( 'math' );
294 $this->mDate = $wgUser->getOption( 'date' );
295 $this->mRows = $wgUser->getOption( 'rows' );
296 $this->mCols = $wgUser->getOption( 'cols' );
297 $this->mStubs = $wgUser->getOption( 'stubthreshold' );
298 $this->mHourDiff = $wgUser->getOption( 'timecorrection' );
299 $this->mSearch = $wgUser->getOption( 'searchlimit' );
300 $this->mSearchLines = $wgUser->getOption( 'contextlines' );
301 $this->mSearchChars = $wgUser->getOption( 'contextchars' );
302 $this->mImageSize = $wgUser->getOption( 'imagesize' );
303 $this->mThumbSize = $wgUser->getOption( 'thumbsize' );
304 $this->mRecent = $wgUser->getOption( 'rclimit' );
305
306 $togs = $wgLang->getUserToggles();
307 foreach ( $togs as $tname ) {
308 $ttext = wfMsg('tog-'.$tname);
309 $this->mToggles[$tname] = $wgUser->getOption( $tname );
310 }
311
312 $namespaces = $wgContLang->getNamespaces();
313 foreach ( $namespaces as $i => $namespace ) {
314 if ( $i >= NS_MAIN ) {
315 $this->mSearchNs[$i] = $wgUser->getOption( 'searchNs'.$i );
316 }
317 }
318 }
319
320 /**
321 * @access private
322 */
323 function namespacesCheckboxes() {
324 global $wgContLang, $wgUser;
325
326 # Determine namespace checkboxes
327 $namespaces = $wgContLang->getNamespaces();
328 $r1 = null;
329
330 foreach ( $namespaces as $i => $name ) {
331 if ($i < 0)
332 continue;
333 $checked = $this->mSearchNs[$i] ? "checked='checked'" : '';
334 $name = str_replace( '_', ' ', $namespaces[$i] );
335
336 if ( empty($name) )
337 $name = wfMsg( 'blanknamespace' );
338
339 $r1 .= "<label><input type='checkbox' value='1' name='wpNs$i' {$checked}/>{$name}</label>\n";
340 }
341 return $r1;
342 }
343
344
345 function getToggle( $tname, $trailer = false) {
346 global $wgUser, $wgLang;
347
348 $this->mUsedToggles[$tname] = true;
349 $ttext = $wgLang->getUserToggle( $tname );
350
351 $checked = $wgUser->getOption( $tname ) == 1 ? ' checked="checked"' : '';
352 $trailer = $trailer ? $trailer : '';
353 return "<div class='toggle'><input type='checkbox' value='1' id=\"$tname\" name=\"wpOp$tname\"$checked />" .
354 " <span class='toggletext'><label for=\"$tname\">$ttext</label>$trailer</span></div>";
355 }
356
357 function getToggles( $items ) {
358 $out = "";
359 foreach( $items as $item ) {
360 if( $item === false )
361 continue;
362 if( is_array( $item ) ) {
363 list( $key, $trailer ) = $item;
364 } else {
365 $key = $item;
366 $trailer = false;
367 }
368 $out .= $this->getToggle( $key, $trailer );
369 }
370 return $out;
371 }
372
373 function addRow($td1, $td2) {
374 return "<tr><td align='right'>$td1</td><td align='left'>$td2</td></tr>";
375 }
376
377 /**
378 * @access private
379 */
380 function mainPrefsForm( $err ) {
381 global $wgUser, $wgOut, $wgLang, $wgContLang, $wgValidSkinNames;
382 global $wgAllowRealName, $wgImageLimits, $wgThumbLimits;
383 global $wgDisableLangConversion;
384 global $wgEnotifWatchlist, $wgEnotifUserTalk,$wgEnotifMinorEdits;
385 global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress;
386 global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
387 global $wgContLanguageCode, $wgDefaultSkin, $wgSkipSkins;
388
389 $wgOut->setPageTitle( wfMsg( 'preferences' ) );
390 $wgOut->setArticleRelated( false );
391 $wgOut->setRobotpolicy( 'noindex,nofollow' );
392
393 if ( '' != $err ) {
394 $wgOut->addHTML( "<p class='error'>" . htmlspecialchars( $err ) . "</p>\n" );
395 }
396 $uname = $wgUser->getName();
397 $uid = $wgUser->getID();
398
399 $wgOut->addWikiText( wfMsg( 'prefslogintext', $uname, $uid ) );
400 $wgOut->addWikiText( wfMsg('clearyourcache'));
401
402 $qbs = $wgLang->getQuickbarSettings();
403 $skinNames = $wgLang->getSkinNames();
404 $mathopts = $wgLang->getMathNames();
405 $dateopts = $wgLang->getDateFormats();
406 $togs = $wgLang->getUserToggles();
407
408 $titleObj = Title::makeTitle( NS_SPECIAL, 'Preferences' );
409 $action = $titleObj->escapeLocalURL();
410
411
412 # Enotif
413 # <FIXME>
414 $this->mUserEmail = htmlspecialchars( $this->mUserEmail );
415 $this->mRealName = htmlspecialchars( $this->mRealName );
416 $this->mNick = htmlspecialchars( $this->mNick );
417 if ( $this->mEmailFlag ) { $emfc = 'checked="checked"'; }
418 else { $emfc = ''; }
419
420 if ($wgEmailAuthentication && ($this->mUserEmail != '') ) {
421 if( $wgUser->getEmailAuthenticationTimestamp() ) {
422 $emailauthenticated = wfMsg('emailauthenticated',$wgLang->timeanddate($wgUser->getEmailAuthenticationTimestamp(), true ) ).'<br />';
423 } else {
424 $skin = $wgUser->getSkin();
425 $emailauthenticated = wfMsg('emailnotauthenticated').'<br />' .
426 $skin->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Confirmemail' ),
427 wfMsg( 'emailconfirmlink' ) );
428 }
429 } else {
430 $emailauthenticated = '';
431 }
432
433 if ($this->mUserEmail == '') {
434 $emailauthenticated = wfMsg( 'noemailprefs' );
435 }
436
437 $ps = $this->namespacesCheckboxes();
438
439 $enotifwatchlistpages = ($wgEnotifWatchlist) ? $this->getToggle( 'enotifwatchlistpages' ) : '';
440 $enotifusertalkpages = ($wgEnotifUserTalk) ? $this->getToggle( 'enotifusertalkpages' ) : '';
441 $enotifminoredits = ($wgEnotifWatchlist && $wgEnotifMinorEdits) ? $this->getToggle( 'enotifminoredits' ) : '';
442 $enotifrevealaddr = (($wgEnotifWatchlist || $wgEnotifUserTalk) && $wgEnotifRevealEditorAddress) ? $this->getToggle( 'enotifrevealaddr' ) : '';
443 $prefs_help_email_enotif = ( $wgEnotifWatchlist || $wgEnotifUserTalk) ? ' ' . wfMsg('prefs-help-email-enotif') : '';
444 $prefs_help_realname = '';
445
446 # </FIXME>
447
448 $wgOut->addHTML( "<form id='preferences' name='preferences' action=\"$action\" method='post'>" );
449
450 # User data
451 #
452
453 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('prefs-personal') . "</legend>\n<table>\n");
454
455 if ($wgAllowRealName) {
456 $wgOut->addHTML(
457 $this->addRow(
458 wfMsg('yourrealname'),
459 "<input type='text' name='wpRealName' value=\"{$this->mRealName}\" size='25' />"
460 )
461 );
462 }
463 if ($wgEnableEmail) {
464 $wgOut->addHTML(
465 $this->addRow(
466 wfMsg( 'youremail' ),
467 "<input type='text' name='wpUserEmail' value=\"{$this->mUserEmail}\" size='25' />"
468 )
469 );
470 }
471
472 $wgOut->addHTML(
473 $this->addRow(
474 wfMsg( 'yournick' ),
475 "<input type='text' name='wpNick' value=\"{$this->mNick}\" size='25' />"
476 ) .
477 # FIXME: The <input> part should be where the &nbsp; is, getToggle() needs
478 # to be changed to out return its output in two parts. -รฆvar
479 $this->addRow(
480 '&nbsp;',
481 $this->getToggle( 'fancysig' )
482 )
483 );
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 $languages = $wgLang->getLanguageNames();
491 $selectedLang = isset( $languages[$this->mUserLanguage] ) ? $this->mUserLanguage : $wgContLanguageCode;
492 $selbox = null;
493 foreach($languages as $code => $name) {
494 global $IP;
495 /* only add languages that have a file */
496 $langfile="$IP/languages/Language".str_replace('-', '_', ucfirst($code)).".php";
497 if(file_exists($langfile) || $code == $wgContLanguageCode) {
498 $sel = ($code == $selectedLang)? ' selected="selected"' : '';
499 $selbox .= "<option value=\"$code\"$sel>$code - $name</option>\n";
500 }
501 }
502 $wgOut->addHTML( $this->addRow( wfMsg('yourlanguage'), "<select name='wpUserLanguage'>$selbox</select>" ));
503
504 /* see if there are multiple language variants to choose from*/
505 if(!$wgDisableLangConversion) {
506 $variants = $wgContLang->getVariants();
507
508 foreach($variants as $v) {
509 $v = str_replace( '_', '-', strtolower($v));
510 if($name = $languages[$v]) {
511 $variantArray[$v] = $name;
512 }
513 }
514
515 $selbox = null;
516 foreach($variantArray as $code => $name) {
517 $sel = $code == $this->mUserVariant ? 'selected="selected"' : '';
518 $selbox .= "<option value=\"$code\" $sel>$code - $name</option>";
519 }
520
521 if(count($variantArray) > 1) {
522 $wgOut->addHtml(
523 $this->addRow( wfMsg( 'yourvariant' ), "<select name='wpUserVariant'>$selbox</select>" )
524 );
525 }
526 }
527 $wgOut->addHTML('</table>');
528
529 # Password
530 $this->mOldpass = htmlspecialchars( $this->mOldpass );
531 $this->mNewpass = htmlspecialchars( $this->mNewpass );
532 $this->mRetypePass = htmlspecialchars( $this->mRetypePass );
533
534 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'changepassword' ) . '</legend><table>');
535 $wgOut->addHTML(
536 $this->addRow( wfMsg( 'oldpassword' ), "<input type='password' name='wpOldpass' value=\"{$this->mOldpass}\" size='20' />" ) .
537 $this->addRow( wfMsg( 'newpassword' ), "<input type='password' name='wpNewpass' value=\"{$this->mNewpass}\" size='20' />" ) .
538 $this->addRow( wfMsg( 'retypenew' ), "<input type='password' name='wpRetypePass' value=\"{$this->mRetypePass}\" size='20' />" ) .
539 "</table>\n" .
540 $this->getToggle( "rememberpassword" ) . "</fieldset>\n\n" );
541
542 # <FIXME>
543 # Enotif
544 if ($wgEnableEmail) {
545 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'email' ) . '</legend>' );
546 $wgOut->addHTML(
547 $emailauthenticated.
548 $enotifrevealaddr.
549 $enotifwatchlistpages.
550 $enotifusertalkpages.
551 $enotifminoredits );
552 if ($wgEnableUserEmail) {
553 $emf = wfMsg( 'emailflag' );
554 $wgOut->addHTML(
555 "<div><label><input type='checkbox' $emfc value=\"1\" name=\"wpEmailFlag\" />$emf</label></div>" );
556 }
557
558 $wgOut->addHTML( '</fieldset>' );
559 }
560 # </FIXME>
561
562 if ($wgAllowRealName || $wgEnableEmail) {
563 $wgOut->addHTML("<div class='prefsectiontip'>");
564 $rn = $wgAllowRealName ? wfMsg('prefs-help-realname') : '';
565 $em = $wgEnableEmail ? '<br />' . wfMsg('prefs-help-email') : '';
566 $wgOut->addHTML( $rn . $em . '</div>');
567 }
568
569 $wgOut->addHTML( '</fieldset>' );
570
571 # Quickbar
572 #
573 if ($this->mSkin == 'cologneblue' || $this->mSkin == 'standard') {
574 $wgOut->addHtml( "<fieldset>\n<legend>" . wfMsg( 'qbsettings' ) . "</legend>\n" );
575 for ( $i = 0; $i < count( $qbs ); ++$i ) {
576 if ( $i == $this->mQuickbar ) { $checked = ' checked="checked"'; }
577 else { $checked = ""; }
578 $wgOut->addHTML( "<div><label><input type='radio' name='wpQuickbar' value=\"$i\"$checked />{$qbs[$i]}</label></div>\n" );
579 }
580 $wgOut->addHtml( "</fieldset>\n\n" );
581 }
582
583 # Skin
584 #
585 $wgOut->addHTML( "<fieldset>\n<legend>\n" . wfMsg('skin') . "</legend>\n" );
586 # Only show members of $wgValidSkinNames rather than
587 # $skinNames (skins is all skin names from Language.php)
588 foreach ($wgValidSkinNames as $skinkey => $skinname ) {
589 if ( in_array( $skinkey, $wgSkipSkins ) ) {
590 continue;
591 }
592 $checked = $skinkey == $this->mSkin ? ' checked="checked"' : '';
593 $sn = isset( $skinNames[$skinkey] ) ? $skinNames[$skinkey] : $skinname;
594
595 if( $skinkey == $wgDefaultSkin )
596 $sn .= ' (' . wfMsg( 'default' ) . ')';
597 $wgOut->addHTML( "<input type='radio' name='wpSkin' value=\"$skinkey\"$checked /> {$sn}<br/>\n" );
598 }
599 $wgOut->addHTML( "</fieldset>\n\n" );
600
601 # Math
602 #
603 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('math') . '</legend>' );
604 foreach ( $mathopts as $k => $v ) {
605 $checked = $k == $this->mMath ? ' checked="checked"' : '';
606 $wgOut->addHTML( "<div><label><input type='radio' name='wpMath' value=\"$k\"$checked /> ".wfMsg($v)."</label></div>\n" );
607 }
608 $wgOut->addHTML( "</fieldset>\n\n" );
609
610 # Files
611 #
612 $wgOut->addHTML("<fieldset>
613 <legend>" . wfMsg( 'files' ) . "</legend>
614 <div><label>" . wfMsg('imagemaxsize') . "<select name=\"wpImageSize\">");
615
616 $imageLimitOptions = null;
617 foreach ( $wgImageLimits as $index => $limits ) {
618 $selected = ($index == $this->mImageSize) ? 'selected="selected"' : '';
619 $imageLimitOptions .= "<option value=\"{$index}\" {$selected}>{$limits[0]}x{$limits[1]}</option>\n";
620 }
621
622 $imageThumbOptions = null;
623 $wgOut->addHTML( "{$imageLimitOptions}</select></label></div>
624 <div><label>" . wfMsg('thumbsize') . "<select name=\"wpThumbSize\">");
625 foreach ( $wgThumbLimits as $index => $size ) {
626 $selected = ($index == $this->mThumbSize) ? 'selected="selected"' : '';
627 $imageThumbOptions .= "<option value=\"{$index}\" {$selected}>{$size}px</option>\n";
628 }
629 $wgOut->addHTML( "{$imageThumbOptions}</select></label></div></fieldset>\n\n");
630
631 # Date format
632 #
633 if ($dateopts) {
634 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('dateformat') . "</legend>\n" );
635 foreach($dateopts as $key => $option) {
636 ($key == $this->mDate) ? $checked = ' checked="checked"' : $checked = '';
637 $wgOut->addHTML( "<div><label><input type='radio' name=\"wpDate\" ".
638 "value=\"$key\"$checked />$option</label></div>\n" );
639 }
640 $wgOut->addHTML( "</fieldset>\n\n");
641 }
642
643 # Time zone
644 #
645
646 $nowlocal = $wgLang->time( $now = wfTimestampNow(), true );
647 $nowserver = $wgLang->time( $now, false );
648
649 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'timezonelegend' ) . '</legend><table>' .
650 $this->addRow( wfMsg( 'servertime' ), $nowserver ) .
651 $this->addRow( wfMsg( 'localtime' ), $nowlocal ) .
652 $this->addRow(
653 wfMsg( 'timezoneoffset' ),
654 "<input type='text' name='wpHourDiff' value=\"" . htmlspecialchars( $this->mHourDiff ) . "\" size='6' />"
655 ) . "<tr><td colspan='2'>
656 <input type='button' value=\"" . wfMsg( 'guesstimezone' ) ."\"
657 onclick='javascript:guessTimezone()' id='guesstimezonebutton' style='display:none;' />
658 </td></tr></table>
659 <div class='prefsectiontip'>ยน" . wfMsg( 'timezonetext' ) . "</div>
660 </fieldset>\n\n" );
661
662 # Editing
663 #
664 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'textboxsize' ) . '</legend>
665 <div>
666 <label>' . wfMsg( 'rows' ) . ": <input type='text' name='wpRows' value=\"{$this->mRows}\" size='6' /></label>
667 <label>" . wfMsg( 'columns' ) . ": <input type='text' name='wpCols' value=\"{$this->mCols}\" size='6' /></label>
668 </div>" .
669 $this->getToggles( array(
670 'editsection',
671 'editsectiononrightclick',
672 'editondblclick',
673 'editwidth',
674 'showtoolbar',
675 'previewonfirst',
676 'previewontop',
677 'watchdefault',
678 'minordefault',
679 'externaleditor',
680 'externaldiff' )
681 ) . '</fieldset>'
682 );
683
684 $wgOut->addHTML( '<fieldset><legend>' . htmlspecialchars(wfMsg('prefs-rc')) . '</legend>
685 <table>' .
686 $this->addRow(
687 wfMsg ( 'stubthreshold' ),
688 "<input type='text' name=\"wpStubs\" value=\"$this->mStubs\" size='6' />"
689 ) .
690 $this->addRow(
691 wfMsg( 'recentchangescount' ),
692 "<input type='text' name='wpRecent' value=\"$this->mRecent\" size='6' />"
693 ) .
694 '</table>' .
695 $this->getToggles( array(
696 'hideminor',
697 $wgRCShowWatchingUsers ? 'shownumberswatching' : false,
698 'usenewrc',
699 'rcusemodstyle' )
700 ) . '</fieldset>'
701 );
702
703 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'searchresultshead' ) . '</legend><table>' .
704 $this->addRow( wfMsg( 'resultsperpage' ), "<input type='text' name='wpSearch' value=\"$this->mSearch\" size='4' />" ) .
705 $this->addRow( wfMsg( 'contextlines' ), "<input type='text' name='wpSearchLines' value=\"$this->mSearchLines\" size='4' />" ) .
706 $this->addRow( wfMsg( 'contextchars' ), "<input type='text' name='wpSearchChars' value=\"$this->mSearchChars\" size='4' />" ) .
707 "</table><fieldset><legend>" . wfMsg( 'defaultns' ) . "</legend>$ps</fieldset></fieldset>" );
708
709 # Misc
710 #
711 $wgOut->addHTML('<fieldset><legend>' . wfMsg('prefs-misc') . '</legend>');
712
713 foreach ( $togs as $tname ) {
714 if( !array_key_exists( $tname, $this->mUsedToggles ) ) {
715 $wgOut->addHTML( $this->getToggle( $tname ) );
716 }
717 }
718 $wgOut->addHTML( '</fieldset>' );
719
720 $token = $wgUser->editToken();
721 $wgOut->addHTML( "
722 <div id='prefsubmit'>
723 <div>
724 <input type='submit' name='wpSaveprefs' value=\"" . wfMsg( 'saveprefs' ) . "\" accesskey=\"".
725 wfMsg('accesskey-save')."\" title=\"[alt-".wfMsg('accesskey-save')."]\" />
726 <input type='submit' name='wpReset' value=\"" . wfMsg( 'resetprefs' ) . "\" />
727 </div>
728
729 </div>
730
731 <input type='hidden' name='wpEditToken' value='{$token}' />
732 </form>\n" );
733 }
734 }
735 ?>