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