56 'timecorrection' => [
'Preferences',
'filterTimezoneInput' ],
57 'cols' => [
'Preferences',
'filterIntval' ],
58 'rows' => [
'Preferences',
'filterIntval' ],
59 'rclimit' => [
'Preferences',
'filterIntval' ],
60 'wllimit' => [
'Preferences',
'filterIntval' ],
61 'searchlimit' => [
'Preferences',
'filterIntval' ],
74 return self::$saveBlacklist;
84 if ( self::$defaultPreferences ) {
85 return self::$defaultPreferences;
117 # # Remove preferences that wikis don't want to use
118 foreach (
$context->getConfig()->get(
'HiddenPrefs' )
as $pref ) {
124 # # Make sure that form fields have their parent set. See bug 41337.
127 $disable = !
$user->isAllowed(
'editmyoptions' );
130 # # Prod in defaults from the user
132 $prefFromUser = self::getOptionFromUser(
$name, $info,
$user );
133 if ( $disable && !in_array(
$name, self::$saveBlacklist ) ) {
134 $info[
'disabled'] =
'disabled';
137 $globalDefault = isset( $defaultOptions[
$name] )
138 ? $defaultOptions[
$name]
142 if ( isset( $info[
'default'] ) ) {
145 } elseif ( !is_null( $prefFromUser ) &&
146 $field->validate( $prefFromUser,
$user->getOptions() ) ===
true ) {
147 $info[
'default'] = $prefFromUser;
148 } elseif ( $field->validate( $globalDefault,
$user->getOptions() ) ===
true ) {
149 $info[
'default'] = $globalDefault;
151 throw new MWException(
"Global default '$globalDefault' is invalid for field $name" );
170 if ( ( isset( $info[
'type'] ) && $info[
'type'] ==
'multiselect' ) ||
171 ( isset( $info[
'class'] ) && $info[
'class'] ==
'HTMLMultiSelectField' ) ) {
173 $prefix = isset( $info[
'prefix'] ) ? $info[
'prefix'] :
$name;
177 if (
$user->getOption(
"$prefix$value" ) ) {
184 if ( ( isset( $info[
'type'] ) && $info[
'type'] ==
'checkmatrix' ) ||
185 ( isset( $info[
'class'] ) && $info[
'class'] ==
'HTMLCheckMatrix' ) ) {
188 $prefix = isset( $info[
'prefix'] ) ? $info[
'prefix'] :
$name;
191 foreach ( $columns
as $column ) {
192 foreach ( $rows
as $row ) {
193 if (
$user->getOption(
"$prefix$column-$row" ) ) {
194 $val[] =
"$column-$row";
212 $authManager = AuthManager::singleton();
215 $userName =
$user->getName();
217 # # User info #####################################
221 'label-message' => [
'username', $userName ],
222 'default' => $userName,
223 'section' =>
'personal/info',
226 # Get groups to which the user belongs
227 $userEffectiveGroups =
$user->getEffectiveGroups();
228 $userGroups = $userMembers = [];
229 foreach ( $userEffectiveGroups
as $ueg ) {
240 asort( $userGroups );
241 asort( $userMembers );
247 'label' => $context->
msg(
'prefs-memberingroups' )->numParams(
248 count( $userGroups ) )->params( $userName )->parse(),
249 'default' => $context->
msg(
'prefs-memberingroups-type' )
250 ->rawParams(
$lang->commaList( $userGroups ),
$lang->commaList( $userMembers ) )
253 'section' =>
'personal/info',
262 'label-message' =>
'prefs-edits',
263 'default' => $editCount,
264 'section' =>
'personal/info',
267 if (
$user->getRegistration() ) {
268 $displayUser = $context->
getUser();
269 $userRegistration =
$user->getRegistration();
272 'label-message' =>
'prefs-registration',
273 'default' => $context->
msg(
274 'prefs-registration-date-time',
275 $lang->userTimeAndDate( $userRegistration, $displayUser ),
276 $lang->userDate( $userRegistration, $displayUser ),
277 $lang->userTime( $userRegistration, $displayUser )
279 'section' =>
'personal/info',
283 $canViewPrivateInfo =
$user->isAllowed(
'viewmyprivateinfo' );
284 $canEditPrivateInfo =
$user->isAllowed(
'editmyprivateinfo' );
289 'type' => $canEditPrivateInfo && $authManager->allowsPropertyChange(
'realname' )
291 'default' =>
$user->getRealName(),
292 'section' =>
'personal/info',
293 'label-message' =>
'yourrealname',
294 'help-message' =>
'prefs-help-realname',
297 if ( $canEditPrivateInfo && $authManager->allowsAuthenticationDataChange(
301 $context->
msg(
'prefs-resetpass' )->escaped(), [],
308 'label-message' =>
'yourpassword',
309 'section' =>
'personal/info',
316 'label-message' =>
'tog-prefershttps',
317 'help-message' =>
'prefs-help-prefershttps',
318 'section' =>
'personal/info'
324 $languageCode = $config->get(
'LanguageCode' );
325 if ( !array_key_exists( $languageCode,
$languages ) ) {
337 'section' =>
'personal/i18n',
339 'label-message' =>
'yourlanguage',
344 'section' =>
'personal/i18n',
346 $context->
msg(
'parentheses' )
347 ->params( $context->
msg(
'gender-unknown' )->plain() )
348 ->escaped() =>
'unknown',
349 $context->
msg(
'gender-female' )->escaped() =>
'female',
350 $context->
msg(
'gender-male' )->escaped() =>
'male',
352 'label-message' =>
'yourgender',
353 'help-message' =>
'prefs-help-gender',
357 if ( !$config->get(
'DisableLangConversion' ) ) {
359 if ( $langCode == $wgContLang->getCode() ) {
360 $variants = $wgContLang->getVariants();
362 if ( count( $variants ) <= 1 ) {
367 foreach ( $variants
as $v ) {
368 $v = str_replace(
'_',
'-', strtolower( $v ) );
369 $variantArray[$v] =
$lang->getVariantname( $v,
false );
379 'label-message' =>
'yourvariant',
382 'section' =>
'personal/i18n',
383 'help-message' =>
'prefs-help-variant',
395 $toggles = $wgContLang->getExtraUserToggles();
397 foreach ( $toggles
as $toggle ) {
400 'section' =>
'personal/i18n',
401 'label-message' =>
"tog-$toggle",
406 $oldsigWikiText = $wgParser->preSaveTransform(
412 $oldsigHTML = $context->
getOutput()->parseInline( $oldsigWikiText,
true,
true );
416 'label-message' =>
'tog-oldsig',
417 'default' => $oldsigHTML,
418 'section' =>
'personal/signature',
421 'type' => $authManager->allowsPropertyChange(
'nickname' ) ?
'text' :
'info',
422 'maxlength' => $config->get(
'MaxSigChars' ),
423 'label-message' =>
'yournick',
424 'validation-callback' => [
'Preferences',
'validateSignature' ],
425 'section' =>
'personal/signature',
426 'filter-callback' => [
'Preferences',
'cleanSignature' ],
430 'label-message' =>
'tog-fancysig',
432 'help-message' =>
'prefs-help-signature',
433 'section' =>
'personal/signature'
438 if ( $config->get(
'EnableEmail' ) ) {
439 if ( $canViewPrivateInfo ) {
440 $helpMessages[] = $config->get(
'EmailConfirmToEdit' )
441 ?
'prefs-help-email-required'
442 :
'prefs-help-email';
444 if ( $config->get(
'EnableUserEmail' ) ) {
446 $helpMessages[] =
'prefs-help-email-others';
449 $emailAddress =
$user->getEmail() ? htmlspecialchars(
$user->getEmail() ) :
'';
450 if ( $canEditPrivateInfo && $authManager->allowsPropertyChange(
'emailaddress' ) ) {
453 $context->
msg(
$user->getEmail() ?
'prefs-changeemail' :
'prefs-setemail' )->escaped(),
457 $emailAddress .= $emailAddress ==
'' ?
$link : (
458 $context->
msg(
'word-separator' )->escaped()
459 . $context->
msg(
'parentheses' )->rawParams(
$link )->escaped()
466 'default' => $emailAddress,
467 'label-message' =>
'youremail',
468 'section' =>
'personal/email',
469 'help-messages' => $helpMessages,
470 # 'cssclass' chosen below
474 $disableEmailPrefs =
false;
476 if ( $config->get(
'EmailAuthentication' ) ) {
477 $emailauthenticationclass =
'mw-email-not-authenticated';
478 if (
$user->getEmail() ) {
479 if (
$user->getEmailAuthenticationTimestamp() ) {
483 $displayUser = $context->
getUser();
484 $emailTimestamp =
$user->getEmailAuthenticationTimestamp();
485 $time =
$lang->userTimeAndDate( $emailTimestamp, $displayUser );
486 $d =
$lang->userDate( $emailTimestamp, $displayUser );
487 $t =
$lang->userTime( $emailTimestamp, $displayUser );
488 $emailauthenticated = $context->
msg(
'emailauthenticated',
489 $time, $d,
$t )->parse() .
'<br />';
490 $disableEmailPrefs =
false;
491 $emailauthenticationclass =
'mw-email-authenticated';
493 $disableEmailPrefs =
true;
494 $emailauthenticated = $context->
msg(
'emailnotauthenticated' )->parse() .
'<br />' .
497 $context->
msg(
'emailconfirmlink' )->escaped()
499 $emailauthenticationclass =
"mw-email-not-authenticated";
502 $disableEmailPrefs =
true;
503 $emailauthenticated = $context->
msg(
'noemailprefs' )->escaped();
504 $emailauthenticationclass =
'mw-email-none';
507 if ( $canViewPrivateInfo ) {
511 'section' =>
'personal/email',
512 'label-message' =>
'prefs-emailconfirm-label',
513 'default' => $emailauthenticated,
514 # Apply the same CSS class used on the input to the message:
515 'cssclass' => $emailauthenticationclass,
520 if ( $config->get(
'EnableUserEmail' ) &&
$user->isAllowed(
'sendemail' ) ) {
524 'section' =>
'personal/email',
525 'label-message' =>
'allowemail',
526 'disabled' => $disableEmailPrefs,
530 'section' =>
'personal/email',
531 'label-message' =>
'tog-ccmeonemails',
532 'disabled' => $disableEmailPrefs,
536 if ( $config->get(
'EnotifWatchlist' ) ) {
539 'section' =>
'personal/email',
540 'label-message' =>
'tog-enotifwatchlistpages',
541 'disabled' => $disableEmailPrefs,
544 if ( $config->get(
'EnotifUserTalk' ) ) {
547 'section' =>
'personal/email',
548 'label-message' =>
'tog-enotifusertalkpages',
549 'disabled' => $disableEmailPrefs,
552 if ( $config->get(
'EnotifUserTalk' ) || $config->get(
'EnotifWatchlist' ) ) {
553 if ( $config->get(
'EnotifMinorEdits' ) ) {
556 'section' =>
'personal/email',
557 'label-message' =>
'tog-enotifminoredits',
558 'disabled' => $disableEmailPrefs,
562 if ( $config->get(
'EnotifRevealEditorAddress' ) ) {
565 'section' =>
'personal/email',
566 'label-message' =>
'tog-enotifrevealaddr',
567 'disabled' => $disableEmailPrefs,
581 # # Skin #####################################
584 $skinOptions = self::generateSkinOptions(
$user, $context );
585 if ( $skinOptions ) {
588 'options' => $skinOptions,
590 'section' =>
'rendering/skin',
595 $allowUserCss = $config->get(
'AllowUserCss' );
596 $allowUserJs = $config->get(
'AllowUserJs' );
597 # Create links to user CSS/JS pages for all skins
598 # This code is basically copied from generateSkinOptions(). It'd
599 # be nice to somehow merge this back in there to avoid redundancy.
600 if ( $allowUserCss || $allowUserJs ) {
602 $userName =
$user->getName();
604 if ( $allowUserCss ) {
606 $linkTools[] =
Linker::link( $cssPage, $context->
msg(
'prefs-custom-css' )->escaped() );
609 if ( $allowUserJs ) {
611 $linkTools[] =
Linker::link( $jsPage, $context->
msg(
'prefs-custom-js' )->escaped() );
617 'default' => $context->
getLanguage()->pipeList( $linkTools ),
618 'label-message' =>
'prefs-common-css-js',
619 'section' =>
'rendering/skin',
630 # # Files #####################################
633 'options' => self::getImageSizes( $context ),
634 'label-message' =>
'imagemaxsize',
635 'section' =>
'rendering/files',
639 'options' => self::getThumbSizes( $context ),
640 'label-message' =>
'thumbsize',
641 'section' =>
'rendering/files',
652 # # Date and time #####################################
653 $dateOptions = self::getDateOptions( $context );
654 if ( $dateOptions ) {
657 'options' => $dateOptions,
659 'section' =>
'rendering/dateformat',
666 $nowlocal =
Xml::element(
'span', [
'id' =>
'wpLocalTime' ],
669 [
'format' =>
false,
'timecorrection' =>
false ] ) .
670 Html::hidden(
'wpServerTime', (
int)substr( $now, 8, 2 ) * 60 + (
int)substr( $now, 10, 2 ) );
675 'label-message' =>
'servertime',
676 'default' => $nowserver,
677 'section' =>
'rendering/timeoffset',
683 'label-message' =>
'localtime',
684 'default' => $nowlocal,
685 'section' =>
'rendering/timeoffset',
689 $tzOffset =
$user->getOption(
'timecorrection' );
690 $tz = explode(
'|', $tzOffset, 3 );
692 $tzOptions = self::getTimezoneOptions( $context );
694 $tzSetting = $tzOffset;
695 if ( count( $tz ) > 1 && $tz[0] ==
'Offset' ) {
697 $tzSetting = sprintf(
'%+03d:%02d', floor( $minDiff / 60 ), abs( $minDiff ) % 60 );
698 } elseif ( count( $tz ) > 1 && $tz[0] ==
'ZoneInfo' &&
701 # Timezone offset can vary with DST
702 $userTZ = timezone_open( $tz[2] );
703 if ( $userTZ !==
false ) {
704 $minDiff = floor( timezone_offset_get( $userTZ, date_create(
'now' ) ) / 60 );
705 $tzSetting =
"ZoneInfo|$minDiff|{$tz[2]}";
710 'class' =>
'HTMLSelectOrOtherField',
711 'label-message' =>
'timezonelegend',
712 'options' => $tzOptions,
713 'default' => $tzSetting,
715 'section' =>
'rendering/timeoffset',
725 # # Diffs ####################################
728 'section' =>
'rendering/diffs',
729 'label-message' =>
'tog-diffonly',
733 'section' =>
'rendering/diffs',
734 'label-message' =>
'tog-norollbackdiff',
737 # # Page Rendering ##############################
738 if ( $context->
getConfig()->get(
'AllowUserCssPrefs' ) ) {
742 $context->
msg(
'underline-never' )->text() => 0,
743 $context->
msg(
'underline-always' )->text() => 1,
744 $context->
msg(
'underline-default' )->text() => 2,
746 'label-message' =>
'tog-underline',
747 'section' =>
'rendering/advancedrendering',
751 $stubThresholdValues = [ 50, 100, 500, 1000, 2000, 5000, 10000 ];
752 $stubThresholdOptions = [ $context->
msg(
'stub-threshold-disabled' )->text() => 0 ];
753 foreach ( $stubThresholdValues
as $value ) {
754 $stubThresholdOptions[$context->
msg(
'size-bytes', $value )->text()] =
$value;
759 'section' =>
'rendering/advancedrendering',
760 'options' => $stubThresholdOptions,
762 'label-raw' => $context->
msg(
'stub-threshold' )->rawParams(
763 '<a href="#" class="stub">' .
764 $context->
msg(
'stub-threshold-sample-link' )->parse() .
770 'section' =>
'rendering/advancedrendering',
771 'label-message' =>
'tog-showhiddencats'
776 'section' =>
'rendering/advancedrendering',
777 'label-message' =>
'tog-numberheadings',
787 # # Editing #####################################
790 'section' =>
'editing/advancedediting',
791 'label-message' =>
'tog-editsectiononrightclick',
795 'section' =>
'editing/advancedediting',
796 'label-message' =>
'tog-editondblclick',
799 if ( $context->
getConfig()->get(
'AllowUserCssPrefs' ) ) {
802 'section' =>
'editing/editor',
803 'label-message' =>
'editfont-style',
805 $context->
msg(
'editfont-default' )->text() =>
'default',
806 $context->
msg(
'editfont-monospace' )->text() =>
'monospace',
807 $context->
msg(
'editfont-sansserif' )->text() =>
'sans-serif',
808 $context->
msg(
'editfont-serif' )->text() =>
'serif',
814 'label-message' =>
'columns',
815 'section' =>
'editing/editor',
821 'label-message' =>
'rows',
822 'section' =>
'editing/editor',
826 if (
$user->isAllowed(
'minoredit' ) ) {
829 'section' =>
'editing/editor',
830 'label-message' =>
'tog-minordefault',
835 'section' =>
'editing/editor',
836 'label-message' =>
'tog-forceeditsummary',
840 'section' =>
'editing/editor',
841 'label-message' =>
'tog-useeditwarning',
845 'section' =>
'editing/editor',
846 'label-message' =>
'tog-showtoolbar',
851 'section' =>
'editing/preview',
852 'label-message' =>
'tog-previewonfirst',
856 'section' =>
'editing/preview',
857 'label-message' =>
'tog-previewontop',
861 'section' =>
'editing/preview',
862 'label-message' =>
'tog-uselivepreview',
874 $rcMaxAge = $config->get(
'RCMaxAge' );
875 # # RecentChanges #####################################
878 'label-message' =>
'recentchangesdays',
879 'section' =>
'rc/displayrc',
881 'max' => ceil( $rcMaxAge / ( 3600 * 24 ) ),
882 'help' => $context->
msg(
'recentchangesdays-max' )->numParams(
883 ceil( $rcMaxAge / ( 3600 * 24 ) ) )->escaped()
887 'label-message' =>
'recentchangescount',
888 'help-message' =>
'prefs-help-recentchangescount',
889 'section' =>
'rc/displayrc',
893 'label-message' =>
'tog-usenewrc',
894 'section' =>
'rc/advancedrc',
898 'label-message' =>
'tog-hideminor',
899 'section' =>
'rc/advancedrc',
902 if ( $config->get(
'RCWatchCategoryMembership' ) ) {
905 'label-message' =>
'tog-hidecategorization',
906 'section' =>
'rc/advancedrc',
910 if (
$user->useRCPatrol() ) {
913 'section' =>
'rc/advancedrc',
914 'label-message' =>
'tog-hidepatrolled',
918 if (
$user->useNPPatrol() ) {
921 'section' =>
'rc/advancedrc',
922 'label-message' =>
'tog-newpageshidepatrolled',
926 if ( $config->get(
'RCShowWatchingUsers' ) ) {
929 'section' =>
'rc/advancedrc',
930 'label-message' =>
'tog-shownumberswatching',
942 $watchlistdaysMax = ceil( $config->get(
'RCMaxAge' ) / ( 3600 * 24 ) );
944 # # Watchlist #####################################
945 if (
$user->isAllowed(
'editmywatchlist' ) ) {
946 $editWatchlistLinks = [];
947 $editWatchlistModes = [
948 'edit' => [
'EditWatchlist',
false ],
949 'raw' => [
'EditWatchlist',
'raw' ],
950 'clear' => [
'EditWatchlist',
'clear' ],
952 foreach ( $editWatchlistModes
as $editWatchlistMode => $mode ) {
956 $context->
msg(
"prefs-editwatchlist-{$editWatchlistMode}" )->parse()
963 'default' => $context->
getLanguage()->pipeList( $editWatchlistLinks ),
964 'label-message' =>
'prefs-editwatchlist-label',
965 'section' =>
'watchlist/editwatchlist',
972 'max' => $watchlistdaysMax,
973 'section' =>
'watchlist/displaywatchlist',
974 'help' => $context->
msg(
'prefs-watchlist-days-max' )->numParams(
975 $watchlistdaysMax )->escaped(),
976 'label-message' =>
'prefs-watchlist-days',
982 'label-message' =>
'prefs-watchlist-edits',
983 'help' => $context->
msg(
'prefs-watchlist-edits-max' )->escaped(),
984 'section' =>
'watchlist/displaywatchlist',
988 'section' =>
'watchlist/advancedwatchlist',
989 'label-message' =>
'tog-extendwatchlist',
993 'section' =>
'watchlist/advancedwatchlist',
994 'label-message' =>
'tog-watchlisthideminor',
998 'section' =>
'watchlist/advancedwatchlist',
999 'label-message' =>
'tog-watchlisthidebots',
1003 'section' =>
'watchlist/advancedwatchlist',
1004 'label-message' =>
'tog-watchlisthideown',
1008 'section' =>
'watchlist/advancedwatchlist',
1009 'label-message' =>
'tog-watchlisthideanons',
1013 'section' =>
'watchlist/advancedwatchlist',
1014 'label-message' =>
'tog-watchlisthideliu',
1018 'section' =>
'watchlist/advancedwatchlist',
1019 'label-message' =>
'tog-watchlistreloadautomatically',
1022 if ( $config->get(
'RCWatchCategoryMembership' ) ) {
1025 'section' =>
'watchlist/advancedwatchlist',
1026 'label-message' =>
'tog-watchlisthidecategorization',
1030 if (
$user->useRCPatrol() ) {
1033 'section' =>
'watchlist/advancedwatchlist',
1034 'label-message' =>
'tog-watchlisthidepatrolled',
1039 'edit' =>
'watchdefault',
1040 'move' =>
'watchmoves',
1041 'delete' =>
'watchdeletion'
1045 if (
$user->isAllowed(
'createpage' ) ||
$user->isAllowed(
'createtalk' ) ) {
1046 $watchTypes[
'read'] =
'watchcreations';
1049 if (
$user->isAllowed(
'rollback' ) ) {
1050 $watchTypes[
'rollback'] =
'watchrollback';
1053 if (
$user->isAllowed(
'upload' ) ) {
1054 $watchTypes[
'upload'] =
'watchuploads';
1057 foreach ( $watchTypes
as $action => $pref ) {
1058 if (
$user->isAllowed( $action ) ) {
1064 'section' =>
'watchlist/advancedwatchlist',
1065 'label-message' =>
"tog-$pref",
1070 if ( $config->get(
'EnableAPI' ) ) {
1076 'section' =>
'watchlist/tokenwatchlist',
1077 'label-message' =>
'prefs-watchlist-token',
1078 'default' =>
$user->getTokenFromOption(
'watchlisttoken' ),
1079 'help-message' =>
'prefs-help-watchlist-token2',
1112 $previewtext = $context->
msg(
'skin-preview' )->escaped();
1114 # Only show skins that aren't disabled in $wgSkipSkins
1117 # Sort by UI skin name. First though need to update validSkinNames as sometimes
1118 # the skinkey & UI skinname differ (e.g. "standard" skinkey is "Classic" in the UI).
1119 foreach ( $validSkinNames
as $skinkey => &$skinname ) {
1120 $msg = $context->
msg(
"skinname-{$skinkey}" );
1121 if ( $msg->exists() ) {
1122 $skinname = htmlspecialchars( $msg->text() );
1125 asort( $validSkinNames );
1128 $defaultSkin = $config->get(
'DefaultSkin' );
1129 $allowUserCss = $config->get(
'AllowUserCss' );
1130 $allowUserJs = $config->get(
'AllowUserJs' );
1132 $foundDefault =
false;
1133 foreach ( $validSkinNames
as $skinkey => $sn ) {
1136 # Mark the default skin
1137 if ( strcasecmp( $skinkey, $defaultSkin ) === 0 ) {
1138 $linkTools[] = $context->
msg(
'default' )->escaped();
1139 $foundDefault =
true;
1142 # Create preview link
1143 $mplink = htmlspecialchars( $mptitle->getLocalURL( [
'useskin' => $skinkey ] ) );
1144 $linkTools[] =
"<a target='_blank' href=\"$mplink\">$previewtext</a>";
1146 # Create links to user CSS/JS pages
1147 if ( $allowUserCss ) {
1149 $linkTools[] =
Linker::link( $cssPage, $context->
msg(
'prefs-custom-css' )->escaped() );
1152 if ( $allowUserJs ) {
1154 $linkTools[] =
Linker::link( $jsPage, $context->
msg(
'prefs-custom-js' )->escaped() );
1157 $display = $sn .
' ' . $context->
msg(
'parentheses' )
1158 ->rawParams( $context->
getLanguage()->pipeList( $linkTools ) )
1160 $ret[$display] = $skinkey;
1163 if ( !$foundDefault ) {
1178 $dateopts =
$lang->getDatePreferences();
1183 if ( !in_array(
'default', $dateopts ) ) {
1184 $dateopts[] =
'default';
1190 if ( !in_array( $wgDefaultUserOptions[
'date'], $dateopts ) ) {
1191 $wgDefaultUserOptions[
'date'] =
'default';
1195 foreach ( $dateopts
as $key ) {
1196 if ( $key ==
'default' ) {
1197 $formatted = $context->
msg(
'datedefault' )->escaped();
1199 $formatted = htmlspecialchars(
$lang->timeanddate( $epoch,
false, $key ) );
1201 $ret[$formatted] = $key;
1213 $pixels = $context->
msg(
'unit-pixel' )->text();
1215 foreach ( $context->
getConfig()->get(
'ImageLimits' )
as $index => $limits ) {
1216 $display =
"{$limits[0]}×{$limits[1]}" . $pixels;
1217 $ret[$display] = $index;
1229 $pixels = $context->
msg(
'unit-pixel' )->text();
1231 foreach ( $context->
getConfig()->get(
'ThumbLimits' )
as $index => $size ) {
1232 $display = $size . $pixels;
1233 $ret[$display] = $index;
1247 $maxSigChars = $form->getConfig()->get(
'MaxSigChars' );
1248 if ( mb_strlen( $signature ) > $maxSigChars ) {
1250 $form->msg(
'badsiglength' )->numParams( $maxSigChars )->text() );
1251 } elseif ( isset( $alldata[
'fancysig'] ) &&
1252 $alldata[
'fancysig'] &&
1253 $wgParser->validateSig( $signature ) ===
false
1257 [
'class' =>
'error' ],
1258 $form->msg(
'badsig' )->text()
1272 if ( isset( $alldata[
'fancysig'] ) && $alldata[
'fancysig'] ) {
1274 $signature = $wgParser->cleanSig( $signature );
1293 $formClass =
'PreferencesForm',
1297 if ( count( $remove ) ) {
1298 $removeKeys = array_flip( $remove );
1299 $formDescriptor = array_diff_key( $formDescriptor, $removeKeys );
1303 foreach ( $formDescriptor
as $name => $info ) {
1304 if ( isset( $info[
'type'] ) && $info[
'type'] ===
'api' ) {
1305 unset( $formDescriptor[
$name] );
1312 $htmlForm =
new $formClass( $formDescriptor, $context,
'prefs' );
1314 $htmlForm->setModifiedUser(
$user );
1315 $htmlForm->setId(
'mw-prefs-form' );
1316 $htmlForm->setAutocomplete(
'off' );
1317 $htmlForm->setSubmitText( $context->
msg(
'saveprefs' )->text() );
1318 # Used message keys: 'accesskey-preferences-save', 'tooltip-preferences-save'
1319 $htmlForm->setSubmitTooltip(
'preferences-save' );
1320 $htmlForm->setSubmitID(
'prefsubmit' );
1321 $htmlForm->setSubmitCallback( [
'Preferences',
'tryFormSubmit' ] );
1333 $localTZoffset = $context->
getConfig()->get(
'LocalTZoffset' );
1334 $timeZoneList = self::getTimeZoneList( $context->
getLanguage() );
1338 if ( $localTZoffset == $timestamp->format(
'Z' ) / 60 ) {
1339 $timezoneName = $timestamp->getTimezone()->getName();
1341 if ( isset( $timeZoneList[$timezoneName] ) ) {
1342 $timezoneName = $timeZoneList[$timezoneName][
'name'];
1344 $server_tz_msg = $context->
msg(
1345 'timezoneuseserverdefault',
1349 $tzstring = sprintf(
1351 floor( $localTZoffset / 60 ),
1352 abs( $localTZoffset ) % 60
1354 $server_tz_msg = $context->
msg(
'timezoneuseserverdefault', $tzstring )->text();
1356 $opt[$server_tz_msg] =
"System|$localTZoffset";
1357 $opt[$context->
msg(
'timezoneuseoffset' )->text()] =
'other';
1358 $opt[$context->
msg(
'guesstimezone' )->text()] =
'guess';
1360 foreach ( $timeZoneList
as $timeZoneInfo ) {
1361 $region = $timeZoneInfo[
'region'];
1362 if ( !isset( $opt[$region] ) ) {
1365 $opt[$region][$timeZoneInfo[
'name']] = $timeZoneInfo[
'timecorrection'];
1385 $data = explode(
'|', $tz, 3 );
1386 switch ( $data[0] ) {
1391 $data = explode(
':', $tz, 2 );
1392 if ( count( $data ) == 2 ) {
1393 $data[0] = intval( $data[0] );
1394 $data[1] = intval( $data[1] );
1395 $minDiff = abs( $data[0] ) * 60 + $data[1];
1396 if ( $data[0] < 0 ) {
1397 $minDiff = - $minDiff;
1400 $minDiff = intval( $data[0] ) * 60;
1403 # Max is +14:00 and min is -12:00, see:
1404 # https://en.wikipedia.org/wiki/Timezone
1405 $minDiff = min( $minDiff, 840 ); # 14:00
1406 $minDiff = max( $minDiff, - 720 ); # -12:00
1407 return 'Offset|' . $minDiff;
1419 $user = $form->getModifiedUser();
1420 $hiddenPrefs = $form->getConfig()->get(
'HiddenPrefs' );
1423 if ( !
$user->isAllowedAny(
'editmyprivateinfo',
'editmyoptions' ) ) {
1428 foreach ( array_keys( $formData )
as $name ) {
1429 if ( isset( self::$saveFilters[$name] ) ) {
1431 call_user_func( self::$saveFilters[$name], $formData[$name], $formData );
1438 if ( !in_array(
'realname', $hiddenPrefs )
1439 &&
$user->isAllowed(
'editmyprivateinfo' )
1440 && array_key_exists(
'realname', $formData )
1442 $realName = $formData[
'realname'];
1443 $user->setRealName( $realName );
1446 if (
$user->isAllowed(
'editmyoptions' ) ) {
1447 foreach ( self::$saveBlacklist
as $b ) {
1448 unset( $formData[$b] );
1451 # If users have saved a value for a preference which has subsequently been disabled
1452 # via $wgHiddenPrefs, we don't want to destroy that setting in case the preference
1453 # is subsequently re-enabled
1454 foreach ( $hiddenPrefs
as $pref ) {
1455 # If the user has not set a non-default value here, the default will be returned
1456 # and subsequently discarded
1457 $formData[$pref] =
$user->getOption( $pref, null,
true );
1461 $user->resetOptions(
'unused', $form->getContext() );
1463 foreach ( $formData
as $key =>
$value ) {
1471 $user->saveSettings();
1482 $res = self::tryFormSubmit( $formData, $form );
1487 if (
$res ===
'eauth' ) {
1488 $urlOptions[
'eauth'] = 1;
1491 $urlOptions += $form->getExtraSuccessRedirectParameters();
1493 $url = $form->getTitle()->getFullURL( $urlOptions );
1497 $context->getRequest()->getSession()->set(
'specialPreferencesSaveSuccess', 1 );
1499 $context->getOutput()->redirect( $url );
1514 $identifiers = DateTimeZone::listIdentifiers();
1515 if ( $identifiers ===
false ) {
1518 sort( $identifiers );
1521 'Africa' =>
wfMessage(
'timezoneregion-africa' )->inLanguage( $language )->text(),
1522 'America' =>
wfMessage(
'timezoneregion-america' )->inLanguage( $language )->text(),
1523 'Antarctica' =>
wfMessage(
'timezoneregion-antarctica' )->inLanguage( $language )->text(),
1524 'Arctic' =>
wfMessage(
'timezoneregion-arctic' )->inLanguage( $language )->text(),
1525 'Asia' =>
wfMessage(
'timezoneregion-asia' )->inLanguage( $language )->text(),
1526 'Atlantic' =>
wfMessage(
'timezoneregion-atlantic' )->inLanguage( $language )->text(),
1527 'Australia' =>
wfMessage(
'timezoneregion-australia' )->inLanguage( $language )->text(),
1528 'Europe' =>
wfMessage(
'timezoneregion-europe' )->inLanguage( $language )->text(),
1529 'Indian' =>
wfMessage(
'timezoneregion-indian' )->inLanguage( $language )->text(),
1530 'Pacific' =>
wfMessage(
'timezoneregion-pacific' )->inLanguage( $language )->text(),
1532 asort( $tzRegions );
1536 $now =
new DateTime();
1538 foreach ( $identifiers
as $identifier ) {
1539 $parts = explode(
'/', $identifier, 2 );
1544 if ( count( $parts ) !== 2 || !array_key_exists( $parts[0], $tzRegions ) ) {
1549 $parts[0] = $tzRegions[$parts[0]];
1552 $minDiff = floor( $dateTimeZone->getOffset( $now ) / 60 );
1554 $display = str_replace(
'_',
' ', $parts[0] .
'/' . $parts[1] );
1555 $value =
"ZoneInfo|$minDiff|$identifier";
1557 $timeZoneList[$identifier] = [
1559 'timecorrection' =>
$value,
1560 'region' => $parts[0],
1564 return $timeZoneList;
1579 $this->modifiedUser =
$user;
1586 if ( $this->modifiedUser === null ) {
1610 return parent::wrapForm(
$html );
1618 $attrs = [
'id' =>
'mw-prefs-restoreprefs' ];
1620 if ( !$this->
getModifiedUser()->isAllowedAny(
'editmyprivateinfo',
'editmyoptions' ) ) {
1624 $html = parent::getButtons();
1645 foreach ( $this->mFlatFields
as $fieldname => $field ) {
1647 $info = $field->mParams;
1648 $prefix = isset( $info[
'prefix'] ) ? $info[
'prefix'] : $fieldname;
1649 foreach ( $field->filterDataForSubmit( $data[$fieldname] )
as $key =>
$value ) {
1650 $data[
"$prefix$key"] =
$value;
1652 unset( $data[$fieldname] );
1664 return $this->
displaySection( $this->mFieldTree,
'',
'mw-prefsection-' );
1674 $legend = parent::getLegend( $key );
1675 Hooks::run(
'PreferencesGetLegend', [ $this, $key, &$legend ] );
1684 return array_keys( array_filter( $this->mFieldTree,
'is_array' ) );
static array $saveFilters
static newFromContext(IContextSource $context)
Get a ParserOptions object from a IContextSource object.
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
Interface for objects which can provide a MediaWiki context on request.
the array() calling protocol came about after MediaWiki 1.4rc1.
wfCanIPUseHTTPS($ip)
Determine whether the client at a given source IP is likely to be able to access the wiki via HTTPS...
static getImageSizes(IContextSource $context)
static element($element, $attribs=null, $contents= '', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
static filterTimezoneInput($tz, $alldata)
processing should stop and the error should be shown to the user * false
static newMainPage()
Create a new Title for the Main Page.
static skinPreferences($user, IContextSource $context, &$defaultPreferences)
static rcPreferences($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 & $ret
static validateSignature($signature, $alldata, $form)
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
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 newFatal($message)
Factory function for fatal errors.
msg()
Get a Message object with context set.
static editingPreferences($user, IContextSource $context, &$defaultPreferences)
if(!isset($args[0])) $lang
static loadPreferenceValues($user, $context, &$defaultPreferences)
Loads existing values for a given array of preferences.
static hidden($name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
static array $defaultPreferences
static array static $saveBlacklist
static getDateOptions(IContextSource $context)
static filesPreferences($user, IContextSource $context, &$defaultPreferences)
static miscPreferences($user, IContextSource $context, &$defaultPreferences)
Dummy, kept for backwards-compatibility.
when a variable name is used in a it is silently declared as a new local masking the global
static getPreferences($user, IContextSource $context)
static generateSkinOptions($user, IContextSource $context)
static makeGroupLinkHTML($group, $text= '')
Create a link to the group in HTML, if available; else return the group name.
static fetchLanguageNames($inLanguage=null, $include= 'mw')
Get an array of language names, indexed by code.
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:Associative array mapping language codes to prefixed links of the form"language:title".&$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 getLocalInstance($ts=false)
Get a timestamp instance in the server local timezone ($wgLocaltimezone)
usually copyright or history_copyright This message must be in HTML not wikitext & $link
static getTimeZoneList(Language $language)
Get a list of all time zones.
getUser()
Get the User object.
msg()
Get a Message object with context set Parameters are the same as wfMessage()
getConfig()
Get the site configuration.
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 unsetoffset-wrap String Wrap the message in html(usually something like"<
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist 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
static searchPreferences($user, IContextSource $context, &$defaultPreferences)
switch($options['output']) $languages
static getSaveBlacklist()
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
static getFormObject($user, IContextSource $context, $formClass= 'PreferencesForm', array $remove=[])
static makeTitleSafe($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
static watchlistPreferences($user, IContextSource $context, &$defaultPreferences)
static datetimePreferences($user, IContextSource $context, &$defaultPreferences)
static renderingPreferences($user, IContextSource $context, &$defaultPreferences)
wfBCP47($code)
Get the normalised IETF language tag See unit test for examples.
static linkKnown($target, $html=null, $customAttribs=[], $query=[], $options=[ 'known'])
Identical to link(), except $options defaults to 'known'.
static newGood($value=null)
Factory function for good results.
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
getLanguage()
Get the Language object.
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
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 filterIntval($value, $alldata)
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 local account $user
static link($target, $html=null, $customAttribs=[], $query=[], $options=[])
This function returns an HTML link to the given target.
static getGroupName($group)
Get the localized descriptive name for a group, if it exists.
static tryFormSubmit($formData, $form)
Handle the form submission if everything validated properly.
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 tags($element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
static getGroupMember($group, $username= '#')
Get the localized descriptive name for a member of a group, if it exists.
static profilePreferences($user, IContextSource $context, &$defaultPreferences)
static buttonAttributes(array $attrs, array $modifiers=[])
Modifies a set of attributes meant for button elements and apply a set of default attributes when $wg...
getTitle()
Get the Title object.
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 local content language as $wgContLang
static cleanSigInSig($text)
Strip 3, 4 or 5 tildes out of signatures.
getOutput()
Get the OutputPage object.
static cleanSignature($signature, $alldata, $form)
static getTimezoneOptions(IContextSource $context)
We're now using the HTMLForm object with some customisation to generate the Preferences form...
static getThumbSizes(IContextSource $context)
static getDefaultOptions()
Combine the language default options with any site-specific options and add the default language vari...
static array $languagesWithVariants
languages supporting variants
static getValidNamespaces()
Returns an array of the namespaces (by integer id) that exist on the wiki.
static tryUISubmit($formData, $form)
static getAllowedSkins()
Fetch the list of user-selectable skins in regards to $wgSkipSkins.
getUser()
Get the User object.
getRequest()
Get the WebRequest object.
if($wgRCFilterByAge) $wgDefaultUserOptions['rcdays']
see documentation in includes Linker php for Linker::makeImageLink & $time
static getOptionFromUser($name, $info, $user)
Pull option from a user account.
Allows to change the fields on the form that will be generated $name