3 * Form to edit user preferences.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
24 * We're now using the HTMLForm object with some customisation to generate the
25 * Preferences form. This object handles generic submission, CSRF protection,
26 * layout and other logic in a reusable manner. We subclass it as a PreferencesForm
27 * to make some minor customisations.
29 * In order to generate the form, the HTMLForm object needs an array structure
30 * detailing the form fields available, and that's what this class is for. Each
31 * element of the array is a basic property-list, including the type of field,
32 * the label it is to be given in the form, callbacks for validation and
33 * 'filtering', and other pertinent information. Note that the 'default' field
34 * is named for generic forms, and does not represent the preference's default
35 * (which is stored in $wgDefaultUserOptions), but the default for the form
36 * field, which should be whatever the user has set for that preference. There
37 * is no need to override it unless you have some special storage logic (for
38 * instance, those not presently stored as options, but which are best set from
39 * the user preferences view).
41 * Field types are implemented as subclasses of the generic HTMLFormField
42 * object, and typically implement at least getInputHTML, which generates the
43 * HTML for the input field to be placed in the table.
45 * Once fields have been retrieved and validated, submission logic is handed
46 * over to the tryUISubmit static method of this class.
49 static $defaultPreferences = null;
50 static $saveFilters = array(
51 'timecorrection' => array( 'Preferences', 'filterTimezoneInput' ),
52 'cols' => array( 'Preferences', 'filterIntval' ),
53 'rows' => array( 'Preferences', 'filterIntval' ),
54 'rclimit' => array( 'Preferences', 'filterIntval' ),
55 'wllimit' => array( 'Preferences', 'filterIntval' ),
56 'searchlimit' => array( 'Preferences', 'filterIntval' ),
62 * @param $context IContextSource
65 static function getPreferences( $user, IContextSource
$context ) {
66 if ( self
::$defaultPreferences ) {
67 return self
::$defaultPreferences;
70 $defaultPreferences = array();
72 self
::profilePreferences( $user, $context, $defaultPreferences );
73 self
::skinPreferences( $user, $context, $defaultPreferences );
74 self
::filesPreferences( $user, $context, $defaultPreferences );
75 self
::datetimePreferences( $user, $context, $defaultPreferences );
76 self
::renderingPreferences( $user, $context, $defaultPreferences );
77 self
::editingPreferences( $user, $context, $defaultPreferences );
78 self
::rcPreferences( $user, $context, $defaultPreferences );
79 self
::watchlistPreferences( $user, $context, $defaultPreferences );
80 self
::searchPreferences( $user, $context, $defaultPreferences );
81 self
::miscPreferences( $user, $context, $defaultPreferences );
83 wfRunHooks( 'GetPreferences', array( $user, &$defaultPreferences ) );
85 ## Remove preferences that wikis don't want to use
86 global $wgHiddenPrefs;
87 foreach ( $wgHiddenPrefs as $pref ) {
88 if ( isset( $defaultPreferences[$pref] ) ) {
89 unset( $defaultPreferences[$pref] );
93 ## Make sure that form fields have their parent set. See bug 41337.
94 $dummyForm = new HTMLForm( array(), $context );
96 ## Prod in defaults from the user
97 foreach ( $defaultPreferences as $name => &$info ) {
98 $prefFromUser = self
::getOptionFromUser( $name, $info, $user );
99 $field = HTMLForm
::loadInputFromParameters( $name, $info ); // For validation
100 $field->mParent
= $dummyForm;
101 $defaultOptions = User
::getDefaultOptions();
102 $globalDefault = isset( $defaultOptions[$name] )
103 ?
$defaultOptions[$name]
106 // If it validates, set it as the default
107 if ( isset( $info['default'] ) ) {
108 // Already set, no problem
110 } elseif ( !is_null( $prefFromUser ) && // Make sure we're not just pulling nothing
111 $field->validate( $prefFromUser, $user->getOptions() ) === true ) {
112 $info['default'] = $prefFromUser;
113 } elseif ( $field->validate( $globalDefault, $user->getOptions() ) === true ) {
114 $info['default'] = $globalDefault;
116 throw new MWException( "Global default '$globalDefault' is invalid for field $name" );
120 self
::$defaultPreferences = $defaultPreferences;
122 return $defaultPreferences;
126 * Pull option from a user account. Handles stuff like array-type preferences.
131 * @return array|String
133 static function getOptionFromUser( $name, $info, $user ) {
134 $val = $user->getOption( $name );
136 // Handling for multiselect preferences
137 if ( ( isset( $info['type'] ) && $info['type'] == 'multiselect' ) ||
138 ( isset( $info['class'] ) && $info['class'] == 'HTMLMultiSelectField' ) ) {
139 $options = HTMLFormField
::flattenOptions( $info['options'] );
140 $prefix = isset( $info['prefix'] ) ?
$info['prefix'] : $name;
143 foreach ( $options as $value ) {
144 if ( $user->getOption( "$prefix$value" ) ) {
150 // Handling for checkmatrix preferences
151 if ( ( isset( $info['type'] ) && $info['type'] == 'checkmatrix' ) ||
152 ( isset( $info['class'] ) && $info['class'] == 'HTMLCheckMatrix' ) ) {
153 $columns = HTMLFormField
::flattenOptions( $info['columns'] );
154 $rows = HTMLFormField
::flattenOptions( $info['rows'] );
155 $prefix = isset( $info['prefix'] ) ?
$info['prefix'] : $name;
158 foreach ( $columns as $column ) {
159 foreach ( $rows as $row ) {
160 if ( $user->getOption( "$prefix$column-$row" ) ) {
161 $val[] = "$column-$row";
172 * @param $context IContextSource
173 * @param $defaultPreferences
176 static function profilePreferences( $user, IContextSource
$context, &$defaultPreferences ) {
177 global $wgAuth, $wgContLang, $wgParser, $wgCookieExpiration, $wgLanguageCode,
178 $wgDisableTitleConversion, $wgDisableLangConversion, $wgMaxSigChars,
179 $wgEnableEmail, $wgEmailConfirmToEdit, $wgEnableUserEmail, $wgEmailAuthentication,
180 $wgEnotifWatchlist, $wgEnotifUserTalk, $wgEnotifRevealEditorAddress;
182 // retrieving user name for GENDER and misc.
183 $userName = $user->getName();
185 ## User info #####################################
187 $defaultPreferences['username'] = array(
189 'label-message' => array( 'username', $userName ),
190 'default' => $userName,
191 'section' => 'personal/info',
194 $defaultPreferences['userid'] = array(
196 'label-message' => array( 'uid', $userName ),
197 'default' => $user->getId(),
198 'section' => 'personal/info',
201 # Get groups to which the user belongs
202 $userEffectiveGroups = $user->getEffectiveGroups();
203 $userGroups = $userMembers = array();
204 foreach ( $userEffectiveGroups as $ueg ) {
206 // Skip the default * group, seems useless here
209 $groupName = User
::getGroupName( $ueg );
210 $userGroups[] = User
::makeGroupLinkHTML( $ueg, $groupName );
212 $memberName = User
::getGroupMember( $ueg, $userName );
213 $userMembers[] = User
::makeGroupLinkHTML( $ueg, $memberName );
215 asort( $userGroups );
216 asort( $userMembers );
218 $lang = $context->getLanguage();
220 $defaultPreferences['usergroups'] = array(
222 'label' => $context->msg( 'prefs-memberingroups' )->numParams(
223 count( $userGroups ) )->params( $userName )->parse(),
224 'default' => $context->msg( 'prefs-memberingroups-type',
225 $lang->commaList( $userGroups ),
226 $lang->commaList( $userMembers )
229 'section' => 'personal/info',
232 $defaultPreferences['editcount'] = array(
234 'label-message' => 'prefs-edits',
235 'default' => $lang->formatNum( $user->getEditCount() ),
236 'section' => 'personal/info',
239 if ( $user->getRegistration() ) {
240 $displayUser = $context->getUser();
241 $userRegistration = $user->getRegistration();
242 $defaultPreferences['registrationdate'] = array(
244 'label-message' => 'prefs-registration',
245 'default' => $context->msg(
246 'prefs-registration-date-time',
247 $lang->userTimeAndDate( $userRegistration, $displayUser ),
248 $lang->userDate( $userRegistration, $displayUser ),
249 $lang->userTime( $userRegistration, $displayUser )
251 'section' => 'personal/info',
255 // Actually changeable stuff
256 $defaultPreferences['realname'] = array(
257 'type' => $wgAuth->allowPropChange( 'realname' ) ?
'text' : 'info',
258 'default' => $user->getRealName(),
259 'section' => 'personal/info',
260 'label-message' => 'yourrealname',
261 'help-message' => 'prefs-help-realname',
264 $defaultPreferences['gender'] = array(
266 'section' => 'personal/info',
268 $context->msg( 'gender-male' )->text() => 'male',
269 $context->msg( 'gender-female' )->text() => 'female',
270 $context->msg( 'gender-unknown' )->text() => 'unknown',
272 'label-message' => 'yourgender',
273 'help-message' => 'prefs-help-gender',
276 if ( $wgAuth->allowPasswordChange() ) {
277 $link = Linker
::link( SpecialPage
::getTitleFor( 'ChangePassword' ),
278 $context->msg( 'prefs-resetpass' )->escaped(), array(),
279 array( 'returnto' => SpecialPage
::getTitleFor( 'Preferences' )->getPrefixedText() ) );
281 $defaultPreferences['password'] = array(
285 'label-message' => 'yourpassword',
286 'section' => 'personal/info',
289 if ( $wgCookieExpiration > 0 ) {
290 $defaultPreferences['rememberpassword'] = array(
292 'label' => $context->msg( 'tog-rememberpassword' )->numParams(
293 ceil( $wgCookieExpiration / ( 3600 * 24 ) ) )->text(),
294 'section' => 'personal/info',
299 $languages = Language
::fetchLanguageNames( null, 'mw' );
300 if ( !array_key_exists( $wgLanguageCode, $languages ) ) {
301 $languages[$wgLanguageCode] = $wgLanguageCode;
306 foreach ( $languages as $code => $name ) {
307 $display = wfBCP47( $code ) . ' - ' . $name;
308 $options[$display] = $code;
310 $defaultPreferences['language'] = array(
312 'section' => 'personal/i18n',
313 'options' => $options,
314 'label-message' => 'yourlanguage',
317 // see if there are multiple language variants to choose from
318 if ( !$wgDisableLangConversion ) {
319 $variants = $wgContLang->getVariants();
321 if ( count( $variants ) > 1 ) {
322 $variantArray = array();
323 foreach ( $variants as $v ) {
324 $v = str_replace( '_', '-', strtolower( $v ) );
325 $variantArray[$v] = $wgContLang->getVariantname( $v, false );
329 foreach ( $variantArray as $code => $name ) {
330 $display = wfBCP47( $code ) . ' - ' . $name;
331 $options[$display] = $code;
334 $defaultPreferences['variant'] = array(
335 'label-message' => 'yourvariant',
337 'options' => $options,
338 'section' => 'personal/i18n',
339 'help-message' => 'prefs-help-variant',
342 if ( !$wgDisableTitleConversion ) {
343 $defaultPreferences['noconvertlink'] =
346 'section' => 'personal/i18n',
347 'label-message' => 'tog-noconvertlink',
353 // show a preview of the old signature first
354 $oldsigWikiText = $wgParser->preSaveTransform( "~~~", $context->getTitle(), $user, ParserOptions
::newFromContext( $context ) );
355 $oldsigHTML = $context->getOutput()->parseInline( $oldsigWikiText, true, true );
356 $defaultPreferences['oldsig'] = array(
359 'label-message' => 'tog-oldsig',
360 'default' => $oldsigHTML,
361 'section' => 'personal/signature',
363 $defaultPreferences['nickname'] = array(
364 'type' => $wgAuth->allowPropChange( 'nickname' ) ?
'text' : 'info',
365 'maxlength' => $wgMaxSigChars,
366 'label-message' => 'yournick',
367 'validation-callback' => array( 'Preferences', 'validateSignature' ),
368 'section' => 'personal/signature',
369 'filter-callback' => array( 'Preferences', 'cleanSignature' ),
371 $defaultPreferences['fancysig'] = array(
373 'label-message' => 'tog-fancysig',
374 'help-message' => 'prefs-help-signature', // show general help about signature at the bottom of the section
375 'section' => 'personal/signature'
380 if ( $wgEnableEmail ) {
381 $helpMessages[] = $wgEmailConfirmToEdit
382 ?
'prefs-help-email-required'
383 : 'prefs-help-email';
385 if ( $wgEnableUserEmail ) {
386 // additional messages when users can send email to each other
387 $helpMessages[] = 'prefs-help-email-others';
390 $link = Linker
::link(
391 SpecialPage
::getTitleFor( 'ChangeEmail' ),
392 $context->msg( $user->getEmail() ?
'prefs-changeemail' : 'prefs-setemail' )->escaped(),
394 array( 'returnto' => SpecialPage
::getTitleFor( 'Preferences' )->getPrefixedText() ) );
396 $emailAddress = $user->getEmail() ?
htmlspecialchars( $user->getEmail() ) : '';
397 if ( $wgAuth->allowPropChange( 'emailaddress' ) ) {
398 $emailAddress .= $emailAddress == '' ?
$link : (
399 $context->msg( 'word-separator' )->plain()
400 . $context->msg( 'parentheses' )->rawParams( $link )->plain()
404 $defaultPreferences['emailaddress'] = array(
407 'default' => $emailAddress,
408 'label-message' => 'youremail',
409 'section' => 'personal/email',
410 'help-messages' => $helpMessages,
411 # 'cssclass' chosen below
414 $disableEmailPrefs = false;
416 if ( $wgEmailAuthentication ) {
417 $emailauthenticationclass = 'mw-email-not-authenticated';
418 if ( $user->getEmail() ) {
419 if ( $user->getEmailAuthenticationTimestamp() ) {
420 // date and time are separate parameters to facilitate localisation.
421 // $time is kept for backward compat reasons.
422 // 'emailauthenticated' is also used in SpecialConfirmemail.php
423 $displayUser = $context->getUser();
424 $emailTimestamp = $user->getEmailAuthenticationTimestamp();
425 $time = $lang->userTimeAndDate( $emailTimestamp, $displayUser );
426 $d = $lang->userDate( $emailTimestamp, $displayUser );
427 $t = $lang->userTime( $emailTimestamp, $displayUser );
428 $emailauthenticated = $context->msg( 'emailauthenticated',
429 $time, $d, $t )->parse() . '<br />';
430 $disableEmailPrefs = false;
431 $emailauthenticationclass = 'mw-email-authenticated';
433 $disableEmailPrefs = true;
434 $emailauthenticated = $context->msg( 'emailnotauthenticated' )->parse() . '<br />' .
436 SpecialPage
::getTitleFor( 'Confirmemail' ),
437 $context->msg( 'emailconfirmlink' )->escaped()
439 $emailauthenticationclass = "mw-email-not-authenticated";
442 $disableEmailPrefs = true;
443 $emailauthenticated = $context->msg( 'noemailprefs' )->escaped();
444 $emailauthenticationclass = 'mw-email-none';
447 $defaultPreferences['emailauthentication'] = array(
450 'section' => 'personal/email',
451 'label-message' => 'prefs-emailconfirm-label',
452 'default' => $emailauthenticated,
453 # Apply the same CSS class used on the input to the message:
454 'cssclass' => $emailauthenticationclass,
456 $defaultPreferences['emailaddress']['cssclass'] = $emailauthenticationclass;
459 if ( $wgEnableUserEmail && $user->isAllowed( 'sendemail' ) ) {
460 $defaultPreferences['disablemail'] = array(
463 'section' => 'personal/email',
464 'label-message' => 'allowemail',
465 'disabled' => $disableEmailPrefs,
467 $defaultPreferences['ccmeonemails'] = array(
469 'section' => 'personal/email',
470 'label-message' => 'tog-ccmeonemails',
471 'disabled' => $disableEmailPrefs,
475 if ( $wgEnotifWatchlist ) {
476 $defaultPreferences['enotifwatchlistpages'] = array(
478 'section' => 'personal/email',
479 'label-message' => 'tog-enotifwatchlistpages',
480 'disabled' => $disableEmailPrefs,
483 if ( $wgEnotifUserTalk ) {
484 $defaultPreferences['enotifusertalkpages'] = array(
486 'section' => 'personal/email',
487 'label-message' => 'tog-enotifusertalkpages',
488 'disabled' => $disableEmailPrefs,
491 if ( $wgEnotifUserTalk ||
$wgEnotifWatchlist ) {
492 $defaultPreferences['enotifminoredits'] = array(
494 'section' => 'personal/email',
495 'label-message' => 'tog-enotifminoredits',
496 'disabled' => $disableEmailPrefs,
499 if ( $wgEnotifRevealEditorAddress ) {
500 $defaultPreferences['enotifrevealaddr'] = array(
502 'section' => 'personal/email',
503 'label-message' => 'tog-enotifrevealaddr',
504 'disabled' => $disableEmailPrefs,
513 * @param $context IContextSource
514 * @param $defaultPreferences
517 static function skinPreferences( $user, IContextSource
$context, &$defaultPreferences ) {
518 ## Skin #####################################
519 global $wgAllowUserCss, $wgAllowUserJs;
521 $defaultPreferences['skin'] = array(
523 'options' => self
::generateSkinOptions( $user, $context ),
525 'section' => 'rendering/skin',
528 # Create links to user CSS/JS pages for all skins
529 # This code is basically copied from generateSkinOptions(). It'd
530 # be nice to somehow merge this back in there to avoid redundancy.
531 if ( $wgAllowUserCss ||
$wgAllowUserJs ) {
532 $linkTools = array();
533 $userName = $user->getName();
535 if ( $wgAllowUserCss ) {
536 $cssPage = Title
::makeTitleSafe( NS_USER
, $userName . '/common.css' );
537 $linkTools[] = Linker
::link( $cssPage, $context->msg( 'prefs-custom-css' )->escaped() );
540 if ( $wgAllowUserJs ) {
541 $jsPage = Title
::makeTitleSafe( NS_USER
, $userName . '/common.js' );
542 $linkTools[] = Linker
::link( $jsPage, $context->msg( 'prefs-custom-js' )->escaped() );
545 $defaultPreferences['commoncssjs'] = array(
548 'default' => $context->getLanguage()->pipeList( $linkTools ),
549 'label-message' => 'prefs-common-css-js',
550 'section' => 'rendering/skin',
557 * @param $context IContextSource
558 * @param $defaultPreferences Array
560 static function filesPreferences( $user, IContextSource
$context, &$defaultPreferences ) {
561 ## Files #####################################
562 $defaultPreferences['imagesize'] = array(
564 'options' => self
::getImageSizes( $context ),
565 'label-message' => 'imagemaxsize',
566 'section' => 'rendering/files',
568 $defaultPreferences['thumbsize'] = array(
570 'options' => self
::getThumbSizes( $context ),
571 'label-message' => 'thumbsize',
572 'section' => 'rendering/files',
578 * @param $context IContextSource
579 * @param $defaultPreferences
582 static function datetimePreferences( $user, IContextSource
$context, &$defaultPreferences ) {
583 ## Date and time #####################################
584 $dateOptions = self
::getDateOptions( $context );
585 if ( $dateOptions ) {
586 $defaultPreferences['date'] = array(
588 'options' => $dateOptions,
590 'section' => 'datetime/dateformat',
595 $now = wfTimestampNow();
596 $lang = $context->getLanguage();
597 $nowlocal = Xml
::element( 'span', array( 'id' => 'wpLocalTime' ),
598 $lang->time( $now, true ) );
599 $nowserver = $lang->time( $now, false ) .
600 Html
::hidden( 'wpServerTime', (int)substr( $now, 8, 2 ) * 60 +
(int)substr( $now, 10, 2 ) );
602 $defaultPreferences['nowserver'] = array(
605 'label-message' => 'servertime',
606 'default' => $nowserver,
607 'section' => 'datetime/timeoffset',
610 $defaultPreferences['nowlocal'] = array(
613 'label-message' => 'localtime',
614 'default' => $nowlocal,
615 'section' => 'datetime/timeoffset',
618 // Grab existing pref.
619 $tzOffset = $user->getOption( 'timecorrection' );
620 $tz = explode( '|', $tzOffset, 3 );
622 $tzOptions = self
::getTimezoneOptions( $context );
624 $tzSetting = $tzOffset;
625 if ( count( $tz ) > 1 && $tz[0] == 'Offset' ) {
627 $tzSetting = sprintf( '%+03d:%02d', floor( $minDiff / 60 ), abs( $minDiff ) %
60 );
628 } elseif ( count( $tz ) > 1 && $tz[0] == 'ZoneInfo' &&
629 !in_array( $tzOffset, HTMLFormField
::flattenOptions( $tzOptions ) ) )
631 # Timezone offset can vary with DST
632 $userTZ = timezone_open( $tz[2] );
633 if ( $userTZ !== false ) {
634 $minDiff = floor( timezone_offset_get( $userTZ, date_create( 'now' ) ) / 60 );
635 $tzSetting = "ZoneInfo|$minDiff|{$tz[2]}";
639 $defaultPreferences['timecorrection'] = array(
640 'class' => 'HTMLSelectOrOtherField',
641 'label-message' => 'timezonelegend',
642 'options' => $tzOptions,
643 'default' => $tzSetting,
645 'section' => 'datetime/timeoffset',
651 * @param $context IContextSource
652 * @param $defaultPreferences Array
654 static function renderingPreferences( $user, IContextSource
$context, &$defaultPreferences ) {
655 ## Page Rendering ##############################
656 global $wgAllowUserCssPrefs;
657 if ( $wgAllowUserCssPrefs ) {
658 $defaultPreferences['underline'] = array(
661 $context->msg( 'underline-never' )->text() => 0,
662 $context->msg( 'underline-always' )->text() => 1,
663 $context->msg( 'underline-default' )->text() => 2,
665 'label-message' => 'tog-underline',
666 'section' => 'rendering/advancedrendering',
670 $stubThresholdValues = array( 50, 100, 500, 1000, 2000, 5000, 10000 );
671 $stubThresholdOptions = array( $context->msg( 'stub-threshold-disabled' )->text() => 0 );
672 foreach ( $stubThresholdValues as $value ) {
673 $stubThresholdOptions[$context->msg( 'size-bytes', $value )->text()] = $value;
676 $defaultPreferences['stubthreshold'] = array(
677 'type' => 'selectorother',
678 'section' => 'rendering/advancedrendering',
679 'options' => $stubThresholdOptions,
681 'label-raw' => $context->msg( 'stub-threshold' )->text(), // Raw HTML message. Yay?
684 if ( $wgAllowUserCssPrefs ) {
685 $defaultPreferences['showtoc'] = array(
687 'section' => 'rendering/advancedrendering',
688 'label-message' => 'tog-showtoc',
691 $defaultPreferences['nocache'] = array(
693 'label-message' => 'tog-nocache',
694 'section' => 'rendering/advancedrendering',
696 $defaultPreferences['showhiddencats'] = array(
698 'section' => 'rendering/advancedrendering',
699 'label-message' => 'tog-showhiddencats'
701 $defaultPreferences['showjumplinks'] = array(
703 'section' => 'rendering/advancedrendering',
704 'label-message' => 'tog-showjumplinks',
707 if ( $wgAllowUserCssPrefs ) {
708 $defaultPreferences['justify'] = array(
710 'section' => 'rendering/advancedrendering',
711 'label-message' => 'tog-justify',
715 $defaultPreferences['numberheadings'] = array(
717 'section' => 'rendering/advancedrendering',
718 'label-message' => 'tog-numberheadings',
724 * @param $context IContextSource
725 * @param $defaultPreferences Array
727 static function editingPreferences( $user, IContextSource
$context, &$defaultPreferences ) {
728 global $wgAllowUserCssPrefs;
730 ## Editing #####################################
731 $defaultPreferences['cols'] = array(
733 'label-message' => 'columns',
734 'section' => 'editing/textboxsize',
738 $defaultPreferences['rows'] = array(
740 'label-message' => 'rows',
741 'section' => 'editing/textboxsize',
746 if ( $wgAllowUserCssPrefs ) {
747 $defaultPreferences['editfont'] = array(
749 'section' => 'editing/advancedediting',
750 'label-message' => 'editfont-style',
752 $context->msg( 'editfont-default' )->text() => 'default',
753 $context->msg( 'editfont-monospace' )->text() => 'monospace',
754 $context->msg( 'editfont-sansserif' )->text() => 'sans-serif',
755 $context->msg( 'editfont-serif' )->text() => 'serif',
759 $defaultPreferences['previewontop'] = array(
761 'section' => 'editing/advancedediting',
762 'label-message' => 'tog-previewontop',
764 $defaultPreferences['previewonfirst'] = array(
766 'section' => 'editing/advancedediting',
767 'label-message' => 'tog-previewonfirst',
770 if ( $wgAllowUserCssPrefs ) {
771 $defaultPreferences['editsection'] = array(
773 'section' => 'editing/advancedediting',
774 'label-message' => 'tog-editsection',
777 $defaultPreferences['editsectiononrightclick'] = array(
779 'section' => 'editing/advancedediting',
780 'label-message' => 'tog-editsectiononrightclick',
782 $defaultPreferences['editondblclick'] = array(
784 'section' => 'editing/advancedediting',
785 'label-message' => 'tog-editondblclick',
787 $defaultPreferences['showtoolbar'] = array(
789 'section' => 'editing/advancedediting',
790 'label-message' => 'tog-showtoolbar',
793 if ( $user->isAllowed( 'minoredit' ) ) {
794 $defaultPreferences['minordefault'] = array(
796 'section' => 'editing/advancedediting',
797 'label-message' => 'tog-minordefault',
801 $defaultPreferences['forceeditsummary'] = array(
803 'section' => 'editing/advancedediting',
804 'label-message' => 'tog-forceeditsummary',
807 $defaultPreferences['uselivepreview'] = array(
809 'section' => 'editing/advancedediting',
810 'label-message' => 'tog-uselivepreview',
813 $defaultPreferences['useeditwarning'] = array(
815 'section' => 'editing/advancedediting',
816 'label-message' => 'tog-useeditwarning',
823 * @param $context IContextSource
824 * @param $defaultPreferences Array
826 static function rcPreferences( $user, IContextSource
$context, &$defaultPreferences ) {
827 global $wgRCMaxAge, $wgRCShowWatchingUsers;
829 ## RecentChanges #####################################
830 $defaultPreferences['rcdays'] = array(
832 'label-message' => 'recentchangesdays',
833 'section' => 'rc/displayrc',
835 'max' => ceil( $wgRCMaxAge / ( 3600 * 24 ) ),
836 'help' => $context->msg( 'recentchangesdays-max' )->numParams(
837 ceil( $wgRCMaxAge / ( 3600 * 24 ) ) )->text()
839 $defaultPreferences['rclimit'] = array(
841 'label-message' => 'recentchangescount',
842 'help-message' => 'prefs-help-recentchangescount',
843 'section' => 'rc/displayrc',
845 $defaultPreferences['usenewrc'] = array(
847 'label-message' => 'tog-usenewrc',
848 'section' => 'rc/advancedrc',
850 $defaultPreferences['hideminor'] = array(
852 'label-message' => 'tog-hideminor',
853 'section' => 'rc/advancedrc',
856 if ( $user->useRCPatrol() ) {
857 $defaultPreferences['hidepatrolled'] = array(
859 'section' => 'rc/advancedrc',
860 'label-message' => 'tog-hidepatrolled',
862 $defaultPreferences['newpageshidepatrolled'] = array(
864 'section' => 'rc/advancedrc',
865 'label-message' => 'tog-newpageshidepatrolled',
869 if ( $wgRCShowWatchingUsers ) {
870 $defaultPreferences['shownumberswatching'] = array(
872 'section' => 'rc/advancedrc',
873 'label-message' => 'tog-shownumberswatching',
880 * @param $context IContextSource
881 * @param $defaultPreferences
883 static function watchlistPreferences( $user, IContextSource
$context, &$defaultPreferences ) {
884 global $wgUseRCPatrol, $wgEnableAPI, $wgRCMaxAge;
886 $watchlistdaysMax = ceil( $wgRCMaxAge / ( 3600 * 24 ) );
888 ## Watchlist #####################################
889 $defaultPreferences['watchlistdays'] = array(
892 'max' => $watchlistdaysMax,
893 'section' => 'watchlist/displaywatchlist',
894 'help' => $context->msg( 'prefs-watchlist-days-max' )->numParams(
895 $watchlistdaysMax )->text(),
896 'label-message' => 'prefs-watchlist-days',
898 $defaultPreferences['wllimit'] = array(
902 'label-message' => 'prefs-watchlist-edits',
903 'help' => $context->msg( 'prefs-watchlist-edits-max' )->escaped(),
904 'section' => 'watchlist/displaywatchlist',
906 $defaultPreferences['extendwatchlist'] = array(
908 'section' => 'watchlist/advancedwatchlist',
909 'label-message' => 'tog-extendwatchlist',
911 $defaultPreferences['watchlisthideminor'] = array(
913 'section' => 'watchlist/advancedwatchlist',
914 'label-message' => 'tog-watchlisthideminor',
916 $defaultPreferences['watchlisthidebots'] = array(
918 'section' => 'watchlist/advancedwatchlist',
919 'label-message' => 'tog-watchlisthidebots',
921 $defaultPreferences['watchlisthideown'] = array(
923 'section' => 'watchlist/advancedwatchlist',
924 'label-message' => 'tog-watchlisthideown',
926 $defaultPreferences['watchlisthideanons'] = array(
928 'section' => 'watchlist/advancedwatchlist',
929 'label-message' => 'tog-watchlisthideanons',
931 $defaultPreferences['watchlisthideliu'] = array(
933 'section' => 'watchlist/advancedwatchlist',
934 'label-message' => 'tog-watchlisthideliu',
937 if ( $wgUseRCPatrol ) {
938 $defaultPreferences['watchlisthidepatrolled'] = array(
940 'section' => 'watchlist/advancedwatchlist',
941 'label-message' => 'tog-watchlisthidepatrolled',
945 if ( $wgEnableAPI ) {
946 # Some random gibberish as a proposed default
947 // @todo Fixme: this should use CryptRand but we may not want to read urandom on every view
948 $hash = sha1( mt_rand() . microtime( true ) );
950 $defaultPreferences['watchlisttoken'] = array(
952 'section' => 'watchlist/advancedwatchlist',
953 'label-message' => 'prefs-watchlist-token',
954 'help' => $context->msg( 'prefs-help-watchlist-token', $hash )->escaped()
959 'edit' => 'watchdefault',
960 'move' => 'watchmoves',
961 'delete' => 'watchdeletion'
965 if ( $user->isAllowed( 'createpage' ) ||
$user->isAllowed( 'createtalk' ) ) {
966 $watchTypes['read'] = 'watchcreations';
969 foreach ( $watchTypes as $action => $pref ) {
970 if ( $user->isAllowed( $action ) ) {
971 $defaultPreferences[$pref] = array(
973 'section' => 'watchlist/advancedwatchlist',
974 'label-message' => "tog-$pref",
982 * @param $context IContextSource
983 * @param $defaultPreferences Array
985 static function searchPreferences( $user, IContextSource
$context, &$defaultPreferences ) {
986 global $wgContLang, $wgVectorUseSimpleSearch;
988 ## Search #####################################
989 $defaultPreferences['searchlimit'] = array(
991 'label-message' => 'resultsperpage',
992 'section' => 'searchoptions/displaysearchoptions',
996 if ( $wgVectorUseSimpleSearch ) {
997 $defaultPreferences['vector-simplesearch'] = array(
999 'label-message' => 'vector-simplesearch-preference',
1000 'section' => 'searchoptions/displaysearchoptions',
1004 $defaultPreferences['disablesuggest'] = array(
1006 'label-message' => 'mwsuggest-disable',
1007 'section' => 'searchoptions/displaysearchoptions',
1010 $defaultPreferences['searcheverything'] = array(
1012 'label-message' => 'searcheverything-enable',
1013 'section' => 'searchoptions/advancedsearchoptions',
1016 $nsOptions = $wgContLang->getFormattedNamespaces();
1017 $nsOptions[0] = $context->msg( 'blanknamespace' )->text();
1018 foreach ( $nsOptions as $ns => $name ) {
1020 unset( $nsOptions[$ns] );
1024 $defaultPreferences['searchnamespaces'] = array(
1025 'type' => 'multiselect',
1026 'label-message' => 'defaultns',
1027 'options' => array_flip( $nsOptions ),
1028 'section' => 'searchoptions/advancedsearchoptions',
1029 'prefix' => 'searchNs',
1035 * @param $context IContextSource
1036 * @param $defaultPreferences Array
1038 static function miscPreferences( $user, IContextSource
$context, &$defaultPreferences ) {
1041 ## Misc #####################################
1042 $defaultPreferences['diffonly'] = array(
1044 'section' => 'misc/diffs',
1045 'label-message' => 'tog-diffonly',
1047 $defaultPreferences['norollbackdiff'] = array(
1049 'section' => 'misc/diffs',
1050 'label-message' => 'tog-norollbackdiff',
1053 // Stuff from Language::getExtraUserToggles()
1054 $toggles = $wgContLang->getExtraUserToggles();
1056 foreach ( $toggles as $toggle ) {
1057 $defaultPreferences[$toggle] = array(
1059 'section' => 'personal/i18n',
1060 'label-message' => "tog-$toggle",
1066 * @param $user User The User object
1067 * @param $context IContextSource
1068 * @return Array: text/links to display as key; $skinkey as value
1070 static function generateSkinOptions( $user, IContextSource
$context ) {
1071 global $wgDefaultSkin, $wgAllowUserCss, $wgAllowUserJs;
1074 $mptitle = Title
::newMainPage();
1075 $previewtext = $context->msg( 'skin-preview' )->text();
1077 # Only show members of Skin::getSkinNames() rather than
1078 # $skinNames (skins is all skin names from Language.php)
1079 $validSkinNames = Skin
::getUsableSkins();
1081 # Sort by UI skin name. First though need to update validSkinNames as sometimes
1082 # the skinkey & UI skinname differ (e.g. "standard" skinkey is "Classic" in the UI).
1083 foreach ( $validSkinNames as $skinkey => &$skinname ) {
1084 $msg = $context->msg( "skinname-{$skinkey}" );
1085 if ( $msg->exists() ) {
1086 $skinname = htmlspecialchars( $msg->text() );
1089 asort( $validSkinNames );
1091 foreach ( $validSkinNames as $skinkey => $sn ) {
1092 $linkTools = array();
1094 # Mark the default skin
1095 if ( $skinkey == $wgDefaultSkin ) {
1096 $linkTools[] = $context->msg( 'default' )->escaped();
1099 # Create preview link
1100 $mplink = htmlspecialchars( $mptitle->getLocalURL( array( 'useskin' => $skinkey ) ) );
1101 $linkTools[] = "<a target='_blank' href=\"$mplink\">$previewtext</a>";
1103 # Create links to user CSS/JS pages
1104 if ( $wgAllowUserCss ) {
1105 $cssPage = Title
::makeTitleSafe( NS_USER
, $user->getName() . '/' . $skinkey . '.css' );
1106 $linkTools[] = Linker
::link( $cssPage, $context->msg( 'prefs-custom-css' )->escaped() );
1109 if ( $wgAllowUserJs ) {
1110 $jsPage = Title
::makeTitleSafe( NS_USER
, $user->getName() . '/' . $skinkey . '.js' );
1111 $linkTools[] = Linker
::link( $jsPage, $context->msg( 'prefs-custom-js' )->escaped() );
1114 $display = $sn . ' ' . $context->msg( 'parentheses', $context->getLanguage()->pipeList( $linkTools ) )->text();
1115 $ret[$display] = $skinkey;
1122 * @param $context IContextSource
1125 static function getDateOptions( IContextSource
$context ) {
1126 $lang = $context->getLanguage();
1127 $dateopts = $lang->getDatePreferences();
1132 if ( !in_array( 'default', $dateopts ) ) {
1133 $dateopts[] = 'default'; // Make sure default is always valid
1137 // KLUGE: site default might not be valid for user language
1138 global $wgDefaultUserOptions;
1139 if ( !in_array( $wgDefaultUserOptions['date'], $dateopts ) ) {
1140 $wgDefaultUserOptions['date'] = 'default';
1143 $epoch = wfTimestampNow();
1144 foreach ( $dateopts as $key ) {
1145 if ( $key == 'default' ) {
1146 $formatted = $context->msg( 'datedefault' )->escaped();
1148 $formatted = htmlspecialchars( $lang->timeanddate( $epoch, false, $key ) );
1150 $ret[$formatted] = $key;
1157 * @param $context IContextSource
1160 static function getImageSizes( IContextSource
$context ) {
1161 global $wgImageLimits;
1164 $pixels = $context->msg( 'unit-pixel' )->text();
1166 foreach ( $wgImageLimits as $index => $limits ) {
1167 $display = "{$limits[0]}×{$limits[1]}" . $pixels;
1168 $ret[$display] = $index;
1175 * @param $context IContextSource
1178 static function getThumbSizes( IContextSource
$context ) {
1179 global $wgThumbLimits;
1182 $pixels = $context->msg( 'unit-pixel' )->text();
1184 foreach ( $wgThumbLimits as $index => $size ) {
1185 $display = $size . $pixels;
1186 $ret[$display] = $index;
1193 * @param $signature string
1194 * @param $alldata array
1195 * @param $form HTMLForm
1196 * @return bool|string
1198 static function validateSignature( $signature, $alldata, $form ) {
1199 global $wgParser, $wgMaxSigChars;
1200 if ( mb_strlen( $signature ) > $wgMaxSigChars ) {
1201 return Xml
::element( 'span', array( 'class' => 'error' ),
1202 $form->msg( 'badsiglength' )->numParams( $wgMaxSigChars )->text() );
1203 } elseif ( isset( $alldata['fancysig'] ) &&
1204 $alldata['fancysig'] &&
1205 false === $wgParser->validateSig( $signature ) ) {
1206 return Xml
::element( 'span', array( 'class' => 'error' ), $form->msg( 'badsig' )->text() );
1213 * @param $signature string
1214 * @param $alldata array
1215 * @param $form HTMLForm
1218 static function cleanSignature( $signature, $alldata, $form ) {
1219 if ( isset( $alldata['fancysig'] ) && $alldata['fancysig'] ) {
1221 $signature = $wgParser->cleanSig( $signature );
1223 // When no fancy sig used, make sure ~{3,5} get removed.
1224 $signature = Parser
::cleanSigInSig( $signature );
1232 * @param $context IContextSource
1233 * @param $formClass string
1234 * @param array $remove array of items to remove
1237 static function getFormObject( $user, IContextSource
$context, $formClass = 'PreferencesForm', array $remove = array() ) {
1238 $formDescriptor = Preferences
::getPreferences( $user, $context );
1239 if ( count( $remove ) ) {
1240 $removeKeys = array_flip( $remove );
1241 $formDescriptor = array_diff_key( $formDescriptor, $removeKeys );
1244 // Remove type=api preferences. They are not intended for rendering in the form.
1245 foreach ( $formDescriptor as $name => $info ) {
1246 if ( isset( $info['type'] ) && $info['type'] === 'api' ) {
1247 unset( $formDescriptor[$name] );
1252 * @var $htmlForm PreferencesForm
1254 $htmlForm = new $formClass( $formDescriptor, $context, 'prefs' );
1256 $htmlForm->setModifiedUser( $user );
1257 $htmlForm->setId( 'mw-prefs-form' );
1258 $htmlForm->setSubmitText( $context->msg( 'saveprefs' )->text() );
1259 # Used message keys: 'accesskey-preferences-save', 'tooltip-preferences-save'
1260 $htmlForm->setSubmitTooltip( 'preferences-save' );
1261 $htmlForm->setSubmitID( 'prefsubmit' );
1262 $htmlForm->setSubmitCallback( array( 'Preferences', 'tryFormSubmit' ) );
1268 * @param $context IContextSource
1271 static function getTimezoneOptions( IContextSource
$context ) {
1274 global $wgLocalTZoffset, $wgLocaltimezone;
1275 // Check that $wgLocalTZoffset is the same as $wgLocaltimezone
1276 if ( $wgLocalTZoffset == date( 'Z' ) / 60 ) {
1277 $server_tz_msg = $context->msg( 'timezoneuseserverdefault', $wgLocaltimezone )->text();
1279 $tzstring = sprintf( '%+03d:%02d', floor( $wgLocalTZoffset / 60 ), abs( $wgLocalTZoffset ) %
60 );
1280 $server_tz_msg = $context->msg( 'timezoneuseserverdefault', $tzstring )->text();
1282 $opt[$server_tz_msg] = "System|$wgLocalTZoffset";
1283 $opt[$context->msg( 'timezoneuseoffset' )->text()] = 'other';
1284 $opt[$context->msg( 'guesstimezone' )->text()] = 'guess';
1286 if ( function_exists( 'timezone_identifiers_list' ) ) {
1287 # Read timezone list
1288 $tzs = timezone_identifiers_list();
1291 $tzRegions = array();
1292 $tzRegions['Africa'] = $context->msg( 'timezoneregion-africa' )->text();
1293 $tzRegions['America'] = $context->msg( 'timezoneregion-america' )->text();
1294 $tzRegions['Antarctica'] = $context->msg( 'timezoneregion-antarctica' )->text();
1295 $tzRegions['Arctic'] = $context->msg( 'timezoneregion-arctic' )->text();
1296 $tzRegions['Asia'] = $context->msg( 'timezoneregion-asia' )->text();
1297 $tzRegions['Atlantic'] = $context->msg( 'timezoneregion-atlantic' )->text();
1298 $tzRegions['Australia'] = $context->msg( 'timezoneregion-australia' )->text();
1299 $tzRegions['Europe'] = $context->msg( 'timezoneregion-europe' )->text();
1300 $tzRegions['Indian'] = $context->msg( 'timezoneregion-indian' )->text();
1301 $tzRegions['Pacific'] = $context->msg( 'timezoneregion-pacific' )->text();
1302 asort( $tzRegions );
1304 $prefill = array_fill_keys( array_values( $tzRegions ), array() );
1305 $opt = array_merge( $opt, $prefill );
1307 $now = date_create( 'now' );
1309 foreach ( $tzs as $tz ) {
1310 $z = explode( '/', $tz, 2 );
1312 # timezone_identifiers_list() returns a number of
1313 # backwards-compatibility entries. This filters them out of the
1314 # list presented to the user.
1315 if ( count( $z ) != 2 ||
!array_key_exists( $z[0], $tzRegions ) ) {
1320 $z[0] = $tzRegions[$z[0]];
1322 $minDiff = floor( timezone_offset_get( timezone_open( $tz ), $now ) / 60 );
1324 $display = str_replace( '_', ' ', $z[0] . '/' . $z[1] );
1325 $value = "ZoneInfo|$minDiff|$tz";
1327 $opt[$z[0]][$display] = $value;
1338 static function filterIntval( $value, $alldata ) {
1339 return intval( $value );
1347 static function filterTimezoneInput( $tz, $alldata ) {
1348 $data = explode( '|', $tz, 3 );
1349 switch ( $data[0] ) {
1354 $data = explode( ':', $tz, 2 );
1355 if ( count( $data ) == 2 ) {
1356 $data[0] = intval( $data[0] );
1357 $data[1] = intval( $data[1] );
1358 $minDiff = abs( $data[0] ) * 60 +
$data[1];
1359 if ( $data[0] < 0 ) {
1360 $minDiff = - $minDiff;
1363 $minDiff = intval( $data[0] ) * 60;
1366 # Max is +14:00 and min is -12:00, see:
1367 # http://en.wikipedia.org/wiki/Timezone
1368 $minDiff = min( $minDiff, 840 ); # 14:00
1369 $minDiff = max( $minDiff, - 720 ); # -12:00
1370 return 'Offset|' . $minDiff;
1375 * Handle the form submission if everything validated properly
1378 * @param $form PreferencesForm
1379 * @param $entryPoint string
1380 * @return bool|Status|string
1382 static function tryFormSubmit( $formData, $form, $entryPoint = 'internal' ) {
1383 global $wgHiddenPrefs, $wgAuth;
1385 $user = $form->getModifiedUser();
1389 foreach ( array_keys( $formData ) as $name ) {
1390 if ( isset( self
::$saveFilters[$name] ) ) {
1392 call_user_func( self
::$saveFilters[$name], $formData[$name], $formData );
1396 // Stuff that shouldn't be saved as a preference.
1397 $saveBlacklist = array(
1402 // Fortunately, the realname field is MUCH simpler
1403 if ( !in_array( 'realname', $wgHiddenPrefs ) ) {
1404 $realName = $formData['realname'];
1405 $user->setRealName( $realName );
1408 foreach ( $saveBlacklist as $b ) {
1409 unset( $formData[$b] );
1412 # If users have saved a value for a preference which has subsequently been disabled
1413 # via $wgHiddenPrefs, we don't want to destroy that setting in case the preference
1414 # is subsequently re-enabled
1415 # TODO: maintenance script to actually delete these
1416 foreach ( $wgHiddenPrefs as $pref ) {
1417 # If the user has not set a non-default value here, the default will be returned
1418 # and subsequently discarded
1419 $formData[$pref] = $user->getOption( $pref, null, true );
1422 // Keep old preferences from interfering due to back-compat code, etc.
1423 $user->resetOptions( 'unused', $form->getContext() );
1425 foreach ( $formData as $key => $value ) {
1426 $user->setOption( $key, $value );
1429 $user->saveSettings();
1431 $wgAuth->updateExternalDB( $user );
1438 * @param $form PreferencesForm
1441 public static function tryUISubmit( $formData, $form ) {
1442 $res = self
::tryFormSubmit( $formData, $form, 'ui' );
1445 $urlOptions = array( 'success' => 1 );
1447 if ( $res === 'eauth' ) {
1448 $urlOptions['eauth'] = 1;
1451 $urlOptions +
= $form->getExtraSuccessRedirectParameters();
1453 $url = $form->getTitle()->getFullURL( $urlOptions );
1455 $form->getContext()->getOutput()->redirect( $url );
1458 return Status
::newGood();
1462 * Try to set a user's email address.
1463 * This does *not* try to validate the address.
1464 * Caller is responsible for checking $wgAuth.
1466 * @deprecated in 1.20; use User::setEmailWithConfirmation() instead.
1468 * @param string $newaddr New email address
1469 * @return Array (true on success or Status on failure, info string)
1471 public static function trySetUserEmail( User
$user, $newaddr ) {
1472 wfDeprecated( __METHOD__
, '1.20' );
1474 $result = $user->setEmailWithConfirmation( $newaddr );
1475 if ( $result->isGood() ) {
1476 return array( true, $result->value
);
1478 return array( $result, 'mailerror' );
1483 * @deprecated in 1.19
1487 public static function loadOldSearchNs( $user ) {
1488 wfDeprecated( __METHOD__
, '1.19' );
1490 $searchableNamespaces = SearchEngine
::searchableNamespaces();
1491 // Back compat with old format
1494 foreach ( $searchableNamespaces as $ns => $name ) {
1495 if ( $user->getOption( 'searchNs' . $ns ) ) {
1504 /** Some tweaks to allow js prefs to work */
1505 class PreferencesForm
extends HTMLForm
{
1506 // Override default value from HTMLForm
1507 protected $mSubSectionBeforeFields = false;
1509 private $modifiedUser;
1514 public function setModifiedUser( $user ) {
1515 $this->modifiedUser
= $user;
1521 public function getModifiedUser() {
1522 if ( $this->modifiedUser
=== null ) {
1523 return $this->getUser();
1525 return $this->modifiedUser
;
1530 * Get extra parameters for the query string when redirecting after
1535 public function getExtraSuccessRedirectParameters() {
1540 * @param $html string
1543 function wrapForm( $html ) {
1544 $html = Xml
::tags( 'div', array( 'id' => 'preferences' ), $html );
1546 return parent
::wrapForm( $html );
1552 function getButtons() {
1553 $html = parent
::getButtons();
1555 $t = SpecialPage
::getTitleFor( 'Preferences', 'reset' );
1557 $html .= "\n" . Linker
::link( $t, $this->msg( 'restoreprefs' )->escaped() );
1559 $html = Xml
::tags( 'div', array( 'class' => 'mw-prefs-buttons' ), $html );
1565 * Separate multi-option preferences into multiple preferences, since we
1566 * have to store them separately
1567 * @param $data array
1570 function filterDataForSubmit( $data ) {
1571 foreach ( $this->mFlatFields
as $fieldname => $field ) {
1572 if ( $field instanceof HTMLNestedFilterable
) {
1573 $info = $field->mParams
;
1574 $prefix = isset( $info['prefix'] ) ?
$info['prefix'] : $fieldname;
1575 foreach ( $field->filterDataForSubmit( $data[$fieldname] ) as $key => $value ) {
1576 $data["$prefix$key"] = $value;
1578 unset( $data[$fieldname] );
1586 * Get the whole body of the form.
1589 function getBody() {
1590 return $this->displaySection( $this->mFieldTree
, '', 'mw-prefsection-' );
1594 * Get the "<legend>" for a given section key. Normally this is the
1595 * prefs-$key message but we'll allow extensions to override it.
1596 * @param $key string
1599 function getLegend( $key ) {
1600 $legend = parent
::getLegend( $key );
1601 wfRunHooks( 'PreferencesGetLegend', array( $this, $key, &$legend ) );