* Removed the troublesome regular expression in isValidEmailAddr which returns
[lhc/web/wiklou.git] / includes / SpecialPreferences.php
1 <?php
2 /**
3 * Hold things related to displaying and saving user preferences.
4 * @package MediaWiki
5 * @subpackage SpecialPage
6 */
7
8 if( !defined( 'MEDIAWIKI' ) )
9 die();
10
11 /** to get a list of languages in setting user's language preference */
12 require_once('languages/Names.php');
13
14 /**
15 * Entry point that create the "Preferences" object
16 */
17 function wfSpecialPreferences() {
18 global $wgRequest;
19
20 $form = new PreferencesForm( $wgRequest );
21 $form->execute();
22 }
23
24 /**
25 * Preferences form handling
26 * This object will show the preferences form and can save it as well.
27 * @package MediaWiki
28 * @subpackage SpecialPage
29 */
30 class PreferencesForm {
31 var $mQuickbar, $mOldpass, $mNewpass, $mRetypePass, $mStubs;
32 var $mRows, $mCols, $mSkin, $mMath, $mDate, $mUserEmail, $mEmailFlag, $mNick;
33 var $mUserLanguage, $mUserVariant;
34 var $mSearch, $mRecent, $mHourDiff, $mSearchLines, $mSearchChars, $mAction;
35 var $mReset, $mPosted, $mToggles, $mSearchNs, $mRealName, $mImageSize;
36
37 /**
38 * Constructor
39 * Load some values
40 */
41 function PreferencesForm( &$request ) {
42 global $wgLang, $wgContLang, $wgUser, $wgAllowRealName;
43
44 $this->mQuickbar = $request->getVal( 'wpQuickbar' );
45 $this->mOldpass = $request->getVal( 'wpOldpass' );
46 $this->mNewpass = $request->getVal( 'wpNewpass' );
47 $this->mRetypePass =$request->getVal( 'wpRetypePass' );
48 $this->mStubs = $request->getVal( 'wpStubs' );
49 $this->mRows = $request->getVal( 'wpRows' );
50 $this->mCols = $request->getVal( 'wpCols' );
51 $this->mSkin = $request->getVal( 'wpSkin' );
52 $this->mMath = $request->getVal( 'wpMath' );
53 $this->mDate = $request->getVal( 'wpDate' );
54 $this->mUserEmail = $request->getVal( 'wpUserEmail' );
55 $this->mRealName = ($wgAllowRealName) ? $request->getVal( 'wpRealName' ) : '';
56 $this->mEmailFlag = $request->getCheck( 'wpEmailFlag' ) ? 1 : 0;
57 $this->mNick = $request->getVal( 'wpNick' );
58 $this->mUserLanguage = $request->getVal( 'wpUserLanguage' );
59 $this->mUserVariant = $request->getVal( 'wpUserVariant' );
60 $this->mSearch = $request->getVal( 'wpSearch' );
61 $this->mRecent = $request->getVal( 'wpRecent' );
62 $this->mHourDiff = $request->getVal( 'wpHourDiff' );
63 $this->mSearchLines = $request->getVal( 'wpSearchLines' );
64 $this->mSearchChars = $request->getVal( 'wpSearchChars' );
65 $this->mImageSize = $request->getVal( 'wpImageSize' );
66 $this->mThumbSize = $request->getInt( 'wpThumbSize' );
67
68 $this->mAction = $request->getVal( 'action' );
69 $this->mReset = $request->getCheck( 'wpReset' );
70 $this->mPosted = $request->wasPosted();
71 $this->mSaveprefs = $request->getCheck( 'wpSaveprefs' ) &&
72 $this->mPosted &&
73 $wgUser->matchEditToken( $request->getVal( 'wpEditToken' ) );
74
75 # User toggles (the big ugly unsorted list of checkboxes)
76 $this->mToggles = array();
77 if ( $this->mPosted ) {
78 $togs = $wgLang->getUserToggles();
79 foreach ( $togs as $tname ) {
80 $this->mToggles[$tname] = $request->getCheck( "wpOp$tname" ) ? 1 : 0;
81 }
82 }
83
84 $this->mUsedToggles = array();
85
86 # Search namespace options
87 # Note: namespaces don't necessarily have consecutive keys
88 $this->mSearchNs = array();
89 if ( $this->mPosted ) {
90 $namespaces = $wgContLang->getNamespaces();
91 foreach ( $namespaces as $i => $namespace ) {
92 if ( $i >= 0 ) {
93 $this->mSearchNs[$i] = $request->getCheck( "wpNs$i" ) ? 1 : 0;
94 }
95 }
96 }
97
98 # Validate language
99 if ( !preg_match( '/^[a-z\-]*$/', $this->mUserLanguage ) ) {
100 $this->mUserLanguage = 'nolanguage';
101 }
102 }
103
104 function execute() {
105 global $wgUser, $wgOut;
106
107 if ( $wgUser->isAnon() ) {
108 $wgOut->errorpage( 'prefsnologin', 'prefsnologintext' );
109 return;
110 }
111 if ( wfReadOnly() ) {
112 $wgOut->readOnlyPage();
113 return;
114 }
115 if ( $this->mReset ) {
116 $this->resetPrefs();
117 $this->mainPrefsForm( wfMsg( 'prefsreset' ) );
118 } else if ( $this->mSaveprefs ) {
119 $this->savePreferences();
120 } else {
121 $this->resetPrefs();
122 $this->mainPrefsForm( '' );
123 }
124 }
125
126 /**
127 * @access private
128 */
129 function validateInt( &$val, $min=0, $max=0x7fffffff ) {
130 $val = intval($val);
131 $val = min($val, $max);
132 $val = max($val, $min);
133 return $val;
134 }
135
136 /**
137 * @access private
138 */
139 function validateIntOrNull( &$val, $min=0, $max=0x7fffffff ) {
140 $val = trim($val);
141 if($val === '') {
142 return $val;
143 } else {
144 return $this->validateInt( $val, $min, $max );
145 }
146 }
147
148 /**
149 * Used to validate the user inputed timezone before saving it as
150 * 'timeciorrection', will return '00:00' if fed bogus data.
151 * Note: It's not a 100% correct implementation timezone-wise, it will
152 * accept stuff like '14:30',
153 * @access private
154 * @param string $s the user input
155 * @return string
156 */
157 function validateTimeZone( $s ) {
158 if ( $s !== '' ) {
159 if ( strpos( $s, ':' ) ) {
160 # HH:MM
161 $array = explode( ':' , $s );
162 $hour = intval( $array[0] );
163 $minute = intval( $array[1] );
164 } else {
165 $minute = intval( $s * 60 );
166 $hour = intval( $minute / 60 );
167 $minute = abs( $minute ) % 60;
168 }
169 # Max is +14:00 and min is -12:00, see:
170 # http://en.wikipedia.org/wiki/Timezone
171 $hour = min( $hour, 14 );
172 $hour = max( $hour, -12 );
173 $minute = min( $minute, 59 );
174 $minute = max( $minute, 0 );
175 $s = sprintf( "%02d:%02d", $hour, $minute );
176 }
177 return $s;
178 }
179
180 /**
181 * @access private
182 */
183 function savePreferences() {
184 global $wgUser, $wgLang, $wgOut;
185 global $wgEnableUserEmail, $wgEnableEmail;
186 global $wgEmailAuthentication, $wgMinimalPasswordLength;
187
188 if ( '' != $this->mNewpass ) {
189 if ( $this->mNewpass != $this->mRetypePass ) {
190 $this->mainPrefsForm( wfMsg( 'badretype' ) );
191 return;
192 }
193
194 if ( strlen( $this->mNewpass ) < $wgMinimalPasswordLength ) {
195 $this->mainPrefsForm( wfMsg( 'passwordtooshort', $wgMinimalPasswordLength ) );
196 return;
197 }
198
199 if (!$wgUser->checkPassword( $this->mOldpass )) {
200 $this->mainPrefsForm( wfMsg( 'wrongpassword' ) );
201 return;
202 }
203 $wgUser->setPassword( $this->mNewpass );
204 }
205 $wgUser->setRealName( $this->mRealName );
206 $wgUser->setOption( 'language', $this->mUserLanguage );
207 $wgUser->setOption( 'variant', $this->mUserVariant );
208 $wgUser->setOption( 'nickname', $this->mNick );
209 $wgUser->setOption( 'quickbar', $this->mQuickbar );
210 $wgUser->setOption( 'skin', $this->mSkin );
211 $wgUser->setOption( 'math', $this->mMath );
212 $wgUser->setOption( 'date', $this->mDate );
213 $wgUser->setOption( 'searchlimit', $this->validateIntOrNull( $this->mSearch ) );
214 $wgUser->setOption( 'contextlines', $this->validateIntOrNull( $this->mSearchLines ) );
215 $wgUser->setOption( 'contextchars', $this->validateIntOrNull( $this->mSearchChars ) );
216 $wgUser->setOption( 'rclimit', $this->validateIntOrNull( $this->mRecent ) );
217 $wgUser->setOption( 'rows', $this->validateInt( $this->mRows, 4, 1000 ) );
218 $wgUser->setOption( 'cols', $this->validateInt( $this->mCols, 4, 1000 ) );
219 $wgUser->setOption( 'stubthreshold', $this->validateIntOrNull( $this->mStubs ) );
220 $wgUser->setOption( 'timecorrection', $this->validateTimeZone( $this->mHourDiff, -12, 14 ) );
221 $wgUser->setOption( 'imagesize', $this->mImageSize );
222 $wgUser->setOption( 'thumbsize', $this->mThumbSize );
223
224 # Set search namespace options
225 foreach( $this->mSearchNs as $i => $value ) {
226 $wgUser->setOption( "searchNs{$i}", $value );
227 }
228
229 if( $wgEnableEmail && $wgEnableUserEmail ) {
230 $wgUser->setOption( 'disablemail', $this->mEmailFlag );
231 }
232
233 # Set user toggles
234 foreach ( $this->mToggles as $tname => $tvalue ) {
235 $wgUser->setOption( $tname, $tvalue );
236 }
237 $wgUser->setCookies();
238 $wgUser->saveSettings();
239
240 if( $wgEnableEmail ) {
241 $newadr = strtolower( $this->mUserEmail );
242 $oldadr = strtolower($wgUser->getEmail());
243 if (($newadr <> '') && ($newadr <> $oldadr)) { # the user has supplied a new email address on the login page
244 # prepare for authentication and mail a temporary password to newadr
245 require_once( 'SpecialUserlogin.php' );
246 if ( !$wgUser->isValidEmailAddr( $newadr ) ) {
247 $this->mainPrefsForm( wfMsg( 'invalidemailaddress' ) );
248 return;
249 }
250 $wgUser->mEmail = $newadr; # new behaviour: set this new emailaddr from login-page into user database record
251 $wgUser->mEmailAuthenticationtimestamp = 0; # but flag as "dirty" = unauthenticated
252 $wgUser->saveSettings();
253 if ($wgEmailAuthentication) {
254 # mail a temporary password to the dirty address
255 # on "save options", this user will be logged-out automatically
256 $error = LoginForm::mailPasswordInternal( $wgUser, true, $dummy );
257 if ($error === '') {
258 return LoginForm::mainLoginForm( wfMsg( 'passwordsentforemailauthentication', $wgUser->getName() ) );
259 } else {
260 return LoginForm::mainLoginForm( wfMsg( 'mailerror', $error ) );
261 }
262 # if user returns, that new email address gets authenticated in checkpassword()
263 }
264 } else {
265 $wgUser->setEmail( strtolower($this->mUserEmail) );
266 $wgUser->setCookies();
267 $wgUser->saveSettings();
268 }
269 }
270
271 $wgOut->setParserOptions( ParserOptions::newFromUser( $wgUser ) );
272 $po = ParserOptions::newFromUser( $wgUser );
273 $this->mainPrefsForm( wfMsg( 'savedprefs' ) );
274 }
275
276 /**
277 * @access private
278 */
279 function resetPrefs() {
280 global $wgUser, $wgLang, $wgContLang, $wgAllowRealName;
281
282 $this->mOldpass = $this->mNewpass = $this->mRetypePass = '';
283 $this->mUserEmail = $wgUser->getEmail();
284 $this->mUserEmailAuthenticationtimestamp = $wgUser->getEmailAuthenticationtimestamp();
285 $this->mRealName = ($wgAllowRealName) ? $wgUser->getRealName() : '';
286 $this->mUserLanguage = $wgUser->getOption( 'language' );
287 if( empty( $this->mUserLanguage ) ) {
288 # Quick hack for conversions, where this value is blank
289 global $wgContLanguageCode;
290 $this->mUserLanguage = $wgContLanguageCode;
291 }
292 $this->mUserVariant = $wgUser->getOption( 'variant');
293 if ( 1 == $wgUser->getOption( 'disablemail' ) ) { $this->mEmailFlag = 1; }
294 else { $this->mEmailFlag = 0; }
295 $this->mNick = $wgUser->getOption( 'nickname' );
296
297 $this->mQuickbar = $wgUser->getOption( 'quickbar' );
298 $this->mSkin = $wgUser->getOption( 'skin' );
299 $this->mMath = $wgUser->getOption( 'math' );
300 $this->mDate = $wgUser->getOption( 'date' );
301 $this->mRows = $wgUser->getOption( 'rows' );
302 $this->mCols = $wgUser->getOption( 'cols' );
303 $this->mStubs = $wgUser->getOption( 'stubthreshold' );
304 $this->mHourDiff = $wgUser->getOption( 'timecorrection' );
305 $this->mSearch = $wgUser->getOption( 'searchlimit' );
306 $this->mSearchLines = $wgUser->getOption( 'contextlines' );
307 $this->mSearchChars = $wgUser->getOption( 'contextchars' );
308 $this->mImageSize = $wgUser->getOption( 'imagesize' );
309 $this->mThumbSize = $wgUser->getOption( 'thumbsize' );
310 $this->mRecent = $wgUser->getOption( 'rclimit' );
311
312 $togs = $wgLang->getUserToggles();
313 foreach ( $togs as $tname ) {
314 $ttext = wfMsg('tog-'.$tname);
315 $this->mToggles[$tname] = $wgUser->getOption( $tname );
316 }
317
318 $namespaces = $wgContLang->getNamespaces();
319 foreach ( $namespaces as $i => $namespace ) {
320 if ( $i >= 0 ) {
321 $this->mSearchNs[$i] = $wgUser->getOption( 'searchNs'.$i );
322 }
323 }
324 }
325
326 /**
327 * @access private
328 */
329 function namespacesCheckboxes() {
330 global $wgContLang, $wgUser;
331
332 # Determine namespace checkboxes
333 $namespaces = $wgContLang->getNamespaces();
334 $r1 = '';
335
336 foreach ( $namespaces as $i => $name ) {
337 # Skip special or anything similar
338 if ( $i >= 0 ) {
339 $checked = '';
340 if ( $this->mSearchNs[$i] ) {
341 $checked = ' checked="checked"';
342 }
343 $name = str_replace( '_', ' ', $namespaces[$i] );
344 if ( '' == $name ) {
345 $name = wfMsg( 'blanknamespace' );
346 }
347
348 if ( 0 != $i ) {
349 $r1 .= ' ';
350 }
351 $r1 .= "<label><input type='checkbox' value=\"1\" name=\"" .
352 "wpNs$i\"{$checked} />{$name}</label>\n";
353 }
354 }
355
356 return $r1;
357 }
358
359
360 function getToggle( $tname, $trailer = false) {
361 global $wgUser, $wgLang;
362
363 $this->mUsedToggles[$tname] = true;
364 $ttext = $wgLang->getUserToggle( $tname );
365
366 if ( 1 == $wgUser->getOption( $tname ) ) {
367 $checked = ' checked="checked"';
368 } else {
369 $checked = '';
370 }
371 $trailer =($trailer) ? $trailer : '';
372 return "<div><input type='checkbox' value=\"1\" "
373 . "id=\"$tname\" name=\"wpOp$tname\"$checked /><label for=\"$tname\">$ttext</label>$trailer</div>\n";
374 }
375
376 /**
377 * @access private
378 */
379 function mainPrefsForm( $err ) {
380 global $wgUser, $wgOut, $wgLang, $wgContLang, $wgValidSkinNames;
381 global $wgAllowRealName, $wgImageLimits, $wgThumbLimits;
382 global $wgLanguageNames, $wgDisableLangConversion;
383 global $wgEmailNotificationForWatchlistPages, $wgEmailNotificationForUserTalkPages,$wgEmailNotificationForMinorEdits;
384 global $wgRCShowWatchingUsers, $wgEmailNotificationRevealPageEditorAddress;
385 global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
386 global $wgContLanguageCode;
387
388 $wgOut->setPageTitle( wfMsg( 'preferences' ) );
389 $wgOut->setArticleRelated( false );
390 $wgOut->setRobotpolicy( 'noindex,nofollow' );
391
392 if ( '' != $err ) {
393 $wgOut->addHTML( "<p class='error'>" . htmlspecialchars( $err ) . "</p>\n" );
394 }
395 $uname = $wgUser->getName();
396 $uid = $wgUser->getID();
397
398 $wgOut->addWikiText( wfMsg( 'prefslogintext', $uname, $uid ) );
399 $wgOut->addWikiText( wfMsg('clearyourcache'));
400
401 $qbs = $wgLang->getQuickbarSettings();
402 $skinNames = $wgLang->getSkinNames();
403 $mathopts = $wgLang->getMathNames();
404 $dateopts = $wgLang->getDateFormats();
405 $togs = $wgLang->getUserToggles();
406
407 $titleObj = Title::makeTitle( NS_SPECIAL, 'Preferences' );
408 $action = $titleObj->escapeLocalURL();
409
410 $qb = wfMsg( 'qbsettings' );
411 $cp = wfMsg( 'changepassword' );
412 $sk = wfMsg( 'skin' );
413 $math = wfMsg( 'math' );
414 $files = wfMsg( 'files' );
415 $dateFormat = wfMsg('dateformat');
416 $opw = wfMsg( 'oldpassword' );
417 $npw = wfMsg( 'newpassword' );
418 $rpw = wfMsg( 'retypenew' );
419 $svp = wfMsg( 'saveprefs' );
420 $rsp = wfMsg( 'resetprefs' );
421 $tbs = wfMsg( 'textboxsize' );
422 $tbr = wfMsg( 'rows' );
423 $tbc = wfMsg( 'columns' );
424 $ltz = wfMsg( 'localtime' );
425 $timezone = wfMsg( 'timezonelegend' );
426 $tzt = wfMsg( 'timezonetext' );
427 $tzo = wfMsg( 'timezoneoffset' );
428 $tzGuess = wfMsg( 'guesstimezone' );
429 $tzServerTime = wfMsg( 'servertime' );
430 $yem = wfMsg( 'youremail' );
431 $yrn = ($wgAllowRealName) ? wfMsg( 'yourrealname' ) : '';
432 $yl = wfMsg( 'yourlanguage' );
433 $yv = wfMsg( 'yourvariant' );
434 $emf = wfMsg( 'emailflag' );
435 $ynn = wfMsg( 'yournick' );
436 $stt = wfMsg ( 'stubthreshold' ) ;
437 $srh = wfMsg( 'searchresultshead' );
438 $rpp = wfMsg( 'resultsperpage' );
439 $scl = wfMsg( 'contextlines' );
440 $scc = wfMsg( 'contextchars' );
441 $rcc = wfMsg( 'recentchangescount' );
442 $dsn = wfMsg( 'defaultns' );
443
444 $wgOut->addHTML( "<form id=\"preferences\" name=\"preferences\" action=\"$action\"
445 method=\"post\">" );
446
447 # First section: identity
448 # Email, etc.
449 #
450 $this->mUserEmail = htmlspecialchars( $this->mUserEmail );
451 $this->mRealName = htmlspecialchars( $this->mRealName );
452 $this->mNick = htmlspecialchars( $this->mNick );
453 if ( $this->mEmailFlag ) { $emfc = 'checked="checked"'; }
454 else { $emfc = ''; }
455
456 if ($wgEmailAuthentication && ($this->mUserEmail != '') ) {
457 if ($wgUser->getEmailAuthenticationtimestamp() != 0) {
458 $emailauthenticated = wfMsg('emailauthenticated',$wgLang->timeanddate($wgUser->getEmailAuthenticationtimestamp(), true ) ).'<br />';
459 $disabled = '';
460 } else {
461 $emailauthenticated = wfMsg('emailnotauthenticated').'<br />';
462 $disabled = ' '.wfMsg('disableduntilauthent');
463 }
464 } else {
465 $emailauthenticated = '';
466 }
467
468 if ($this->mUserEmail == '') {
469 $disabled = ' '.wfMsg('disablednoemail');
470 }
471
472 $ps = $this->namespacesCheckboxes();
473
474 $enotifwatchlistpages = ($wgEmailNotificationForWatchlistPages) ? $this->getToggle( 'enotifwatchlistpages', $disabled) : '';
475 $enotifusertalkpages = ($wgEmailNotificationForUserTalkPages) ? $this->getToggle( 'enotifusertalkpages', $disabled) : '';
476 $enotifminoredits = ($wgEmailNotificationForMinorEdits) ? $this->getToggle( 'enotifminoredits', $disabled) : '';
477 $enotifrevealaddr = ($wgEmailNotificationRevealPageEditorAddress) ? $this->getToggle( 'enotifrevealaddr', $disabled) : '';
478 $prefs_help_email_enotif = ( $wgEmailNotificationForWatchlistPages || $wgEmailNotificationForUserTalkPages) ? ' ' . wfMsg('prefs-help-email-enotif') : '';
479 $prefs_help_realname = '';
480
481 $wgOut->addHTML( "<fieldset>
482 <legend>".wfMsg('prefs-personal')."</legend>");
483
484 if ($wgAllowRealName) {
485 $wgOut->addHTML("<div><label>$yrn: <input type='text' name=\"wpRealName\" value=\"{$this->mRealName}\" size='20' /></label></div>");
486 $prefs_help_realname = wfMsg('prefs-help-realname').'<br />';
487 }
488
489 if( $wgEnableEmail ) {
490 $wgOut->addHTML("
491 <div><label>$yem: <input type='text' name=\"wpUserEmail\" value=\"{$this->mUserEmail}\" size='20' /></label></div>" );
492 $wgOut->addHTML(
493 $emailauthenticated.
494 $enotifrevealaddr.
495 $enotifwatchlistpages.
496 $enotifusertalkpages.
497 $enotifminoredits );
498 if( $wgEnableUserEmail ) {
499 $wgOut->addHTML(
500 "<div><label><input type='checkbox' $emfc value=\"1\" name=\"wpEmailFlag\" />$emf.$disabled</label></div>" );
501 }
502 }
503
504 $fancysig = $this->getToggle( 'fancysig' );
505 $wgOut->addHTML("
506 <div><label>$ynn: <input type='text' name=\"wpNick\" value=\"{$this->mNick}\" size='25' /></label></div>
507 <div>$fancysig<br /></div>
508 <div><label>$yl: <select name=\"wpUserLanguage\">\n");
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 if( isset( $wgLanguageNames[$this->mUserLanguage] ) ) {
516 $selectedLang = $this->mUserLanguage;
517 } else {
518 $selectedLang = $wgContLanguageCode;
519 }
520 foreach($wgLanguageNames as $code => $name) {
521 global $IP;
522 /* only add languages that have a file */
523 $langfile="$IP/languages/Language".str_replace('-', '_', ucfirst($code)).".php";
524 if(file_exists($langfile) || $code == $wgContLanguageCode) {
525 $sel = ($code == $selectedLang)? 'selected="selected"' : '';
526 $wgOut->addHtml("\t<option value=\"$code\" $sel>$code - $name</option>\n");
527 }
528 }
529 $wgOut->addHtml("</select></label></div>\n" );
530
531 /* see if there are multiple language variants to choose from*/
532 if(!$wgDisableLangConversion) {
533 $variants = $wgContLang->getVariants();
534 $size=sizeof($variants);
535
536 $variantArray=array();
537 foreach($variants as $v) {
538 $v = str_replace( '_', '-', strtolower($v));
539 if($name=$wgLanguageNames[$v]) {
540 $variantArray[$v] = $name;
541 }
542 }
543 $size=sizeof($variantArray);
544
545 if(sizeof($variantArray) > 1) {
546 $wgOut->addHtml("
547 <div><label>$yv: <select name=\"wpUserVariant\">\n");
548 foreach($variantArray as $code => $name) {
549 $sel = ($code==$this->mUserVariant)? 'selected="selected"' : '';
550 $wgOut->addHtml("\t<option value=\"$code\" $sel>$code - $name</option>\n");
551 }
552 }
553 }
554 # Fields for changing password
555 #
556 $this->mOldpass = htmlspecialchars( $this->mOldpass );
557 $this->mNewpass = htmlspecialchars( $this->mNewpass );
558 $this->mRetypePass = htmlspecialchars( $this->mRetypePass );
559
560 $wgOut->addHTML( "<fieldset>
561 <legend>$cp</legend>
562 <div><label>$opw: <input type='password' name=\"wpOldpass\" value=\"{$this->mOldpass}\" size='20' /></label></div>
563 <div><label>$npw: <input type='password' name=\"wpNewpass\" value=\"{$this->mNewpass}\" size='20' /></label></div>
564 <div><label>$rpw: <input type='password' name=\"wpRetypePass\" value=\"{$this->mRetypePass}\" size='20' /></label></div>
565 " . $this->getToggle( "rememberpassword" ) . "
566 </fieldset>
567 <div class='prefsectiontip'>".$prefs_help_realname.wfMsg('prefs-help-email').$prefs_help_email_enotif."</div>\n</fieldset>\n" );
568
569 # Quickbar setting
570 #
571 if ($this->mSkin == 'cologneblue' || $this->mSkin == 'standard') {
572 $wgOut->addHtml( "<fieldset>\n<legend>$qb</legend>\n" );
573 for ( $i = 0; $i < count( $qbs ); ++$i ) {
574 if ( $i == $this->mQuickbar ) { $checked = ' checked="checked"'; }
575 else { $checked = ""; }
576 $wgOut->addHTML( "<div><label><input type='radio' name=\"wpQuickbar\" value=\"$i\"$checked />{$qbs[$i]}</label></div>\n" );
577 }
578 $wgOut->addHtml( "</fieldset>\n\n" );
579 }
580
581 # Skin setting
582 #
583 $wgOut->addHTML( "<fieldset>\n<legend>$sk</legend>\n" );
584 # Only show members of $wgValidSkinNames rather than
585 # $skinNames (skins is all skin names from Language.php)
586 foreach ($wgValidSkinNames as $skinkey => $skinname ) {
587 if ( $skinkey == $this->mSkin ) {
588 $checked = ' checked="checked"';
589 } else {
590 $checked = '';
591 }
592 if ( isset( $skinNames[$skinkey] ) ) {
593 $sn = $skinNames[$skinkey];
594 } else {
595 $sn = $skinname;
596 }
597 global $wgDefaultSkin;
598 if( $skinkey == $wgDefaultSkin ) {
599 $sn .= ' (' . wfMsg( 'default' ) . ')';
600 }
601 $wgOut->addHTML( "<div><label><input type='radio' name=\"wpSkin\" value=\"$skinkey\"$checked /> {$sn}</label></div>\n" );
602 }
603 $wgOut->addHTML( "</fieldset>\n\n" );
604
605 # Math setting
606 #
607 $wgOut->addHTML( "<fieldset>\n<legend>$math</legend>\n" );
608 for ( $i = 0; $i < count( $mathopts ); ++$i ) {
609 if ( $i == $this->mMath ) { $checked = ' checked="checked"'; }
610 else { $checked = ""; }
611 $wgOut->addHTML( "<div><label><input type='radio' name=\"wpMath\"
612 value=\"$i\"$checked /> ".wfMsg($mathopts[$i])."</label></div>\n" );
613 }
614 $wgOut->addHTML( "</fieldset>\n\n" );
615
616 # Files
617 #
618 $wgOut->addHTML("<fieldset>
619 <legend>$files</legend>
620 <div><label>" . wfMsg('imagemaxsize') . "<select name=\"wpImageSize\">");
621
622 $imageLimitOptions = null;
623 foreach ( $wgImageLimits as $index => $limits ) {
624 $selected = ($index == $this->mImageSize) ? 'selected="selected"' : '';
625 $imageLimitOptions .= "<option value=\"{$index}\" {$selected}>{$limits[0]}x{$limits[1]}</option>\n";
626 }
627
628 $imageThumbOptions = null;
629 $wgOut->addHTML( "{$imageLimitOptions}</select></label></div>
630 <div><label>" . wfMsg('thumbsize') . "<select name=\"wpThumbSize\">");
631 foreach ( $wgThumbLimits as $index => $size ) {
632 $selected = ($index == $this->mThumbSize) ? 'selected="selected"' : '';
633 $imageThumbOptions .= "<option value=\"{$index}\" {$selected}>{$size}px</option>\n";
634 }
635 $wgOut->addHTML( "{$imageThumbOptions}</select></label></div></fieldset>\n\n");
636
637 # Date format
638 #
639 if ($dateopts) {
640 $wgOut->addHTML( "<fieldset>\n<legend>$dateFormat</legend>\n" );
641 foreach($dateopts as $key => $option) {
642 ($key == $this->mDate) ? $checked = ' checked="checked"' : $checked = '';
643 $wgOut->addHTML( "<div><label><input type='radio' name=\"wpDate\" ".
644 "value=\"$key\"$checked />$option</label></div>\n" );
645 }
646 $wgOut->addHTML( "</fieldset>\n\n");
647 }
648
649 # Time zone
650 #
651
652 $nowlocal = $wgLang->time( $now = wfTimestampNow(), true );
653 $nowserver = $wgLang->time( $now, false );
654
655 $wgOut->addHTML( "<fieldset>
656 <legend>$timezone</legend>
657 <div><b>$tzServerTime:</b>" . $nowserver . "</div>
658 <div><b>$ltz:</b> $nowlocal</div>
659 <div><label>$tzo*: <input type='text' name=\"wpHourDiff\" value=\"" . htmlspecialchars( $this->mHourDiff ) . "\" size='6' /></label></div>
660 <div><input type=\"button\" value=\"$tzGuess\" onclick=\"javascript:guessTimezone()\" id=\"guesstimezonebutton\" style=\"display:none\" /></div>
661 <div class='prefsectiontip'>* {$tzt}</div>
662 </fieldset>\n\n" );
663
664 # Editing
665 #
666 $wgOut->addHTML( "<fieldset>
667 <legend>$tbs</legend>\n
668 <div>
669 <label>$tbr: <input type='text' name=\"wpRows\" value=\"{$this->mRows}\" size='6' /></label>
670 <label>$tbc: <input type='text' name=\"wpCols\" value=\"{$this->mCols}\" size='6' /></label>
671 </div> " .
672 $this->getToggle( "editsection" ) .
673 $this->getToggle( "editsectiononrightclick" ) .
674 $this->getToggle( "editondblclick" ) .
675 $this->getToggle( "editwidth" ) .
676 $this->getToggle( "showtoolbar" ) .
677 $this->getToggle( "previewonfirst" ) .
678 $this->getToggle( "previewontop" ) .
679 $this->getToggle( "watchdefault" ) .
680 $this->getToggle( "minordefault" ) .
681 $this->getToggle( "externaleditor" ) .
682 $this->getToggle( "externaldiff" ) .
683 "
684 </fieldset>");
685
686 $shownumberswatching = ($wgRCShowWatchingUsers) ? $this->getToggle('shownumberswatching') : '';
687
688 $wgOut->addHTML( "
689 <fieldset><legend>".wfMsg('prefs-rc')."</legend>
690 <div><label>$rcc: <input type='text' name=\"wpRecent\" value=\"$this->mRecent\" size='6' /></label></div>" .
691 $this->getToggle( "hideminor" ) . $shownumberswatching .
692 $this->getToggle( "usenewrc" ) .
693 $this->getToggle( "rcusemodstyle" ) .
694 $this->getToggle('showupdated', wfMsg('updatedmarker')) .
695 "<div><label>$stt: <input type='text' name=\"wpStubs\" value=\"$this->mStubs\" size='6' /></label></div>
696 </fieldset>
697
698 <fieldset>
699 <legend>$srh</legend>
700 <div><label>$rpp: <input type='text' name=\"wpSearch\" value=\"$this->mSearch\" size='6' /></label></div>
701 <div><label>$scl: <input type='text' name=\"wpSearchLines\" value=\"$this->mSearchLines\" size='6' /></label></div>
702 <div><label>$scc: <input type='text' name=\"wpSearchChars\" value=\"$this->mSearchChars\" size='6' /></label></div>
703
704 <fieldset>
705 <legend>$dsn</legend>
706 $ps
707 </fieldset>
708 </fieldset>
709 " );
710
711 # Various checkbox options
712 #
713 $wgOut->addHTML("<fieldset><legend>".wfMsg('prefs-misc')."</legend>");
714
715 foreach ( $togs as $tname ) {
716 if( !array_key_exists( $tname, $this->mUsedToggles ) ) {
717 $wgOut->addHTML( $this->getToggle( $tname ) );
718 }
719 }
720 $wgOut->addHTML( "</fieldset>\n\n" );
721
722 $token = htmlspecialchars( $wgUser->editToken() );
723 $wgOut->addHTML( "
724 <div id='prefsubmit'>
725 <div>
726 <input type='submit' name=\"wpSaveprefs\" value=\"$svp\" accesskey=\"".
727 wfMsg('accesskey-save')."\" title=\"[alt-".wfMsg('accesskey-save')."]\" />
728 <input type='submit' name=\"wpReset\" value=\"$rsp\" />
729 </div>
730
731 </div>
732
733 <input type='hidden' name='wpEditToken' value=\"{$token}\" />
734 </form>\n" );
735 }
736 }
737 ?>