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