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