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