Back out r42352, r42355, r42363, r42410 for now "Redesigning Special:Search"
[lhc/web/wiklou.git] / includes / specials / SpecialPreferences.php
1 <?php
2 /**
3 * Hold things related to displaying and saving user preferences.
4 * @file
5 * @ingroup SpecialPage
6 */
7
8 /**
9 * Entry point that create the "Preferences" object
10 */
11 function wfSpecialPreferences() {
12 global $wgRequest;
13
14 $form = new PreferencesForm( $wgRequest );
15 $form->execute();
16 }
17
18 /**
19 * Preferences form handling
20 * This object will show the preferences form and can save it as well.
21 * @ingroup SpecialPage
22 */
23 class PreferencesForm {
24 var $mQuickbar, $mOldpass, $mNewpass, $mRetypePass, $mStubs;
25 var $mRows, $mCols, $mSkin, $mMath, $mDate, $mUserEmail, $mEmailFlag, $mNick;
26 var $mUserLanguage, $mUserVariant;
27 var $mSearch, $mRecent, $mRecentDays, $mHourDiff, $mSearchLines, $mSearchChars, $mAction;
28 var $mReset, $mPosted, $mToggles, $mSearchNs, $mRealName, $mImageSize;
29 var $mUnderline, $mWatchlistEdits;
30
31 /**
32 * Constructor
33 * Load some values
34 */
35 function PreferencesForm( &$request ) {
36 global $wgContLang, $wgUser, $wgAllowRealName;
37
38 $this->mQuickbar = $request->getVal( 'wpQuickbar' );
39 $this->mOldpass = $request->getVal( 'wpOldpass' );
40 $this->mNewpass = $request->getVal( 'wpNewpass' );
41 $this->mRetypePass =$request->getVal( 'wpRetypePass' );
42 $this->mStubs = $request->getVal( 'wpStubs' );
43 $this->mRows = $request->getVal( 'wpRows' );
44 $this->mCols = $request->getVal( 'wpCols' );
45 $this->mSkin = $request->getVal( 'wpSkin' );
46 $this->mMath = $request->getVal( 'wpMath' );
47 $this->mDate = $request->getVal( 'wpDate' );
48 $this->mUserEmail = $request->getVal( 'wpUserEmail' );
49 $this->mRealName = $wgAllowRealName ? $request->getVal( 'wpRealName' ) : '';
50 $this->mEmailFlag = $request->getCheck( 'wpEmailFlag' ) ? 0 : 1;
51 $this->mNick = $request->getVal( 'wpNick' );
52 $this->mUserLanguage = $request->getVal( 'wpUserLanguage' );
53 $this->mUserVariant = $request->getVal( 'wpUserVariant' );
54 $this->mSearch = $request->getVal( 'wpSearch' );
55 $this->mRecent = $request->getVal( 'wpRecent' );
56 $this->mRecentDays = $request->getVal( 'wpRecentDays' );
57 $this->mHourDiff = $request->getVal( 'wpHourDiff' );
58 $this->mSearchLines = $request->getVal( 'wpSearchLines' );
59 $this->mSearchChars = $request->getVal( 'wpSearchChars' );
60 $this->mImageSize = $request->getVal( 'wpImageSize' );
61 $this->mThumbSize = $request->getInt( 'wpThumbSize' );
62 $this->mUnderline = $request->getInt( 'wpOpunderline' );
63 $this->mAction = $request->getVal( 'action' );
64 $this->mReset = $request->getCheck( 'wpReset' );
65 $this->mPosted = $request->wasPosted();
66 $this->mSuccess = $request->getCheck( 'success' );
67 $this->mWatchlistDays = $request->getVal( 'wpWatchlistDays' );
68 $this->mWatchlistEdits = $request->getVal( 'wpWatchlistEdits' );
69 $this->mDisableMWSuggest = $request->getCheck( 'wpDisableMWSuggest' );
70
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 = User::getToggles();
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 wfRunHooks( 'InitPreferencesForm', array( $this, $request ) );
104 }
105
106 function execute() {
107 global $wgUser, $wgOut, $wgTitle;
108
109 if ( $wgUser->isAnon() ) {
110 $wgOut->showErrorPage( 'prefsnologin', 'prefsnologintext', array($wgTitle->getPrefixedDBkey()) );
111 return;
112 }
113 if ( wfReadOnly() ) {
114 $wgOut->readOnlyPage();
115 return;
116 }
117 if ( $this->mReset ) {
118 $this->resetPrefs();
119 $this->mainPrefsForm( 'reset', wfMsg( 'prefsreset' ) );
120 } else if ( $this->mSaveprefs ) {
121 $this->savePreferences();
122 } else {
123 $this->resetPrefs();
124 $this->mainPrefsForm( '' );
125 }
126 }
127 /**
128 * @access private
129 */
130 function validateInt( &$val, $min=0, $max=0x7fffffff ) {
131 $val = intval($val);
132 $val = min($val, $max);
133 $val = max($val, $min);
134 return $val;
135 }
136
137 /**
138 * @access private
139 */
140 function validateFloat( &$val, $min, $max=0x7fffffff ) {
141 $val = floatval( $val );
142 $val = min( $val, $max );
143 $val = max( $val, $min );
144 return( $val );
145 }
146
147 /**
148 * @access private
149 */
150 function validateIntOrNull( &$val, $min=0, $max=0x7fffffff ) {
151 $val = trim($val);
152 if($val === '') {
153 return null;
154 } else {
155 return $this->validateInt( $val, $min, $max );
156 }
157 }
158
159 /**
160 * @access private
161 */
162 function validateDate( $val ) {
163 global $wgLang, $wgContLang;
164 if ( $val !== false && (
165 in_array( $val, (array)$wgLang->getDatePreferences() ) ||
166 in_array( $val, (array)$wgContLang->getDatePreferences() ) ) )
167 {
168 return $val;
169 } else {
170 return $wgLang->getDefaultDateFormat();
171 }
172 }
173
174 /**
175 * Used to validate the user inputed timezone before saving it as
176 * 'timecorrection', will return '00:00' if fed bogus data.
177 * Note: It's not a 100% correct implementation timezone-wise, it will
178 * accept stuff like '14:30',
179 * @access private
180 * @param string $s the user input
181 * @return string
182 */
183 function validateTimeZone( $s ) {
184 if ( $s !== '' ) {
185 if ( strpos( $s, ':' ) ) {
186 # HH:MM
187 $array = explode( ':' , $s );
188 $hour = intval( $array[0] );
189 $minute = intval( $array[1] );
190 } else {
191 $minute = intval( $s * 60 );
192 $hour = intval( $minute / 60 );
193 $minute = abs( $minute ) % 60;
194 }
195 # Max is +14:00 and min is -12:00, see:
196 # http://en.wikipedia.org/wiki/Timezone
197 $hour = min( $hour, 14 );
198 $hour = max( $hour, -12 );
199 $minute = min( $minute, 59 );
200 $minute = max( $minute, 0 );
201 $s = sprintf( "%02d:%02d", $hour, $minute );
202 }
203 return $s;
204 }
205
206 /**
207 * @access private
208 */
209 function savePreferences() {
210 global $wgUser, $wgOut, $wgParser;
211 global $wgEnableUserEmail, $wgEnableEmail;
212 global $wgEmailAuthentication, $wgRCMaxAge;
213 global $wgAuth, $wgEmailConfirmToEdit;
214
215
216 if ( ($this->mNewpass !== '' || $this->mOldpass !== '' ) && $wgAuth->allowPasswordChange() ) {
217 if ( $this->mNewpass != $this->mRetypePass ) {
218 wfRunHooks( 'PrefsPasswordAudit', array( $wgUser, $this->mNewpass, 'badretype' ) );
219 $this->mainPrefsForm( 'error', wfMsg( 'badretype' ) );
220 return;
221 }
222
223 if (!$wgUser->checkPassword( $this->mOldpass )) {
224 wfRunHooks( 'PrefsPasswordAudit', array( $wgUser, $this->mNewpass, 'wrongpassword' ) );
225 $this->mainPrefsForm( 'error', wfMsg( 'wrongpassword' ) );
226 return;
227 }
228
229 try {
230 $wgUser->setPassword( $this->mNewpass );
231 wfRunHooks( 'PrefsPasswordAudit', array( $wgUser, $this->mNewpass, 'success' ) );
232 $this->mNewpass = $this->mOldpass = $this->mRetypePass = '';
233 } catch( PasswordError $e ) {
234 wfRunHooks( 'PrefsPasswordAudit', array( $wgUser, $this->mNewpass, 'error' ) );
235 $this->mainPrefsForm( 'error', $e->getMessage() );
236 return;
237 }
238 }
239 $wgUser->setRealName( $this->mRealName );
240 $oldOptions = $wgUser->mOptions;
241
242 if( $wgUser->getOption( 'language' ) !== $this->mUserLanguage ) {
243 $needRedirect = true;
244 } else {
245 $needRedirect = false;
246 }
247
248 # Validate the signature and clean it up as needed
249 global $wgMaxSigChars;
250 if( mb_strlen( $this->mNick ) > $wgMaxSigChars ) {
251 global $wgLang;
252 $this->mainPrefsForm( 'error',
253 wfMsgExt( 'badsiglength', 'parsemag', $wgLang->formatNum( $wgMaxSigChars ) ) );
254 return;
255 } elseif( $this->mToggles['fancysig'] ) {
256 if( $wgParser->validateSig( $this->mNick ) !== false ) {
257 $this->mNick = $wgParser->cleanSig( $this->mNick );
258 } else {
259 $this->mainPrefsForm( 'error', wfMsg( 'badsig' ) );
260 return;
261 }
262 } else {
263 // When no fancy sig used, make sure ~{3,5} get removed.
264 $this->mNick = $wgParser->cleanSigInSig( $this->mNick );
265 }
266
267 $wgUser->setOption( 'language', $this->mUserLanguage );
268 $wgUser->setOption( 'variant', $this->mUserVariant );
269 $wgUser->setOption( 'nickname', $this->mNick );
270 $wgUser->setOption( 'quickbar', $this->mQuickbar );
271 $wgUser->setOption( 'skin', $this->mSkin );
272 global $wgUseTeX;
273 if( $wgUseTeX ) {
274 $wgUser->setOption( 'math', $this->mMath );
275 }
276 $wgUser->setOption( 'date', $this->validateDate( $this->mDate ) );
277 $wgUser->setOption( 'searchlimit', $this->validateIntOrNull( $this->mSearch ) );
278 $wgUser->setOption( 'contextlines', $this->validateIntOrNull( $this->mSearchLines ) );
279 $wgUser->setOption( 'contextchars', $this->validateIntOrNull( $this->mSearchChars ) );
280 $wgUser->setOption( 'rclimit', $this->validateIntOrNull( $this->mRecent ) );
281 $wgUser->setOption( 'rcdays', $this->validateInt($this->mRecentDays, 1, ceil($wgRCMaxAge / (3600*24))));
282 $wgUser->setOption( 'wllimit', $this->validateIntOrNull( $this->mWatchlistEdits, 0, 1000 ) );
283 $wgUser->setOption( 'rows', $this->validateInt( $this->mRows, 4, 1000 ) );
284 $wgUser->setOption( 'cols', $this->validateInt( $this->mCols, 4, 1000 ) );
285 $wgUser->setOption( 'stubthreshold', $this->validateIntOrNull( $this->mStubs ) );
286 $wgUser->setOption( 'timecorrection', $this->validateTimeZone( $this->mHourDiff, -12, 14 ) );
287 $wgUser->setOption( 'imagesize', $this->mImageSize );
288 $wgUser->setOption( 'thumbsize', $this->mThumbSize );
289 $wgUser->setOption( 'underline', $this->validateInt($this->mUnderline, 0, 2) );
290 $wgUser->setOption( 'watchlistdays', $this->validateFloat( $this->mWatchlistDays, 0, 7 ) );
291 $wgUser->setOption( 'disablesuggest', $this->mDisableMWSuggest );
292
293 # Set search namespace options
294 foreach( $this->mSearchNs as $i => $value ) {
295 $wgUser->setOption( "searchNs{$i}", $value );
296 }
297
298 if( $wgEnableEmail && $wgEnableUserEmail ) {
299 $wgUser->setOption( 'disablemail', $this->mEmailFlag );
300 }
301
302 # Set user toggles
303 foreach ( $this->mToggles as $tname => $tvalue ) {
304 $wgUser->setOption( $tname, $tvalue );
305 }
306
307 $error = false;
308 if( $wgEnableEmail ) {
309 $newadr = $this->mUserEmail;
310 $oldadr = $wgUser->getEmail();
311 if( ($newadr != '') && ($newadr != $oldadr) ) {
312 # the user has supplied a new email address on the login page
313 if( $wgUser->isValidEmailAddr( $newadr ) ) {
314 # new behaviour: set this new emailaddr from login-page into user database record
315 $wgUser->setEmail( $newadr );
316 # but flag as "dirty" = unauthenticated
317 $wgUser->invalidateEmail();
318 if ($wgEmailAuthentication) {
319 # Mail a temporary password to the dirty address.
320 # User can come back through the confirmation URL to re-enable email.
321 $result = $wgUser->sendConfirmationMail();
322 if( WikiError::isError( $result ) ) {
323 $error = wfMsg( 'mailerror', htmlspecialchars( $result->getMessage() ) );
324 } else {
325 $error = wfMsg( 'eauthentsent', $wgUser->getName() );
326 }
327 }
328 } else {
329 $error = wfMsg( 'invalidemailaddress' );
330 }
331 } else {
332 if( $wgEmailConfirmToEdit && empty( $newadr ) ) {
333 $this->mainPrefsForm( 'error', wfMsg( 'noemailtitle' ) );
334 return;
335 }
336 $wgUser->setEmail( $this->mUserEmail );
337 }
338 if( $oldadr != $newadr ) {
339 wfRunHooks( 'PrefsEmailAudit', array( $wgUser, $oldadr, $newadr ) );
340 }
341 }
342
343 if( !$wgAuth->updateExternalDB( $wgUser ) ){
344 $this->mainPrefsForm( 'error', wfMsg( 'externaldberror' ) );
345 return;
346 }
347
348 $msg = '';
349 if ( !wfRunHooks( 'SavePreferences', array( $this, $wgUser, &$msg, $oldOptions ) ) ) {
350 $this->mainPrefsForm( 'error', $msg );
351 return;
352 }
353
354 $wgUser->setCookies();
355 $wgUser->saveSettings();
356
357 if( $needRedirect && $error === false ) {
358 $title = SpecialPage::getTitleFor( 'Preferences' );
359 $wgOut->redirect( $title->getFullURL( 'success' ) );
360 return;
361 }
362
363 $wgOut->parserOptions( ParserOptions::newFromUser( $wgUser ) );
364 $this->mainPrefsForm( $error === false ? 'success' : 'error', $error);
365 }
366
367 /**
368 * @access private
369 */
370 function resetPrefs() {
371 global $wgUser, $wgLang, $wgContLang, $wgContLanguageCode, $wgAllowRealName;
372
373 $this->mOldpass = $this->mNewpass = $this->mRetypePass = '';
374 $this->mUserEmail = $wgUser->getEmail();
375 $this->mUserEmailAuthenticationtimestamp = $wgUser->getEmailAuthenticationtimestamp();
376 $this->mRealName = ($wgAllowRealName) ? $wgUser->getRealName() : '';
377
378 # language value might be blank, default to content language
379 $this->mUserLanguage = $wgUser->getOption( 'language', $wgContLanguageCode );
380
381 $this->mUserVariant = $wgUser->getOption( 'variant');
382 $this->mEmailFlag = $wgUser->getOption( 'disablemail' ) == 1 ? 1 : 0;
383 $this->mNick = $wgUser->getOption( 'nickname' );
384
385 $this->mQuickbar = $wgUser->getOption( 'quickbar' );
386 $this->mSkin = Skin::normalizeKey( $wgUser->getOption( 'skin' ) );
387 $this->mMath = $wgUser->getOption( 'math' );
388 $this->mDate = $wgUser->getDatePreference();
389 $this->mRows = $wgUser->getOption( 'rows' );
390 $this->mCols = $wgUser->getOption( 'cols' );
391 $this->mStubs = $wgUser->getOption( 'stubthreshold' );
392 $this->mHourDiff = $wgUser->getOption( 'timecorrection' );
393 $this->mSearch = $wgUser->getOption( 'searchlimit' );
394 $this->mSearchLines = $wgUser->getOption( 'contextlines' );
395 $this->mSearchChars = $wgUser->getOption( 'contextchars' );
396 $this->mImageSize = $wgUser->getOption( 'imagesize' );
397 $this->mThumbSize = $wgUser->getOption( 'thumbsize' );
398 $this->mRecent = $wgUser->getOption( 'rclimit' );
399 $this->mRecentDays = $wgUser->getOption( 'rcdays' );
400 $this->mWatchlistEdits = $wgUser->getOption( 'wllimit' );
401 $this->mUnderline = $wgUser->getOption( 'underline' );
402 $this->mWatchlistDays = $wgUser->getOption( 'watchlistdays' );
403 $this->mDisableMWSuggest = $wgUser->getBoolOption( 'disablesuggest' );
404
405 $togs = User::getToggles();
406 foreach ( $togs as $tname ) {
407 $this->mToggles[$tname] = $wgUser->getOption( $tname );
408 }
409
410 $namespaces = $wgContLang->getNamespaces();
411 foreach ( $namespaces as $i => $namespace ) {
412 if ( $i >= NS_MAIN ) {
413 $this->mSearchNs[$i] = $wgUser->getOption( 'searchNs'.$i );
414 }
415 }
416
417 wfRunHooks( 'ResetPreferences', array( $this, $wgUser ) );
418 }
419
420 /**
421 * @access private
422 */
423 function namespacesCheckboxes() {
424 global $wgContLang;
425
426 # Determine namespace checkboxes
427 $namespaces = $wgContLang->getNamespaces();
428 $r1 = null;
429
430 foreach ( $namespaces as $i => $name ) {
431 if ($i < 0)
432 continue;
433 $checked = $this->mSearchNs[$i] ? "checked='checked'" : '';
434 $name = str_replace( '_', ' ', $namespaces[$i] );
435
436 if ( empty($name) )
437 $name = wfMsg( 'blanknamespace' );
438
439 $r1 .= "<input type='checkbox' value='1' name='wpNs$i' id='wpNs$i' {$checked}/> <label for='wpNs$i'>{$name}</label><br />\n";
440 }
441 return $r1;
442 }
443
444
445 function getToggle( $tname, $trailer = false, $disabled = false ) {
446 global $wgUser, $wgLang;
447
448 $this->mUsedToggles[$tname] = true;
449 $ttext = $wgLang->getUserToggle( $tname );
450
451 $checked = $wgUser->getOption( $tname ) == 1 ? ' checked="checked"' : '';
452 $disabled = $disabled ? ' disabled="disabled"' : '';
453 $trailer = $trailer ? $trailer : '';
454 return "<div class='toggle'><input type='checkbox' value='1' id=\"$tname\" name=\"wpOp$tname\"$checked$disabled />" .
455 " <span class='toggletext'><label for=\"$tname\">$ttext</label>$trailer</span></div>\n";
456 }
457
458 function getToggles( $items ) {
459 $out = "";
460 foreach( $items as $item ) {
461 if( $item === false )
462 continue;
463 if( is_array( $item ) ) {
464 list( $key, $trailer ) = $item;
465 } else {
466 $key = $item;
467 $trailer = false;
468 }
469 $out .= $this->getToggle( $key, $trailer );
470 }
471 return $out;
472 }
473
474 function addRow($td1, $td2) {
475 return "<tr><td class='mw-label'>$td1</td><td class='mw-input'>$td2</td></tr>";
476 }
477
478 /**
479 * Helper function for user information panel
480 * @param $td1 label for an item
481 * @param $td2 item or null
482 * @param $td3 optional help or null
483 * @return xhtml block
484 */
485 function tableRow( $td1, $td2 = null, $td3 = null ) {
486
487 if ( is_null( $td3 ) ) {
488 $td3 = '';
489 } else {
490 $td3 = Xml::tags( 'tr', null,
491 Xml::tags( 'td', array( 'class' => 'pref-label', 'colspan' => '2' ), $td3 )
492 );
493 }
494
495 if ( is_null( $td2 ) ) {
496 $td1 = Xml::tags( 'td', array( 'class' => 'pref-label', 'colspan' => '2' ), $td1 );
497 $td2 = '';
498 } else {
499 $td1 = Xml::tags( 'td', array( 'class' => 'pref-label' ), $td1 );
500 $td2 = Xml::tags( 'td', array( 'class' => 'pref-input' ), $td2 );
501 }
502
503 return Xml::tags( 'tr', null, $td1 . $td2 ). $td3 . "\n";
504
505 }
506
507 /**
508 * @access private
509 */
510 function mainPrefsForm( $status , $message = '' ) {
511 global $wgUser, $wgOut, $wgLang, $wgContLang, $wgAuth;
512 global $wgAllowRealName, $wgImageLimits, $wgThumbLimits;
513 global $wgDisableLangConversion, $wgDisableTitleConversion;
514 global $wgEnotifWatchlist, $wgEnotifUserTalk,$wgEnotifMinorEdits;
515 global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress;
516 global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
517 global $wgContLanguageCode, $wgDefaultSkin, $wgCookieExpiration;
518 global $wgEmailConfirmToEdit, $wgEnableMWSuggest;
519
520 $wgOut->setPageTitle( wfMsg( 'preferences' ) );
521 $wgOut->setArticleRelated( false );
522 $wgOut->setRobotPolicy( 'noindex,nofollow' );
523 $wgOut->addScriptFile( 'prefs.js' );
524
525 $wgOut->disallowUserJs(); # Prevent hijacked user scripts from sniffing passwords etc.
526
527 if ( $this->mSuccess || 'success' == $status ) {
528 $wgOut->wrapWikiMsg( '<div class="successbox"><strong>$1</strong></div>', 'savedprefs' );
529 } else if ( 'error' == $status ) {
530 $wgOut->addWikiText( '<div class="errorbox"><strong>' . $message . '</strong></div>' );
531 } else if ( '' != $status ) {
532 $wgOut->addWikiText( $message . "\n----" );
533 }
534
535 $qbs = $wgLang->getQuickbarSettings();
536 $skinNames = $wgLang->getSkinNames();
537 $mathopts = $wgLang->getMathNames();
538 $dateopts = $wgLang->getDatePreferences();
539 $togs = User::getToggles();
540
541 $titleObj = SpecialPage::getTitleFor( 'Preferences' );
542
543 # Pre-expire some toggles so they won't show if disabled
544 $this->mUsedToggles[ 'shownumberswatching' ] = true;
545 $this->mUsedToggles[ 'showupdated' ] = true;
546 $this->mUsedToggles[ 'enotifwatchlistpages' ] = true;
547 $this->mUsedToggles[ 'enotifusertalkpages' ] = true;
548 $this->mUsedToggles[ 'enotifminoredits' ] = true;
549 $this->mUsedToggles[ 'enotifrevealaddr' ] = true;
550 $this->mUsedToggles[ 'ccmeonemails' ] = true;
551 $this->mUsedToggles[ 'uselivepreview' ] = true;
552 $this->mUsedToggles[ 'noconvertlink' ] = true;
553
554
555 if ( !$this->mEmailFlag ) { $emfc = 'checked="checked"'; }
556 else { $emfc = ''; }
557
558
559 if ($wgEmailAuthentication && ($this->mUserEmail != '') ) {
560 if( $wgUser->getEmailAuthenticationTimestamp() ) {
561 // date and time are separate parameters to facilitate localisation.
562 // $time is kept for backward compat reasons.
563 // 'emailauthenticated' is also used in SpecialConfirmemail.php
564 $time = $wgLang->timeAndDate( $wgUser->getEmailAuthenticationTimestamp(), true );
565 $d = $wgLang->date( $wgUser->getEmailAuthenticationTimestamp(), true );
566 $t = $wgLang->time( $wgUser->getEmailAuthenticationTimestamp(), true );
567 $emailauthenticated = wfMsg('emailauthenticated', $time, $d, $t ).'<br />';
568 $disableEmailPrefs = false;
569 } else {
570 $disableEmailPrefs = true;
571 $skin = $wgUser->getSkin();
572 $emailauthenticated = wfMsg('emailnotauthenticated').'<br />' .
573 $skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Confirmemail' ),
574 wfMsg( 'emailconfirmlink' ) ) . '<br />';
575 }
576 } else {
577 $emailauthenticated = '';
578 $disableEmailPrefs = false;
579 }
580
581 if ($this->mUserEmail == '') {
582 $emailauthenticated = wfMsg( 'noemailprefs' ) . '<br />';
583 }
584
585 $ps = $this->namespacesCheckboxes();
586
587 $enotifwatchlistpages = ($wgEnotifWatchlist) ? $this->getToggle( 'enotifwatchlistpages', false, $disableEmailPrefs ) : '';
588 $enotifusertalkpages = ($wgEnotifUserTalk) ? $this->getToggle( 'enotifusertalkpages', false, $disableEmailPrefs ) : '';
589 $enotifminoredits = ($wgEnotifWatchlist && $wgEnotifMinorEdits) ? $this->getToggle( 'enotifminoredits', false, $disableEmailPrefs ) : '';
590 $enotifrevealaddr = (($wgEnotifWatchlist || $wgEnotifUserTalk) && $wgEnotifRevealEditorAddress) ? $this->getToggle( 'enotifrevealaddr', false, $disableEmailPrefs ) : '';
591
592 # </FIXME>
593
594 $wgOut->addHTML(
595 Xml::openElement( 'form', array(
596 'action' => $titleObj->getLocalUrl(),
597 'method' => 'post',
598 'id' => 'mw-preferences-form',
599 ) ) .
600 Xml::openElement( 'div', array( 'id' => 'preferences' ) )
601 );
602
603 # User data
604
605 $wgOut->addHTML(
606 Xml::fieldset( wfMsg('prefs-personal') ) .
607 Xml::openElement( 'table' ) .
608 $this->tableRow( Xml::element( 'h2', null, wfMsg( 'prefs-personal' ) ) )
609 );
610
611 # Get groups to which the user belongs
612 $userEffectiveGroups = $wgUser->getEffectiveGroups();
613 $userEffectiveGroupsArray = array();
614 foreach( $userEffectiveGroups as $ueg ) {
615 if( $ueg == '*' ) {
616 // Skip the default * group, seems useless here
617 continue;
618 }
619 $userEffectiveGroupsArray[] = User::makeGroupLinkHTML( $ueg );
620 }
621 asort( $userEffectiveGroupsArray );
622
623 $sk = $wgUser->getSkin();
624 $toolLinks = array();
625 $toolLinks[] = $sk->makeKnownLinkObj( SpecialPage::getTitleFor( 'ListGroupRights' ), wfMsg( 'listgrouprights' ) );
626 # At the moment one tool link only but be prepared for the future...
627 # FIXME: Add a link to Special:Userrights for users who are allowed to use it.
628 # $wgUser->isAllowed( 'userrights' ) seems to strict in some cases
629
630 $userInformationHtml =
631 $this->tableRow( wfMsgHtml( 'username' ), htmlspecialchars( $wgUser->getName() ) ) .
632 $this->tableRow( wfMsgHtml( 'uid' ), $wgLang->formatNum( htmlspecialchars( $wgUser->getId() ) ) ).
633
634 $this->tableRow(
635 wfMsgExt( 'prefs-memberingroups', array( 'parseinline' ), count( $userEffectiveGroupsArray ) ),
636 $wgLang->commaList( $userEffectiveGroupsArray ) .
637 '<br />(' . implode( ' | ', $toolLinks ) . ')'
638 ) .
639
640 $this->tableRow(
641 wfMsgHtml( 'prefs-edits' ),
642 $wgLang->formatNum( $wgUser->getEditCount() )
643 );
644
645 if( wfRunHooks( 'PreferencesUserInformationPanel', array( $this, &$userInformationHtml ) ) ) {
646 $wgOut->addHtml( $userInformationHtml );
647 }
648
649 if ( $wgAllowRealName ) {
650 $wgOut->addHTML(
651 $this->tableRow(
652 Xml::label( wfMsg('yourrealname'), 'wpRealName' ),
653 Xml::input( 'wpRealName', 25, $this->mRealName, array( 'id' => 'wpRealName' ) ),
654 Xml::tags('div', array( 'class' => 'prefsectiontip' ),
655 wfMsgExt( 'prefs-help-realname', 'parseinline' )
656 )
657 )
658 );
659 }
660 if ( $wgEnableEmail ) {
661 $wgOut->addHTML(
662 $this->tableRow(
663 Xml::label( wfMsg('youremail'), 'wpUserEmail' ),
664 Xml::input( 'wpUserEmail', 25, $this->mUserEmail, array( 'id' => 'wpUserEmail' ) ),
665 Xml::tags('div', array( 'class' => 'prefsectiontip' ),
666 wfMsgExt( $wgEmailConfirmToEdit ? 'prefs-help-email-required' : 'prefs-help-email', 'parseinline' )
667 )
668 )
669 );
670 }
671
672 global $wgParser, $wgMaxSigChars;
673 if( mb_strlen( $this->mNick ) > $wgMaxSigChars ) {
674 $invalidSig = $this->tableRow(
675 '&nbsp;',
676 Xml::element( 'span', array( 'class' => 'error' ),
677 wfMsgExt( 'badsiglength', 'parsemag', $wgLang->formatNum( $wgMaxSigChars ) ) )
678 );
679 } elseif( !empty( $this->mToggles['fancysig'] ) &&
680 false === $wgParser->validateSig( $this->mNick ) ) {
681 $invalidSig = $this->tableRow(
682 '&nbsp;',
683 Xml::element( 'span', array( 'class' => 'error' ), wfMsg( 'badsig' ) )
684 );
685 } else {
686 $invalidSig = '';
687 }
688
689 $wgOut->addHTML(
690 $this->tableRow(
691 Xml::label( wfMsg( 'yournick' ), 'wpNick' ),
692 Xml::input( 'wpNick', 25, $this->mNick,
693 array(
694 'id' => 'wpNick',
695 // Note: $wgMaxSigChars is enforced in Unicode characters,
696 // both on the backend and now in the browser.
697 // Badly-behaved requests may still try to submit
698 // an overlong string, however.
699 'maxlength' => $wgMaxSigChars ) )
700 ) .
701 $invalidSig .
702 $this->tableRow( '&nbsp;', $this->getToggle( 'fancysig' ) )
703 );
704
705 list( $lsLabel, $lsSelect) = Xml::languageSelector( $this->mUserLanguage );
706 $wgOut->addHTML(
707 $this->tableRow( $lsLabel, $lsSelect )
708 );
709
710 /* see if there are multiple language variants to choose from*/
711 if(!$wgDisableLangConversion) {
712 $variants = $wgContLang->getVariants();
713 $variantArray = array();
714
715 $languages = Language::getLanguageNames( true );
716 foreach($variants as $v) {
717 $v = str_replace( '_', '-', strtolower($v));
718 if( array_key_exists( $v, $languages ) ) {
719 // If it doesn't have a name, we'll pretend it doesn't exist
720 $variantArray[$v] = $languages[$v];
721 }
722 }
723
724 $options = "\n";
725 foreach( $variantArray as $code => $name ) {
726 $selected = ($code == $this->mUserVariant);
727 $options .= Xml::option( "$code - $name", $code, $selected ) . "\n";
728 }
729
730 if(count($variantArray) > 1) {
731 $wgOut->addHtml(
732 $this->tableRow(
733 Xml::label( wfMsg( 'yourvariant' ), 'wpUserVariant' ),
734 Xml::tags( 'select',
735 array( 'name' => 'wpUserVariant', 'id' => 'wpUserVariant' ),
736 $options
737 )
738 )
739 );
740 }
741
742 if(count($variantArray) > 1 && !$wgDisableLangConversion && !$wgDisableTitleConversion) {
743 $wgOut->addHtml(
744 Xml::tags( 'tr', null,
745 Xml::tags( 'td', array( 'colspan' => '2' ),
746 $this->getToggle( "noconvertlink" )
747 )
748 )
749 );
750 }
751 }
752
753 # Password
754 if( $wgAuth->allowPasswordChange() ) {
755 $wgOut->addHTML(
756 $this->tableRow( Xml::element( 'h2', null, wfMsg( 'changepassword' ) ) ) .
757 $this->tableRow(
758 Xml::label( wfMsg( 'oldpassword' ), 'wpOldpass' ),
759 Xml::password( 'wpOldpass', 25, $this->mOldpass, array( 'id' => 'wpOldpass' ) )
760 ) .
761 $this->tableRow(
762 Xml::label( wfMsg( 'newpassword' ), 'wpNewpass' ),
763 Xml::password( 'wpNewpass', 25, $this->mNewpass, array( 'id' => 'wpNewpass' ) )
764 ) .
765 $this->tableRow(
766 Xml::label( wfMsg( 'retypenew' ), 'wpRetypePass' ),
767 Xml::password( 'wpRetypePass', 25, $this->mRetypePass, array( 'id' => 'wpRetypePass' ) )
768 )
769 );
770 if( $wgCookieExpiration > 0 ){
771 $wgOut->addHTML(
772 Xml::tags( 'tr', null,
773 Xml::tags( 'td', array( 'colspan' => '2' ),
774 $this->getToggle( "rememberpassword" )
775 )
776 )
777 );
778 } else {
779 $this->mUsedToggles['rememberpassword'] = true;
780 }
781 }
782
783 # <FIXME>
784 # Enotif
785 if ( $wgEnableEmail ) {
786
787 $moreEmail = '';
788 if ($wgEnableUserEmail) {
789 // fixme -- the "allowemail" pseudotoggle is a hacked-together
790 // inversion for the "disableemail" preference.
791 $emf = wfMsg( 'allowemail' );
792 $disabled = $disableEmailPrefs ? ' disabled="disabled"' : '';
793 $moreEmail =
794 "<input type='checkbox' $emfc $disabled value='1' name='wpEmailFlag' id='wpEmailFlag' /> <label for='wpEmailFlag'>$emf</label>" .
795 $this->getToggle( 'ccmeonemails', '', $disableEmailPrefs );
796 }
797
798
799 $wgOut->addHTML(
800 $this->tableRow( Xml::element( 'h2', null, wfMsg( 'email' ) ) ) .
801 $this->tableRow(
802 $emailauthenticated.
803 $enotifrevealaddr.
804 $enotifwatchlistpages.
805 $enotifusertalkpages.
806 $enotifminoredits.
807 $moreEmail
808 )
809 );
810 }
811 # </FIXME>
812
813 $wgOut->addHTML(
814 Xml::closeElement( 'table' ) .
815 Xml::closeElement( 'fieldset' )
816 );
817
818
819 # Quickbar
820 #
821 if ($this->mSkin == 'cologneblue' || $this->mSkin == 'standard') {
822 $wgOut->addHtml( "<fieldset>\n<legend>" . wfMsg( 'qbsettings' ) . "</legend>\n" );
823 for ( $i = 0; $i < count( $qbs ); ++$i ) {
824 if ( $i == $this->mQuickbar ) { $checked = ' checked="checked"'; }
825 else { $checked = ""; }
826 $wgOut->addHTML( "<div><label><input type='radio' name='wpQuickbar' value=\"$i\"$checked />{$qbs[$i]}</label></div>\n" );
827 }
828 $wgOut->addHtml( "</fieldset>\n\n" );
829 } else {
830 # Need to output a hidden option even if the relevant skin is not in use,
831 # otherwise the preference will get reset to 0 on submit
832 $wgOut->addHtml( wfHidden( 'wpQuickbar', $this->mQuickbar ) );
833 }
834
835 # Skin
836 #
837 $wgOut->addHTML( "<fieldset>\n<legend>\n" . wfMsg('skin') . "</legend>\n" );
838 $mptitle = Title::newMainPage();
839 $previewtext = wfMsg('skin-preview');
840 # Only show members of Skin::getSkinNames() rather than
841 # $skinNames (skins is all skin names from Language.php)
842 $validSkinNames = Skin::getUsableSkins();
843 # Sort by UI skin name. First though need to update validSkinNames as sometimes
844 # the skinkey & UI skinname differ (e.g. "standard" skinkey is "Classic" in the UI).
845 foreach ($validSkinNames as $skinkey => & $skinname ) {
846 if ( isset( $skinNames[$skinkey] ) ) {
847 $skinname = $skinNames[$skinkey];
848 }
849 }
850 asort($validSkinNames);
851 foreach ($validSkinNames as $skinkey => $sn ) {
852 $checked = $skinkey == $this->mSkin ? ' checked="checked"' : '';
853
854 $mplink = htmlspecialchars($mptitle->getLocalURL("useskin=$skinkey"));
855 $previewlink = "(<a target='_blank' href=\"$mplink\">$previewtext</a>)";
856 if( $skinkey == $wgDefaultSkin )
857 $sn .= ' (' . wfMsg( 'default' ) . ')';
858 $wgOut->addHTML( "<input type='radio' name='wpSkin' id=\"wpSkin$skinkey\" value=\"$skinkey\"$checked /> <label for=\"wpSkin$skinkey\">{$sn}</label> $previewlink<br />\n" );
859 }
860 $wgOut->addHTML( "</fieldset>\n\n" );
861
862 # Math
863 #
864 global $wgUseTeX;
865 if( $wgUseTeX ) {
866 $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('math') . '</legend>' );
867 foreach ( $mathopts as $k => $v ) {
868 $checked = ($k == $this->mMath);
869 $wgOut->addHTML(
870 Xml::openElement( 'div' ) .
871 Xml::radioLabel( wfMsg( $v ), 'wpMath', $k, "mw-sp-math-$k", $checked ) .
872 Xml::closeElement( 'div' ) . "\n"
873 );
874 }
875 $wgOut->addHTML( "</fieldset>\n\n" );
876 }
877
878 # Files
879 #
880 $wgOut->addHTML(
881 "<fieldset>\n" . Xml::element( 'legend', null, wfMsg( 'files' ) ) . "\n"
882 );
883
884 $imageLimitOptions = null;
885 foreach ( $wgImageLimits as $index => $limits ) {
886 $selected = ($index == $this->mImageSize);
887 $imageLimitOptions .= Xml::option( "{$limits[0]}×{$limits[1]}" .
888 wfMsg('unit-pixel'), $index, $selected );
889 }
890
891 $imageSizeId = 'wpImageSize';
892 $wgOut->addHTML(
893 "<div>" . Xml::label( wfMsg('imagemaxsize'), $imageSizeId ) . " " .
894 Xml::openElement( 'select', array( 'name' => $imageSizeId, 'id' => $imageSizeId ) ) .
895 $imageLimitOptions .
896 Xml::closeElement( 'select' ) . "</div>\n"
897 );
898
899 $imageThumbOptions = null;
900 foreach ( $wgThumbLimits as $index => $size ) {
901 $selected = ($index == $this->mThumbSize);
902 $imageThumbOptions .= Xml::option($size . wfMsg('unit-pixel'), $index,
903 $selected);
904 }
905
906 $thumbSizeId = 'wpThumbSize';
907 $wgOut->addHTML(
908 "<div>" . Xml::label( wfMsg('thumbsize'), $thumbSizeId ) . " " .
909 Xml::openElement( 'select', array( 'name' => $thumbSizeId, 'id' => $thumbSizeId ) ) .
910 $imageThumbOptions .
911 Xml::closeElement( 'select' ) . "</div>\n"
912 );
913
914 $wgOut->addHTML( "</fieldset>\n\n" );
915
916 # Date format
917 #
918 # Date/Time
919 #
920
921 $wgOut->addHTML(
922 Xml::openElement( 'fieldset' ) .
923 Xml::element( 'legend', null, wfMsg( 'datetime' ) ) . "\n"
924 );
925
926 if ($dateopts) {
927 $wgOut->addHTML(
928 Xml::openElement( 'fieldset' ) .
929 Xml::element( 'legend', null, wfMsg( 'dateformat' ) ) . "\n"
930 );
931 $idCnt = 0;
932 $epoch = '20010115161234'; # Wikipedia day
933 foreach( $dateopts as $key ) {
934 if( $key == 'default' ) {
935 $formatted = wfMsg( 'datedefault' );
936 } else {
937 $formatted = $wgLang->timeanddate( $epoch, false, $key );
938 }
939 $wgOut->addHTML(
940 Xml::tags( 'div', null,
941 Xml::radioLabel( $formatted, 'wpDate', $key, "wpDate$idCnt", $key == $this->mDate )
942 ) . "\n"
943 );
944 $idCnt++;
945 }
946 $wgOut->addHTML( Xml::closeElement( 'fieldset' ) . "\n" );
947 }
948
949 $nowlocal = $wgLang->time( $now = wfTimestampNow(), true );
950 $nowserver = $wgLang->time( $now, false );
951
952 $wgOut->addHTML(
953 Xml::openElement( 'fieldset' ) .
954 Xml::element( 'legend', null, wfMsg( 'timezonelegend' ) ) .
955 Xml::openElement( 'table' ) .
956 $this->addRow( wfMsg( 'servertime' ), $nowserver ) .
957 $this->addRow( wfMsg( 'localtime' ), $nowlocal ) .
958 $this->addRow(
959 Xml::label( wfMsg( 'timezoneoffset' ), 'wpHourDiff' ),
960 Xml::input( 'wpHourDiff', 6, $this->mHourDiff, array( 'id' => 'wpHourDiff' ) ) ) .
961 "<tr>
962 <td></td>
963 <td class='mw-submit'>" .
964 Xml::element( 'input',
965 array( 'type' => 'button',
966 'value' => wfMsg( 'guesstimezone' ),
967 'onclick' => 'javascript:guessTimezone()',
968 'id' => 'guesstimezonebutton',
969 'style' => 'display:none;' ) ) .
970 "</td>
971 </tr>" .
972 Xml::closeElement( 'table' ) .
973 Xml::tags( 'div', array( 'class' => 'prefsectiontip' ), wfMsgExt( 'timezonetext', 'parseinline' ) ).
974 Xml::closeElement( 'fieldset' ) .
975 Xml::closeElement( 'fieldset' ) . "\n\n"
976 );
977
978 # Editing
979 #
980 global $wgLivePreview;
981 $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'textboxsize' ) . '</legend>
982 <div>' .
983 wfInputLabel( wfMsg( 'rows' ), 'wpRows', 'wpRows', 3, $this->mRows ) .
984 ' ' .
985 wfInputLabel( wfMsg( 'columns' ), 'wpCols', 'wpCols', 3, $this->mCols ) .
986 "</div>" .
987 $this->getToggles( array(
988 'editsection',
989 'editsectiononrightclick',
990 'editondblclick',
991 'editwidth',
992 'showtoolbar',
993 'previewonfirst',
994 'previewontop',
995 'minordefault',
996 'externaleditor',
997 'externaldiff',
998 $wgLivePreview ? 'uselivepreview' : false,
999 'forceeditsummary',
1000 ) ) . '</fieldset>'
1001 );
1002
1003 # Recent changes
1004 $wgOut->addHtml( '<fieldset><legend>' . wfMsgHtml( 'prefs-rc' ) . '</legend>' );
1005
1006 $rc = '<table><tr>';
1007 $rc .= '<td>' . Xml::label( wfMsg( 'recentchangesdays' ), 'wpRecentDays' ) . '</td>';
1008 $rc .= '<td>' . Xml::input( 'wpRecentDays', 3, $this->mRecentDays, array( 'id' => 'wpRecentDays' ) ) . '</td>';
1009 $rc .= '</tr><tr>';
1010 $rc .= '<td>' . Xml::label( wfMsg( 'recentchangescount' ), 'wpRecent' ) . '</td>';
1011 $rc .= '<td>' . Xml::input( 'wpRecent', 3, $this->mRecent, array( 'id' => 'wpRecent' ) ) . '</td>';
1012 $rc .= '</tr></table>';
1013 $wgOut->addHtml( $rc );
1014
1015 $wgOut->addHtml( '<br />' );
1016
1017 $toggles[] = 'hideminor';
1018 if( $wgRCShowWatchingUsers )
1019 $toggles[] = 'shownumberswatching';
1020 $toggles[] = 'usenewrc';
1021 $wgOut->addHtml( $this->getToggles( $toggles ) );
1022
1023 $wgOut->addHtml( '</fieldset>' );
1024
1025 # Watchlist
1026 $wgOut->addHtml( '<fieldset><legend>' . wfMsgHtml( 'prefs-watchlist' ) . '</legend>' );
1027
1028 $wgOut->addHtml( wfInputLabel( wfMsg( 'prefs-watchlist-days' ), 'wpWatchlistDays', 'wpWatchlistDays', 3, $this->mWatchlistDays ) );
1029 $wgOut->addHtml( '<br /><br />' );
1030
1031 $wgOut->addHtml( $this->getToggle( 'extendwatchlist' ) );
1032 $wgOut->addHtml( wfInputLabel( wfMsg( 'prefs-watchlist-edits' ), 'wpWatchlistEdits', 'wpWatchlistEdits', 3, $this->mWatchlistEdits ) );
1033 $wgOut->addHtml( '<br /><br />' );
1034
1035 $wgOut->addHtml( $this->getToggles( array( 'watchlisthideminor', 'watchlisthidebots', 'watchlisthideown', 'watchlisthideanons', 'watchlisthideliu' ) ) );
1036
1037 if( $wgUser->isAllowed( 'createpage' ) || $wgUser->isAllowed( 'createtalk' ) )
1038 $wgOut->addHtml( $this->getToggle( 'watchcreations' ) );
1039 foreach( array( 'edit' => 'watchdefault', 'move' => 'watchmoves', 'delete' => 'watchdeletion' ) as $action => $toggle ) {
1040 if( $wgUser->isAllowed( $action ) )
1041 $wgOut->addHtml( $this->getToggle( $toggle ) );
1042 }
1043 $this->mUsedToggles['watchcreations'] = true;
1044 $this->mUsedToggles['watchdefault'] = true;
1045 $this->mUsedToggles['watchmoves'] = true;
1046 $this->mUsedToggles['watchdeletion'] = true;
1047
1048 $wgOut->addHtml( '</fieldset>' );
1049
1050 # Search
1051 $mwsuggest = $wgEnableMWSuggest ?
1052 $this->addRow(
1053 Xml::label( wfMsg( 'mwsuggest-disable' ), 'wpDisableMWSuggest' ),
1054 Xml::check( 'wpDisableMWSuggest', $this->mDisableMWSuggest, array( 'id' => 'wpDisableMWSuggest' ) )
1055 ) : '';
1056 $wgOut->addHTML(
1057 // Elements for the search tab itself
1058 Xml::openElement( 'fieldset' ) .
1059 Xml::element( 'legend', null, wfMsg( 'searchresultshead' ) ) .
1060 // Elements for the search options in the search tab
1061 Xml::openElement( 'fieldset' ) .
1062 Xml::element( 'legend', null, wfMsg( 'prefs-searchoptions' ) ) .
1063 Xml::openElement( 'table' ) .
1064 $this->addRow(
1065 Xml::label( wfMsg( 'resultsperpage' ), 'wpSearch' ),
1066 Xml::input( 'wpSearch', 4, $this->mSearch, array( 'id' => 'wpSearch' ) )
1067 ) .
1068 $this->addRow(
1069 Xml::label( wfMsg( 'contextlines' ), 'wpSearchLines' ),
1070 Xml::input( 'wpSearchLines', 4, $this->mSearchLines, array( 'id' => 'wpSearchLines' ) )
1071 ) .
1072 $this->addRow(
1073 Xml::label( wfMsg( 'contextchars' ), 'wpSearchChars' ),
1074 Xml::input( 'wpSearchChars', 4, $this->mSearchChars, array( 'id' => 'wpSearchChars' ) )
1075 ) .
1076 $mwsuggest .
1077 Xml::closeElement( 'table' ) .
1078 Xml::closeElement( 'fieldset' ) .
1079 // Elements for the namespace options in the search tab
1080 Xml::openElement( 'fieldset' ) .
1081 Xml::element( 'legend', null, wfMsg( 'prefs-namespaces' ) ) .
1082 wfMsgExt( 'defaultns', array( 'parse' ) ) .
1083 $ps .
1084 Xml::closeElement( 'fieldset' ) .
1085 // End of the search tab
1086 Xml::closeElement( 'fieldset' )
1087 );
1088
1089 # Misc
1090 #
1091 $wgOut->addHTML('<fieldset><legend>' . wfMsg('prefs-misc') . '</legend>');
1092 $wgOut->addHtml( '<label for="wpStubs">' . wfMsg( 'stub-threshold' ) . '</label>&nbsp;' );
1093 $wgOut->addHtml( Xml::input( 'wpStubs', 6, $this->mStubs, array( 'id' => 'wpStubs' ) ) );
1094 $msgUnderline = htmlspecialchars( wfMsg ( 'tog-underline' ) );
1095 $msgUnderlinenever = htmlspecialchars( wfMsg ( 'underline-never' ) );
1096 $msgUnderlinealways = htmlspecialchars( wfMsg ( 'underline-always' ) );
1097 $msgUnderlinedefault = htmlspecialchars( wfMsg ( 'underline-default' ) );
1098 $uopt = $wgUser->getOption("underline");
1099 $s0 = $uopt == 0 ? ' selected="selected"' : '';
1100 $s1 = $uopt == 1 ? ' selected="selected"' : '';
1101 $s2 = $uopt == 2 ? ' selected="selected"' : '';
1102 $wgOut->addHTML("
1103 <div class='toggle'><p><label for='wpOpunderline'>$msgUnderline</label>
1104 <select name='wpOpunderline' id='wpOpunderline'>
1105 <option value=\"0\"$s0>$msgUnderlinenever</option>
1106 <option value=\"1\"$s1>$msgUnderlinealways</option>
1107 <option value=\"2\"$s2>$msgUnderlinedefault</option>
1108 </select></p></div>");
1109
1110 foreach ( $togs as $tname ) {
1111 if( !array_key_exists( $tname, $this->mUsedToggles ) ) {
1112 $wgOut->addHTML( $this->getToggle( $tname ) );
1113 }
1114 }
1115 $wgOut->addHTML( '</fieldset>' );
1116
1117 wfRunHooks( 'RenderPreferencesForm', array( $this, $wgOut ) );
1118
1119 $token = htmlspecialchars( $wgUser->editToken() );
1120 $skin = $wgUser->getSkin();
1121 $wgOut->addHTML( "
1122 <div id='prefsubmit'>
1123 <div>
1124 <input type='submit' name='wpSaveprefs' class='btnSavePrefs' value=\"" . wfMsgHtml( 'saveprefs' ) . '"'.$skin->tooltipAndAccesskey('save')." />
1125 <input type='submit' name='wpReset' value=\"" . wfMsgHtml( 'resetprefs' ) . "\" />
1126 </div>
1127
1128 </div>
1129
1130 <input type='hidden' name='wpEditToken' value=\"{$token}\" />
1131 </div></form>\n" );
1132
1133 $wgOut->addHtml( Xml::tags( 'div', array( 'class' => "prefcache" ),
1134 wfMsgExt( 'clearyourcache', 'parseinline' ) )
1135 );
1136 }
1137 }