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