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