Go to the documentation of this file.
57 'timecorrection' => [
'Preferences',
'filterTimezoneInput' ],
58 'rclimit' => [
'Preferences',
'filterIntval' ],
59 'wllimit' => [
'Preferences',
'filterIntval' ],
60 'searchlimit' => [
'Preferences',
'filterIntval' ],
83 if ( self::$defaultPreferences ) {
116 # # Remove preferences that wikis don't want to use
123 # # Make sure that form fields have their parent set. See T43337.
126 $disable = !
$user->isAllowed(
'editmyoptions' );
129 # # Prod in defaults from the user
132 if ( $disable && !in_array(
$name, self::$saveBlacklist ) ) {
133 $info[
'disabled'] =
'disabled';
136 $globalDefault = isset( $defaultOptions[
$name] )
137 ? $defaultOptions[
$name]
141 if ( isset( $info[
'default'] ) ) {
144 } elseif ( !is_null( $prefFromUser ) &&
145 $field->validate( $prefFromUser,
$user->getOptions() ) ===
true ) {
146 $info[
'default'] = $prefFromUser;
147 } elseif ( $field->validate( $globalDefault,
$user->getOptions() ) ===
true ) {
148 $info[
'default'] = $globalDefault;
150 throw new MWException(
"Global default '$globalDefault' is invalid for field $name" );
169 if ( ( isset( $info[
'type'] ) && $info[
'type'] ==
'multiselect' ) ||
170 ( isset( $info[
'class'] ) && $info[
'class'] ==
'HTMLMultiSelectField' ) ) {
172 $prefix = isset( $info[
'prefix'] ) ? $info[
'prefix'] :
$name;
176 if (
$user->getOption(
"$prefix$value" ) ) {
183 if ( ( isset( $info[
'type'] ) && $info[
'type'] ==
'checkmatrix' ) ||
184 ( isset( $info[
'class'] ) && $info[
'class'] ==
'HTMLCheckMatrix' ) ) {
187 $prefix = isset( $info[
'prefix'] ) ? $info[
'prefix'] :
$name;
190 foreach ( $columns
as $column ) {
191 foreach ( $rows
as $row ) {
192 if (
$user->getOption(
"$prefix$column-$row" ) ) {
193 $val[] =
"$column-$row";
211 $authManager = AuthManager::singleton();
214 $userName =
$user->getName();
216 # # User info #####################################
220 'label-message' => [
'username', $userName ],
221 'default' => $userName,
222 'section' =>
'personal/info',
227 # Get groups to which the user belongs
228 $userEffectiveGroups =
$user->getEffectiveGroups();
229 $userGroupMemberships =
$user->getGroupMemberships();
230 $userGroups = $userMembers = $userTempGroups = $userTempMembers = [];
231 foreach ( $userEffectiveGroups
as $ueg ) {
237 if ( isset( $userGroupMemberships[$ueg] ) ) {
238 $groupStringOrObject = $userGroupMemberships[$ueg];
240 $groupStringOrObject = $ueg;
254 $userTempGroups[] = $userG;
255 $userTempMembers[] = $userM;
257 $userGroups[] = $userG;
258 $userMembers[] = $userM;
262 sort( $userMembers );
263 sort( $userTempGroups );
264 sort( $userTempMembers );
265 $userGroups = array_merge( $userTempGroups, $userGroups );
266 $userMembers = array_merge( $userTempMembers, $userMembers );
270 'label' =>
$context->
msg(
'prefs-memberingroups' )->numParams(
271 count( $userGroups ) )->params( $userName )->parse(),
272 'default' =>
$context->
msg(
'prefs-memberingroups-type' )
273 ->rawParams(
$lang->commaList( $userGroups ),
$lang->commaList( $userMembers ) )
276 'section' =>
'personal/info',
279 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
287 'label-message' =>
'prefs-edits',
288 'default' => $editCount,
289 'section' =>
'personal/info',
292 if (
$user->getRegistration() ) {
294 $userRegistration =
$user->getRegistration();
297 'label-message' =>
'prefs-registration',
299 'prefs-registration-date-time',
300 $lang->userTimeAndDate( $userRegistration, $displayUser ),
301 $lang->userDate( $userRegistration, $displayUser ),
302 $lang->userTime( $userRegistration, $displayUser )
304 'section' =>
'personal/info',
308 $canViewPrivateInfo =
$user->isAllowed(
'viewmyprivateinfo' );
309 $canEditPrivateInfo =
$user->isAllowed(
'editmyprivateinfo' );
314 'type' => $canEditPrivateInfo && $authManager->allowsPropertyChange(
'realname' )
316 'default' =>
$user->getRealName(),
317 'section' =>
'personal/info',
318 'label-message' =>
'yourrealname',
319 'help-message' =>
'prefs-help-realname',
322 if ( $canEditPrivateInfo && $authManager->allowsAuthenticationDataChange(
333 'label-message' =>
'yourpassword',
334 'section' =>
'personal/info',
341 'label-message' =>
'tog-prefershttps',
342 'help-message' =>
'prefs-help-prefershttps',
343 'section' =>
'personal/info'
349 $languageCode = $config->get(
'LanguageCode' );
350 if ( !array_key_exists( $languageCode,
$languages ) ) {
362 'section' =>
'personal/i18n',
364 'label-message' =>
'yourlanguage',
369 'section' =>
'personal/i18n',
372 ->params(
$context->
msg(
'gender-unknown' )->plain() )
373 ->escaped() =>
'unknown',
374 $context->
msg(
'gender-female' )->escaped() =>
'female',
375 $context->
msg(
'gender-male' )->escaped() =>
'male',
377 'label-message' =>
'yourgender',
378 'help-message' =>
'prefs-help-gender',
382 if ( !$config->get(
'DisableLangConversion' ) ) {
383 foreach ( LanguageConverter::$languagesWithVariants
as $langCode ) {
387 if (
count( $variants ) <= 1 ) {
392 foreach ( $variants
as $v ) {
393 $v = str_replace(
'_',
'-', strtolower( $v ) );
394 $variantArray[$v] =
$lang->getVariantname( $v,
false );
404 'label-message' =>
'yourvariant',
407 'section' =>
'personal/i18n',
408 'help-message' =>
'prefs-help-variant',
422 foreach ( $toggles
as $toggle ) {
425 'section' =>
'personal/i18n',
426 'label-message' =>
"tog-$toggle",
431 $oldsigWikiText =
$wgParser->preSaveTransform(
441 'label-message' =>
'tog-oldsig',
442 'default' => $oldsigHTML,
443 'section' =>
'personal/signature',
446 'type' => $authManager->allowsPropertyChange(
'nickname' ) ?
'text' :
'info',
447 'maxlength' => $config->get(
'MaxSigChars' ),
448 'label-message' =>
'yournick',
449 'validation-callback' => [
'Preferences',
'validateSignature' ],
450 'section' =>
'personal/signature',
451 'filter-callback' => [
'Preferences',
'cleanSignature' ],
455 'label-message' =>
'tog-fancysig',
457 'help-message' =>
'prefs-help-signature',
458 'section' =>
'personal/signature'
463 if ( $config->get(
'EnableEmail' ) ) {
464 if ( $canViewPrivateInfo ) {
465 $helpMessages[] = $config->get(
'EmailConfirmToEdit' )
466 ?
'prefs-help-email-required'
467 :
'prefs-help-email';
469 if ( $config->get(
'EnableUserEmail' ) ) {
471 $helpMessages[] =
'prefs-help-email-others';
474 $emailAddress =
$user->getEmail() ? htmlspecialchars(
$user->getEmail() ) :
'';
475 if ( $canEditPrivateInfo && $authManager->allowsPropertyChange(
'emailaddress' ) ) {
482 $emailAddress .= $emailAddress ==
'' ?
$link : (
491 'default' => $emailAddress,
492 'label-message' =>
'youremail',
493 'section' =>
'personal/email',
494 'help-messages' => $helpMessages,
495 # 'cssclass' chosen below
499 $disableEmailPrefs =
false;
501 if ( $config->get(
'EmailAuthentication' ) ) {
502 $emailauthenticationclass =
'mw-email-not-authenticated';
503 if (
$user->getEmail() ) {
504 if (
$user->getEmailAuthenticationTimestamp() ) {
509 $emailTimestamp =
$user->getEmailAuthenticationTimestamp();
510 $time =
$lang->userTimeAndDate( $emailTimestamp, $displayUser );
511 $d =
$lang->userDate( $emailTimestamp, $displayUser );
512 $t =
$lang->userTime( $emailTimestamp, $displayUser );
513 $emailauthenticated =
$context->
msg(
'emailauthenticated',
514 $time, $d,
$t )->parse() .
'<br />';
515 $disableEmailPrefs =
false;
516 $emailauthenticationclass =
'mw-email-authenticated';
518 $disableEmailPrefs =
true;
519 $emailauthenticated =
$context->
msg(
'emailnotauthenticated' )->parse() .
'<br />' .
524 $emailauthenticationclass =
"mw-email-not-authenticated";
527 $disableEmailPrefs =
true;
528 $emailauthenticated =
$context->
msg(
'noemailprefs' )->escaped();
529 $emailauthenticationclass =
'mw-email-none';
532 if ( $canViewPrivateInfo ) {
536 'section' =>
'personal/email',
537 'label-message' =>
'prefs-emailconfirm-label',
538 'default' => $emailauthenticated,
539 # Apply the same CSS class used on the input to the message:
540 'cssclass' => $emailauthenticationclass,
545 if ( $config->get(
'EnableUserEmail' ) &&
$user->isAllowed(
'sendemail' ) ) {
549 'section' =>
'personal/email',
550 'label-message' =>
'allowemail',
551 'disabled' => $disableEmailPrefs,
555 'section' =>
'personal/email',
556 'label-message' =>
'tog-ccmeonemails',
557 'disabled' => $disableEmailPrefs,
561 if ( $config->get(
'EnotifWatchlist' ) ) {
564 'section' =>
'personal/email',
565 'label-message' =>
'tog-enotifwatchlistpages',
566 'disabled' => $disableEmailPrefs,
569 if ( $config->get(
'EnotifUserTalk' ) ) {
572 'section' =>
'personal/email',
573 'label-message' =>
'tog-enotifusertalkpages',
574 'disabled' => $disableEmailPrefs,
577 if ( $config->get(
'EnotifUserTalk' ) || $config->get(
'EnotifWatchlist' ) ) {
578 if ( $config->get(
'EnotifMinorEdits' ) ) {
581 'section' =>
'personal/email',
582 'label-message' =>
'tog-enotifminoredits',
583 'disabled' => $disableEmailPrefs,
587 if ( $config->get(
'EnotifRevealEditorAddress' ) ) {
590 'section' =>
'personal/email',
591 'label-message' =>
'tog-enotifrevealaddr',
592 'disabled' => $disableEmailPrefs,
606 # # Skin #####################################
610 if ( $skinOptions ) {
613 'options' => $skinOptions,
615 'section' =>
'rendering/skin',
620 $allowUserCss = $config->get(
'AllowUserCss' );
621 $allowUserJs = $config->get(
'AllowUserJs' );
622 # Create links to user CSS/JS pages for all skins
623 # This code is basically copied from generateSkinOptions(). It'd
624 # be nice to somehow merge this back in there to avoid redundancy.
625 if ( $allowUserCss || $allowUserJs ) {
627 $userName =
$user->getName();
629 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
630 if ( $allowUserCss ) {
635 if ( $allowUserJs ) {
644 'label-message' =>
'prefs-common-css-js',
645 'section' =>
'rendering/skin',
656 # # Files #####################################
660 'label-message' =>
'imagemaxsize',
661 'section' =>
'rendering/files',
666 'label-message' =>
'thumbsize',
667 'section' =>
'rendering/files',
678 # # Date and time #####################################
680 if ( $dateOptions ) {
683 'options' => $dateOptions,
685 'section' =>
'rendering/dateformat',
692 $nowlocal =
Xml::element(
'span', [
'id' =>
'wpLocalTime' ],
695 [
'format' =>
false,
'timecorrection' =>
false ] ) .
696 Html::hidden(
'wpServerTime', (
int)substr( $now, 8, 2 ) * 60 + (
int)substr( $now, 10, 2 ) );
701 'label-message' =>
'servertime',
702 'default' => $nowserver,
703 'section' =>
'rendering/timeoffset',
709 'label-message' =>
'localtime',
710 'default' => $nowlocal,
711 'section' =>
'rendering/timeoffset',
715 $tzOffset =
$user->getOption(
'timecorrection' );
716 $tz = explode(
'|', $tzOffset, 3 );
720 $tzSetting = $tzOffset;
721 if (
count( $tz ) > 1 && $tz[0] ==
'ZoneInfo' &&
726 $userTZ =
new DateTimeZone( $tz[2] );
727 $minDiff = floor( $userTZ->getOffset(
new DateTime(
'now' ) ) / 60 );
728 $tzSetting =
"ZoneInfo|$minDiff|{$tz[2]}";
729 }
catch ( Exception
$e ) {
734 if (
count( $tz ) > 1 && $tz[0] ==
'Offset' ) {
736 $tzSetting = sprintf(
'%+03d:%02d', floor( $minDiff / 60 ), abs( $minDiff ) % 60 );
740 'class' =>
'HTMLSelectOrOtherField',
741 'label-message' =>
'timezonelegend',
742 'options' => $tzOptions,
743 'default' => $tzSetting,
745 'section' =>
'rendering/timeoffset',
755 # # Diffs ####################################
758 'section' =>
'rendering/diffs',
759 'label-message' =>
'tog-diffonly',
763 'section' =>
'rendering/diffs',
764 'label-message' =>
'tog-norollbackdiff',
767 # # Page Rendering ##############################
776 'label-message' =>
'tog-underline',
777 'section' =>
'rendering/advancedrendering',
781 $stubThresholdValues = [ 50, 100, 500, 1000, 2000, 5000, 10000 ];
782 $stubThresholdOptions = [
$context->
msg(
'stub-threshold-disabled' )->text() => 0 ];
783 foreach ( $stubThresholdValues
as $value ) {
789 'section' =>
'rendering/advancedrendering',
790 'options' => $stubThresholdOptions,
792 'label-raw' =>
$context->
msg(
'stub-threshold' )->rawParams(
793 '<a href="#" class="stub">' .
794 $context->
msg(
'stub-threshold-sample-link' )->parse() .
800 'section' =>
'rendering/advancedrendering',
801 'label-message' =>
'tog-showhiddencats'
806 'section' =>
'rendering/advancedrendering',
807 'label-message' =>
'tog-numberheadings',
817 # # Editing #####################################
820 'section' =>
'editing/advancedediting',
821 'label-message' =>
'tog-editsectiononrightclick',
825 'section' =>
'editing/advancedediting',
826 'label-message' =>
'tog-editondblclick',
832 'section' =>
'editing/editor',
833 'label-message' =>
'editfont-style',
835 $context->
msg(
'editfont-default' )->text() =>
'default',
836 $context->
msg(
'editfont-monospace' )->text() =>
'monospace',
837 $context->
msg(
'editfont-sansserif' )->text() =>
'sans-serif',
838 $context->
msg(
'editfont-serif' )->text() =>
'serif',
843 if (
$user->isAllowed(
'minoredit' ) ) {
846 'section' =>
'editing/editor',
847 'label-message' =>
'tog-minordefault',
853 'section' =>
'editing/editor',
854 'label-message' =>
'tog-forceeditsummary',
858 'section' =>
'editing/editor',
859 'label-message' =>
'tog-useeditwarning',
863 'section' =>
'editing/editor',
864 'label-message' =>
'tog-showtoolbar',
869 'section' =>
'editing/preview',
870 'label-message' =>
'tog-previewonfirst',
874 'section' =>
'editing/preview',
875 'label-message' =>
'tog-previewontop',
879 'section' =>
'editing/preview',
880 'label-message' =>
'tog-uselivepreview',
891 $rcMaxAge = $config->get(
'RCMaxAge' );
892 # # RecentChanges #####################################
895 'label-message' =>
'recentchangesdays',
896 'section' =>
'rc/displayrc',
898 'max' => ceil( $rcMaxAge / ( 3600 * 24 ) ),
899 'help' =>
$context->
msg(
'recentchangesdays-max' )->numParams(
900 ceil( $rcMaxAge / ( 3600 * 24 ) ) )->escaped()
904 'label-message' =>
'recentchangescount',
905 'help-message' =>
'prefs-help-recentchangescount',
906 'section' =>
'rc/displayrc',
910 'label-message' =>
'tog-usenewrc',
911 'section' =>
'rc/advancedrc',
915 'label-message' =>
'tog-hideminor',
916 'section' =>
'rc/advancedrc',
919 if ( $config->get(
'RCWatchCategoryMembership' ) ) {
922 'label-message' =>
'tog-hidecategorization',
923 'section' =>
'rc/advancedrc',
927 if (
$user->useRCPatrol() ) {
930 'section' =>
'rc/advancedrc',
931 'label-message' =>
'tog-hidepatrolled',
935 if (
$user->useNPPatrol() ) {
938 'section' =>
'rc/advancedrc',
939 'label-message' =>
'tog-newpageshidepatrolled',
943 if ( $config->get(
'RCShowWatchingUsers' ) ) {
946 'section' =>
'rc/advancedrc',
947 'label-message' =>
'tog-shownumberswatching',
959 $watchlistdaysMax = ceil( $config->get(
'RCMaxAge' ) / ( 3600 * 24 ) );
961 # # Watchlist #####################################
962 if (
$user->isAllowed(
'editmywatchlist' ) ) {
963 $editWatchlistLinks = [];
964 $editWatchlistModes = [
965 'edit' => [
'EditWatchlist',
false ],
966 'raw' => [
'EditWatchlist',
'raw' ],
967 'clear' => [
'EditWatchlist',
'clear' ],
969 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
970 foreach ( $editWatchlistModes
as $editWatchlistMode => $mode ) {
982 'label-message' =>
'prefs-editwatchlist-label',
983 'section' =>
'watchlist/editwatchlist',
990 'max' => $watchlistdaysMax,
991 'section' =>
'watchlist/displaywatchlist',
992 'help' =>
$context->
msg(
'prefs-watchlist-days-max' )->numParams(
993 $watchlistdaysMax )->escaped(),
994 'label-message' =>
'prefs-watchlist-days',
1000 'label-message' =>
'prefs-watchlist-edits',
1001 'help' =>
$context->
msg(
'prefs-watchlist-edits-max' )->escaped(),
1002 'section' =>
'watchlist/displaywatchlist',
1006 'section' =>
'watchlist/advancedwatchlist',
1007 'label-message' =>
'tog-extendwatchlist',
1011 'section' =>
'watchlist/advancedwatchlist',
1012 'label-message' =>
'tog-watchlisthideminor',
1016 'section' =>
'watchlist/advancedwatchlist',
1017 'label-message' =>
'tog-watchlisthidebots',
1021 'section' =>
'watchlist/advancedwatchlist',
1022 'label-message' =>
'tog-watchlisthideown',
1026 'section' =>
'watchlist/advancedwatchlist',
1027 'label-message' =>
'tog-watchlisthideanons',
1031 'section' =>
'watchlist/advancedwatchlist',
1032 'label-message' =>
'tog-watchlisthideliu',
1036 'section' =>
'watchlist/advancedwatchlist',
1037 'label-message' =>
'tog-watchlistreloadautomatically',
1040 if ( $config->get(
'RCWatchCategoryMembership' ) ) {
1043 'section' =>
'watchlist/advancedwatchlist',
1044 'label-message' =>
'tog-watchlisthidecategorization',
1048 if (
$user->useRCPatrol() ) {
1051 'section' =>
'watchlist/advancedwatchlist',
1052 'label-message' =>
'tog-watchlisthidepatrolled',
1057 'edit' =>
'watchdefault',
1058 'move' =>
'watchmoves',
1059 'delete' =>
'watchdeletion'
1063 if (
$user->isAllowed(
'createpage' ) ||
$user->isAllowed(
'createtalk' ) ) {
1064 $watchTypes[
'read'] =
'watchcreations';
1067 if (
$user->isAllowed(
'rollback' ) ) {
1068 $watchTypes[
'rollback'] =
'watchrollback';
1071 if (
$user->isAllowed(
'upload' ) ) {
1072 $watchTypes[
'upload'] =
'watchuploads';
1075 foreach ( $watchTypes
as $action => $pref ) {
1076 if (
$user->isAllowed( $action ) ) {
1082 'section' =>
'watchlist/advancedwatchlist',
1083 'label-message' =>
"tog-$pref",
1088 if ( $config->get(
'EnableAPI' ) ) {
1094 'section' =>
'watchlist/tokenwatchlist',
1095 'label-message' =>
'prefs-watchlist-token',
1096 'default' =>
$user->getTokenFromOption(
'watchlisttoken' ),
1097 'help-message' =>
'prefs-help-watchlist-token2',
1130 $previewtext =
$context->
msg(
'skin-preview' )->escaped();
1132 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
1134 # Only show skins that aren't disabled in $wgSkipSkins
1137 # Sort by UI skin name. First though need to update validSkinNames as sometimes
1138 # the skinkey & UI skinname differ (e.g. "standard" skinkey is "Classic" in the UI).
1139 foreach ( $validSkinNames
as $skinkey => &$skinname ) {
1141 if ( $msg->exists() ) {
1142 $skinname = htmlspecialchars( $msg->text() );
1145 asort( $validSkinNames );
1148 $defaultSkin = $config->get(
'DefaultSkin' );
1149 $allowUserCss = $config->get(
'AllowUserCss' );
1150 $allowUserJs = $config->get(
'AllowUserJs' );
1152 $foundDefault =
false;
1153 foreach ( $validSkinNames
as $skinkey => $sn ) {
1156 # Mark the default skin
1157 if ( strcasecmp( $skinkey, $defaultSkin ) === 0 ) {
1158 $linkTools[] =
$context->
msg(
'default' )->escaped();
1159 $foundDefault =
true;
1162 # Create preview link
1163 $mplink = htmlspecialchars( $mptitle->getLocalURL( [
'useskin' => $skinkey ] ) );
1164 $linkTools[] =
"<a target='_blank' href=\"$mplink\">$previewtext</a>";
1166 # Create links to user CSS/JS pages
1167 if ( $allowUserCss ) {
1172 if ( $allowUserJs ) {
1177 $display = $sn .
' ' .
$context->
msg(
'parentheses' )
1180 $ret[$display] = $skinkey;
1183 if ( !$foundDefault ) {
1198 $dateopts =
$lang->getDatePreferences();
1203 if ( !in_array(
'default', $dateopts ) ) {
1204 $dateopts[] =
'default';
1214 foreach ( $dateopts
as $key ) {
1215 if ( $key ==
'default' ) {
1216 $formatted =
$context->
msg(
'datedefault' )->escaped();
1218 $formatted = htmlspecialchars(
$lang->timeanddate( $epoch,
false, $key ) );
1220 $ret[$formatted] = $key;
1236 $display =
"{$limits[0]}" . json_decode(
'"\u200e"' ) .
"×{$limits[1]}" . $pixels;
1237 $ret[$display] = $index;
1252 $display = $size . $pixels;
1253 $ret[$display] = $index;
1267 $maxSigChars = $form->getConfig()->get(
'MaxSigChars' );
1268 if ( mb_strlen( $signature ) > $maxSigChars ) {
1270 $form->msg(
'badsiglength' )->numParams( $maxSigChars )->text() );
1271 } elseif ( isset( $alldata[
'fancysig'] ) &&
1272 $alldata[
'fancysig'] &&
1277 [
'class' =>
'error' ],
1278 $form->msg(
'badsig' )->text()
1292 if ( isset( $alldata[
'fancysig'] ) && $alldata[
'fancysig'] ) {
1294 $signature =
$wgParser->cleanSig( $signature );
1297 $signature = Parser::cleanSigInSig( $signature );
1313 $formClass =
'PreferencesForm',
1317 if (
count( $remove ) ) {
1318 $removeKeys = array_flip( $remove );
1319 $formDescriptor = array_diff_key( $formDescriptor, $removeKeys );
1323 foreach ( $formDescriptor
as $name => $info ) {
1324 if ( isset( $info[
'type'] ) && $info[
'type'] ===
'api' ) {
1325 unset( $formDescriptor[
$name] );
1332 $htmlForm =
new $formClass( $formDescriptor,
$context,
'prefs' );
1334 $htmlForm->setModifiedUser(
$user );
1335 $htmlForm->setId(
'mw-prefs-form' );
1336 $htmlForm->setAutocomplete(
'off' );
1337 $htmlForm->setSubmitText(
$context->
msg(
'saveprefs' )->text() );
1338 # Used message keys: 'accesskey-preferences-save', 'tooltip-preferences-save'
1339 $htmlForm->setSubmitTooltip(
'preferences-save' );
1340 $htmlForm->setSubmitID(
'prefsubmit' );
1341 $htmlForm->setSubmitCallback( [
'Preferences',
'tryFormSubmit' ] );
1358 if ( $localTZoffset == $timestamp->format(
'Z' ) / 60 ) {
1359 $timezoneName = $timestamp->getTimezone()->getName();
1361 if ( isset( $timeZoneList[$timezoneName] ) ) {
1362 $timezoneName = $timeZoneList[$timezoneName][
'name'];
1365 'timezoneuseserverdefault',
1369 $tzstring = sprintf(
1371 floor( $localTZoffset / 60 ),
1372 abs( $localTZoffset ) % 60
1374 $server_tz_msg =
$context->
msg(
'timezoneuseserverdefault', $tzstring )->text();
1376 $opt[$server_tz_msg] =
"System|$localTZoffset";
1380 foreach ( $timeZoneList
as $timeZoneInfo ) {
1381 $region = $timeZoneInfo[
'region'];
1382 if ( !isset(
$opt[$region] ) ) {
1385 $opt[$region][$timeZoneInfo[
'name']] = $timeZoneInfo[
'timecorrection'];
1405 $data = explode(
'|', $tz, 3 );
1406 switch ( $data[0] ) {
1410 if (
count( $data ) === 3 ) {
1413 new DateTimeZone( $data[2] );
1416 }
catch ( Exception
$e ) {
1423 return 'Offset|' . intval( $tz[1] );
1429 $data = explode(
':', $tz, 2 );
1430 if (
count( $data ) == 2 ) {
1431 $data[0] = intval( $data[0] );
1432 $data[1] = intval( $data[1] );
1433 $minDiff = abs( $data[0] ) * 60 + $data[1];
1434 if ( $data[0] < 0 ) {
1435 $minDiff = - $minDiff;
1438 $minDiff = intval( $data[0] ) * 60;
1441 # Max is +14:00 and min is -12:00, see:
1442 # https://en.wikipedia.org/wiki/Timezone
1443 $minDiff = min( $minDiff, 840 ); # 14:00
1444 $minDiff = max( $minDiff, -720 ); # -12:00
1445 return 'Offset|' . $minDiff;
1457 $user = $form->getModifiedUser();
1458 $hiddenPrefs = $form->getConfig()->get(
'HiddenPrefs' );
1461 if ( !
$user->isAllowedAny(
'editmyprivateinfo',
'editmyoptions' ) ) {
1466 foreach ( array_keys( $formData )
as $name ) {
1467 if ( isset( self::$saveFilters[
$name] ) ) {
1469 call_user_func( self::$saveFilters[
$name], $formData[
$name], $formData );
1476 if ( !in_array(
'realname', $hiddenPrefs )
1477 &&
$user->isAllowed(
'editmyprivateinfo' )
1478 && array_key_exists(
'realname', $formData )
1480 $realName = $formData[
'realname'];
1481 $user->setRealName( $realName );
1484 if (
$user->isAllowed(
'editmyoptions' ) ) {
1485 foreach ( self::$saveBlacklist
as $b ) {
1486 unset( $formData[$b] );
1489 # If users have saved a value for a preference which has subsequently been disabled
1490 # via $wgHiddenPrefs, we don't want to destroy that setting in case the preference
1491 # is subsequently re-enabled
1492 foreach ( $hiddenPrefs
as $pref ) {
1493 # If the user has not set a non-default value here, the default will be returned
1494 # and subsequently discarded
1495 $formData[$pref] =
$user->getOption( $pref,
null,
true );
1499 $user->resetOptions(
'unused', $form->getContext() );
1501 foreach ( $formData
as $key =>
$value ) {
1509 $user->saveSettings();
1525 if (
$res ===
'eauth' ) {
1526 $urlOptions[
'eauth'] = 1;
1529 $urlOptions += $form->getExtraSuccessRedirectParameters();
1531 $url = $form->getTitle()->getFullURL( $urlOptions );
1552 $identifiers = DateTimeZone::listIdentifiers();
1553 if ( $identifiers ===
false ) {
1556 sort( $identifiers );
1559 'Africa' =>
wfMessage(
'timezoneregion-africa' )->inLanguage( $language )->text(),
1560 'America' =>
wfMessage(
'timezoneregion-america' )->inLanguage( $language )->text(),
1561 'Antarctica' =>
wfMessage(
'timezoneregion-antarctica' )->inLanguage( $language )->text(),
1562 'Arctic' =>
wfMessage(
'timezoneregion-arctic' )->inLanguage( $language )->text(),
1563 'Asia' =>
wfMessage(
'timezoneregion-asia' )->inLanguage( $language )->text(),
1564 'Atlantic' =>
wfMessage(
'timezoneregion-atlantic' )->inLanguage( $language )->text(),
1565 'Australia' =>
wfMessage(
'timezoneregion-australia' )->inLanguage( $language )->text(),
1566 'Europe' =>
wfMessage(
'timezoneregion-europe' )->inLanguage( $language )->text(),
1567 'Indian' =>
wfMessage(
'timezoneregion-indian' )->inLanguage( $language )->text(),
1568 'Pacific' =>
wfMessage(
'timezoneregion-pacific' )->inLanguage( $language )->text(),
1570 asort( $tzRegions );
1574 $now =
new DateTime();
1576 foreach ( $identifiers
as $identifier ) {
1577 $parts = explode(
'/', $identifier, 2 );
1582 if (
count( $parts ) !== 2 || !array_key_exists( $parts[0], $tzRegions ) ) {
1587 $parts[0] = $tzRegions[$parts[0]];
1589 $dateTimeZone =
new DateTimeZone( $identifier );
1590 $minDiff = floor( $dateTimeZone->getOffset( $now ) / 60 );
1592 $display = str_replace(
'_',
' ', $parts[0] .
'/' . $parts[1] );
1593 $value =
"ZoneInfo|$minDiff|$identifier";
1595 $timeZoneList[$identifier] = [
1597 'timecorrection' =>
$value,
1598 'region' => $parts[0],
1602 return $timeZoneList;
1617 $this->modifiedUser =
$user;
1624 if ( $this->modifiedUser ===
null ) {
1648 return parent::wrapForm(
$html );
1655 $attrs = [
'id' =>
'mw-prefs-restoreprefs' ];
1657 if ( !$this->
getModifiedUser()->isAllowedAny(
'editmyprivateinfo',
'editmyoptions' ) ) {
1661 $html = parent::getButtons();
1666 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
1683 foreach ( $this->mFlatFields
as $fieldname => $field ) {
1685 $info = $field->mParams;
1686 $prefix = isset( $info[
'prefix'] ) ? $info[
'prefix'] : $fieldname;
1687 foreach ( $field->filterDataForSubmit( $data[$fieldname] )
as $key =>
$value ) {
1688 $data[
"$prefix$key"] =
$value;
1690 unset( $data[$fieldname] );
1702 return $this->
displaySection( $this->mFieldTree,
'',
'mw-prefsection-' );
1712 $legend = parent::getLegend( $key );
1713 Hooks::run(
'PreferencesGetLegend', [ $this, $key, &$legend ] );
1722 return array_keys( array_filter( $this->mFieldTree,
'is_array' ) );
static getPreferences( $user, IContextSource $context)
getConfig()
Get the Config object.
static getThumbSizes(IContextSource $context)
error also a ContextSource you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
getContext()
Get the base IContextSource object.
static filterTimezoneInput( $tz, $alldata)
Marks HTML that shouldn't be escaped.
wfBCP47( $code)
Get the normalised IETF language tag See unit test for examples.
wfCanIPUseHTTPS( $ip)
Determine whether the client at a given source IP is likely to be able to access the wiki via HTTPS.
processing should stop and the error should be shown to the user * false
static getValidNamespaces()
Returns an array of the namespaces (by integer id) that exist on the wiki.
static rcPreferences( $user, IContextSource $context, &$defaultPreferences)
msg()
Get a Message object with context set Parameters are the same as wfMessage()
static tags( $element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
static editingPreferences( $user, IContextSource $context, &$defaultPreferences)
if(!isset( $args[0])) $lang
switch( $options['output']) $languages
if( $wgRCFilterByAge) $wgDefaultUserOptions['rcdays']
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
static newMainPage()
Create a new Title for the Main Page.
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. & $title:Title object for the current page & $request:WebRequest & $ignoreRedirect:boolean to skip redirect check & $target:Title/string of redirect target & $article:Article object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) & $article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetMagic':DEPRECATED! Use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language & $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetSpecialPageAliases':DEPRECATED! Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language & $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Array with elements of the form "language:title" in the order that they will be output. & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED! Use HtmlPageLinkRendererBegin instead. Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
static getFormObject( $user, IContextSource $context, $formClass='PreferencesForm', array $remove=[])
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
static getTimeZoneList(Language $language)
Get a list of all time zones.
static newFatal( $message)
Factory function for fatal errors.
static searchPreferences( $user, IContextSource $context, &$defaultPreferences)
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form before processing starts Return false to skip default processing and return $ret $linkRenderer
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
static filterIntval( $value, $alldata)
Allows to change the fields on the form that will be generated $name
getRequest()
Get the WebRequest object.
static getDateOptions(IContextSource $context)
static tryUISubmit( $formData, $form)
getUser()
Get the User object.
getTitle()
Get the Title object.
static buttonAttributes(array $attrs, array $modifiers=[])
Modifies a set of attributes meant for button elements and apply a set of default attributes when $wg...
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
static getSaveBlacklist()
static getDefaultOptions()
Combine the language default options with any site-specific options and add the default language vari...
getLanguage()
Get the Language object.
static array $defaultPreferences
We're now using the HTMLForm object with some customisation to generate the Preferences form.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
static fetchLanguageNames( $inLanguage=null, $include='mw')
Get an array of language names, indexed by code.
static getLink( $ugm, IContextSource $context, $format, $userName=null)
Gets a link for a user group, possibly including the expiry date if relevant.
getOutput()
Get the OutputPage object.
static generateSkinOptions( $user, IContextSource $context)
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
see documentation in includes Linker php for Linker::makeImageLink & $time
when a variable name is used in a it is silently declared as a new masking the global
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
static validateSignature( $signature, $alldata, $form)
static miscPreferences( $user, IContextSource $context, &$defaultPreferences)
Dummy, kept for backwards-compatibility.
static hidden( $name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
static watchlistPreferences( $user, IContextSource $context, &$defaultPreferences)
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
static tryFormSubmit( $formData, $form)
Handle the form submission if everything validated properly.
static skinPreferences( $user, IContextSource $context, &$defaultPreferences)
static newFromContext(IContextSource $context)
Get a ParserOptions object from a IContextSource object.
static newGood( $value=null)
Factory function for good results.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
Interface for objects which can provide a MediaWiki context on request.
static profilePreferences( $user, IContextSource $context, &$defaultPreferences)
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
static getTimezoneOptions(IContextSource $context)
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
usually copyright or history_copyright This message must be in HTML not wikitext & $link
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
static getAllowedSkins()
Fetch the list of user-selectable skins in regards to $wgSkipSkins.
static getImageSizes(IContextSource $context)
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
static getLocalInstance( $ts=false)
Get a timestamp instance in the server local timezone ($wgLocaltimezone)
static filesPreferences( $user, IContextSource $context, &$defaultPreferences)
static getOptionFromUser( $name, $info, $user)
Pull option from a user account.
static loadPreferenceValues( $user, $context, &$defaultPreferences)
Loads existing values for a given array of preferences.
static renderingPreferences( $user, IContextSource $context, &$defaultPreferences)
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
Internationalisation code.
static array $saveFilters
Represents a "user group membership" – a specific instance of a user belonging to a group.
the array() calling protocol came about after MediaWiki 1.4rc1.
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang
static cleanSignature( $signature, $alldata, $form)
static datetimePreferences( $user, IContextSource $context, &$defaultPreferences)