Prettify files tab of Special:Preferences a bit
[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 $imageLimitOptions = null;
837 foreach ( $wgImageLimits as $index => $limits ) {
838 $selected = ($index == $this->mImageSize);
839 $imageLimitOptions .= Xml::option( "{$limits[0]}×{$limits[1]}" .
840 wfMsg('unit-pixel'), $index, $selected );
841 }
842
843 $imageThumbOptions = null;
844 foreach ( $wgThumbLimits as $index => $size ) {
845 $selected = ($index == $this->mThumbSize);
846 $imageThumbOptions .= Xml::option($size . wfMsg('unit-pixel'), $index,
847 $selected);
848 }
849
850 $imageSizeId = 'wpImageSize';
851 $thumbSizeId = 'wpThumbSize';
852 $wgOut->addHTML(
853 Xml::fieldset( wfMsg( 'files' ) ) . "\n" .
854 Xml::openElement( 'table' ) .
855 '<tr>
856 <td class="mw-label">' .
857 Xml::label( wfMsg( 'imagemaxsize' ), $imageSizeId ) .
858 '</td>
859 <td class="mw-input">' .
860 Xml::openElement( 'select', array( 'name' => $imageSizeId, 'id' => $imageSizeId ) ) .
861 $imageLimitOptions .
862 Xml::closeElement( 'select' ) .
863 '</td>
864 </tr><tr>
865 <td class="mw-label">' .
866 Xml::label( wfMsg( 'thumbsize' ), $thumbSizeId ) .
867 '</td>
868 <td class="mw-input">' .
869 Xml::openElement( 'select', array( 'name' => $thumbSizeId, 'id' => $thumbSizeId ) ) .
870 $imageThumbOptions .
871 Xml::closeElement( 'select' ) .
872 '</td>
873 </tr>' .
874 Xml::closeElement( 'table' ) .
875 Xml::closeElement( 'fieldset' )
876 );
877
878 # Date format
879 #
880 # Date/Time
881 #
882
883 $wgOut->addHTML(
884 Xml::openElement( 'fieldset' ) .
885 Xml::element( 'legend', null, wfMsg( 'datetime' ) ) . "\n"
886 );
887
888 if ($dateopts) {
889 $wgOut->addHTML(
890 Xml::openElement( 'fieldset' ) .
891 Xml::element( 'legend', null, wfMsg( 'dateformat' ) ) . "\n"
892 );
893 $idCnt = 0;
894 $epoch = '20010115161234'; # Wikipedia day
895 foreach( $dateopts as $key ) {
896 if( $key == 'default' ) {
897 $formatted = wfMsg( 'datedefault' );
898 } else {
899 $formatted = $wgLang->timeanddate( $epoch, false, $key );
900 }
901 $wgOut->addHTML(
902 Xml::tags( 'div', null,
903 Xml::radioLabel( $formatted, 'wpDate', $key, "wpDate$idCnt", $key == $this->mDate )
904 ) . "\n"
905 );
906 $idCnt++;
907 }
908 $wgOut->addHTML( Xml::closeElement( 'fieldset' ) . "\n" );
909 }
910
911 $nowlocal = $wgLang->time( $now = wfTimestampNow(), true );
912 $nowserver = $wgLang->time( $now, false );
913
914 $wgOut->addHTML(
915 Xml::openElement( 'fieldset' ) .
916 Xml::element( 'legend', null, wfMsg( 'timezonelegend' ) ) .
917 Xml::openElement( 'table' ) .
918 $this->addRow( wfMsg( 'servertime' ), $nowserver ) .
919 $this->addRow( wfMsg( 'localtime' ), $nowlocal ) .
920 $this->addRow(
921 Xml::label( wfMsg( 'timezoneoffset' ), 'wpHourDiff' ),
922 Xml::input( 'wpHourDiff', 6, $this->mHourDiff, array( 'id' => 'wpHourDiff' ) ) ) .
923 "<tr>
924 <td></td>
925 <td class='mw-submit'>" .
926 Xml::element( 'input',
927 array( 'type' => 'button',
928 'value' => wfMsg( 'guesstimezone' ),
929 'onclick' => 'javascript:guessTimezone()',
930 'id' => 'guesstimezonebutton',
931 'style' => 'display:none;' ) ) .
932 "</td>
933 </tr>" .
934 Xml::closeElement( 'table' ) .
935 Xml::tags( 'div', array( 'class' => 'prefsectiontip' ), wfMsgExt( 'timezonetext', 'parseinline' ) ).
936 Xml::closeElement( 'fieldset' ) .
937 Xml::closeElement( 'fieldset' ) . "\n\n"
938 );
939
940 # Editing
941 #
942 global $wgLivePreview;
943 $wgOut->addHTML(
944 Xml::fieldset( wfMsg( 'textboxsize' ) ) .
945 wfMsgHTML( 'prefs-edit-boxsize' ) . ' ' .
946 Xml::inputLabel( wfMsg( 'rows' ), 'wpRows', 'wpRows', 3, $this->mRows ) . ' ' .
947 Xml::inputLabel( wfMsg( 'columns' ), 'wpCols', 'wpCols', 3, $this->mCols ) .
948 $this->getToggles( array(
949 'editsection',
950 'editsectiononrightclick',
951 'editondblclick',
952 'editwidth',
953 'showtoolbar',
954 'previewonfirst',
955 'previewontop',
956 'minordefault',
957 'externaleditor',
958 'externaldiff',
959 $wgLivePreview ? 'uselivepreview' : false,
960 'forceeditsummary',
961 ) )
962 );
963
964 $wgOut->addHTML( Xml::closeElement( 'fieldset' ) );
965
966 # Recent changes
967 global $wgRCMaxAge;
968 $wgOut->addHTML(
969 Xml::fieldset( wfMsg( 'prefs-rc' ) ) .
970 Xml::openElement( 'table' ) .
971 '<tr>
972 <td class="mw-label">' .
973 Xml::label( wfMsg( 'recentchangesdays' ), 'wpRecentDays' ) .
974 '</td>
975 <td class="mw-input">' .
976 Xml::input( 'wpRecentDays', 3, $this->mRecentDays, array( 'id' => 'wpRecentDays' ) ) . ' ' .
977 wfMsgExt( 'recentchangesdays-max', 'parsemag',
978 $wgLang->formatNum( ceil( $wgRCMaxAge / ( 3600 * 24 ) ) ) ) .
979 '</td>
980 </tr><tr>
981 <td class="mw-label">' .
982 Xml::label( wfMsg( 'recentchangescount' ), 'wpRecent' ) .
983 '</td>
984 <td class="mw-input">' .
985 Xml::input( 'wpRecent', 3, $this->mRecent, array( 'id' => 'wpRecent' ) ) .
986 '</td>
987 </tr>' .
988 Xml::closeElement( 'table' ) .
989 '<br />'
990 );
991
992 $toggles[] = 'hideminor';
993 if( $wgRCShowWatchingUsers )
994 $toggles[] = 'shownumberswatching';
995 $toggles[] = 'usenewrc';
996
997 $wgOut->addHTML(
998 $this->getToggles( $toggles ) .
999 Xml::closeElement( 'fieldset' )
1000 );
1001
1002 # Watchlist
1003 $wgOut->addHTML(
1004 Xml::fieldset( wfMsg( 'prefs-watchlist' ) ) .
1005 Xml::inputLabel( wfMsg( 'prefs-watchlist-days' ), 'wpWatchlistDays', 'wpWatchlistDays', 3, $this->mWatchlistDays ) . ' ' .
1006 wfMsgHTML( 'prefs-watchlist-days-max' ) .
1007 '<br /><br />' .
1008 $this->getToggle( 'extendwatchlist' ) .
1009 Xml::inputLabel( wfMsg( 'prefs-watchlist-edits' ), 'wpWatchlistEdits', 'wpWatchlistEdits', 3, $this->mWatchlistEdits ) . ' ' .
1010 wfMsgHTML( 'prefs-watchlist-edits-max' ) .
1011 '<br /><br />' .
1012 $this->getToggles( array( 'watchlisthideminor', 'watchlisthidebots', 'watchlisthideown', 'watchlisthideanons', 'watchlisthideliu' ) )
1013 );
1014
1015 if( $wgUser->isAllowed( 'createpage' ) || $wgUser->isAllowed( 'createtalk' ) ) {
1016 $wgOut->addHTML( $this->getToggle( 'watchcreations' ) );
1017 }
1018
1019 foreach( array( 'edit' => 'watchdefault', 'move' => 'watchmoves', 'delete' => 'watchdeletion' ) as $action => $toggle ) {
1020 if( $wgUser->isAllowed( $action ) )
1021 $wgOut->addHTML( $this->getToggle( $toggle ) );
1022 }
1023 $this->mUsedToggles['watchcreations'] = true;
1024 $this->mUsedToggles['watchdefault'] = true;
1025 $this->mUsedToggles['watchmoves'] = true;
1026 $this->mUsedToggles['watchdeletion'] = true;
1027
1028 $wgOut->addHTML( Xml::closeElement( 'fieldset' ) );
1029
1030 # Search
1031 $mwsuggest = $wgEnableMWSuggest ?
1032 $this->addRow(
1033 Xml::label( wfMsg( 'mwsuggest-disable' ), 'wpDisableMWSuggest' ),
1034 Xml::check( 'wpDisableMWSuggest', $this->mDisableMWSuggest, array( 'id' => 'wpDisableMWSuggest' ) )
1035 ) : '';
1036 $wgOut->addHTML(
1037 // Elements for the search tab itself
1038 Xml::openElement( 'fieldset' ) .
1039 Xml::element( 'legend', null, wfMsg( 'searchresultshead' ) ) .
1040 // Elements for the search options in the search tab
1041 Xml::openElement( 'fieldset' ) .
1042 Xml::element( 'legend', null, wfMsg( 'prefs-searchoptions' ) ) .
1043 Xml::openElement( 'table' ) .
1044 $this->addRow(
1045 Xml::label( wfMsg( 'resultsperpage' ), 'wpSearch' ),
1046 Xml::input( 'wpSearch', 4, $this->mSearch, array( 'id' => 'wpSearch' ) )
1047 ) .
1048 $this->addRow(
1049 Xml::label( wfMsg( 'contextlines' ), 'wpSearchLines' ),
1050 Xml::input( 'wpSearchLines', 4, $this->mSearchLines, array( 'id' => 'wpSearchLines' ) )
1051 ) .
1052 $this->addRow(
1053 Xml::label( wfMsg( 'contextchars' ), 'wpSearchChars' ),
1054 Xml::input( 'wpSearchChars', 4, $this->mSearchChars, array( 'id' => 'wpSearchChars' ) )
1055 ) .
1056 $mwsuggest .
1057 Xml::closeElement( 'table' ) .
1058 Xml::closeElement( 'fieldset' ) .
1059 // Elements for the namespace options in the search tab
1060 Xml::openElement( 'fieldset' ) .
1061 Xml::element( 'legend', null, wfMsg( 'prefs-namespaces' ) ) .
1062 wfMsgExt( 'defaultns', array( 'parse' ) ) .
1063 $ps .
1064 Xml::closeElement( 'fieldset' ) .
1065 // End of the search tab
1066 Xml::closeElement( 'fieldset' )
1067 );
1068
1069 # Misc
1070 #
1071 $wgOut->addHTML('<fieldset><legend>' . wfMsg('prefs-misc') . '</legend>');
1072 $wgOut->addHTML( '<label for="wpStubs">' . wfMsg( 'stub-threshold' ) . '</label>&nbsp;' );
1073 $wgOut->addHTML( Xml::input( 'wpStubs', 6, $this->mStubs, array( 'id' => 'wpStubs' ) ) );
1074 $msgUnderline = htmlspecialchars( wfMsg ( 'tog-underline' ) );
1075 $msgUnderlinenever = htmlspecialchars( wfMsg ( 'underline-never' ) );
1076 $msgUnderlinealways = htmlspecialchars( wfMsg ( 'underline-always' ) );
1077 $msgUnderlinedefault = htmlspecialchars( wfMsg ( 'underline-default' ) );
1078 $uopt = $wgUser->getOption("underline");
1079 $s0 = $uopt == 0 ? ' selected="selected"' : '';
1080 $s1 = $uopt == 1 ? ' selected="selected"' : '';
1081 $s2 = $uopt == 2 ? ' selected="selected"' : '';
1082 $wgOut->addHTML("
1083 <div class='toggle'><p><label for='wpOpunderline'>$msgUnderline</label>
1084 <select name='wpOpunderline' id='wpOpunderline'>
1085 <option value=\"0\"$s0>$msgUnderlinenever</option>
1086 <option value=\"1\"$s1>$msgUnderlinealways</option>
1087 <option value=\"2\"$s2>$msgUnderlinedefault</option>
1088 </select></p></div>");
1089
1090 foreach ( $togs as $tname ) {
1091 if( !array_key_exists( $tname, $this->mUsedToggles ) ) {
1092 if( $tname == 'norollbackdiff' && $wgUser->isAllowed( 'rollback' ) )
1093 $wgOut->addHTML( $this->getToggle( $tname ) );
1094 else
1095 $wgOut->addHTML( $this->getToggle( $tname ) );
1096 }
1097 }
1098
1099 $wgOut->addHTML( '</fieldset>' );
1100
1101 wfRunHooks( 'RenderPreferencesForm', array( $this, $wgOut ) );
1102
1103 $token = htmlspecialchars( $wgUser->editToken() );
1104 $skin = $wgUser->getSkin();
1105 $wgOut->addHTML( "
1106 <div id='prefsubmit'>
1107 <div>
1108 <input type='submit' name='wpSaveprefs' class='btnSavePrefs' value=\"" . wfMsgHtml( 'saveprefs' ) . '"'.$skin->tooltipAndAccesskey('save')." />
1109 <input type='submit' name='wpReset' value=\"" . wfMsgHtml( 'resetprefs' ) . "\" />
1110 </div>
1111
1112 </div>
1113
1114 <input type='hidden' name='wpEditToken' value=\"{$token}\" />
1115 </div></form>\n" );
1116
1117 $wgOut->addHTML( Xml::tags( 'div', array( 'class' => "prefcache" ),
1118 wfMsgExt( 'clearyourcache', 'parseinline' ) )
1119 );
1120 }
1121 }