Go to the documentation of this file.
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' ),
79 if ( self::$defaultPreferences ) {
98 ## Remove preferences that wikis don't want to use
100 foreach ( $wgHiddenPrefs
as $pref ) {
106 ## Make sure that form fields have their parent set. See bug 41337.
109 $disable = !
$user->isAllowed(
'editmyoptions' );
111 ## Prod in defaults from the user
114 if ( $disable && !in_array(
$name, self::$saveBlacklist ) ) {
115 $info[
'disabled'] =
'disabled';
118 $field->mParent = $dummyForm;
125 if ( isset( $info[
'default'] ) ) {
128 } elseif ( !is_null( $prefFromUser ) &&
129 $field->validate( $prefFromUser,
$user->getOptions() ) ===
true ) {
130 $info[
'default'] = $prefFromUser;
131 } elseif ( $field->validate( $globalDefault,
$user->getOptions() ) ===
true ) {
132 $info[
'default'] = $globalDefault;
134 throw new MWException(
"Global default '$globalDefault' is invalid for field $name" );
155 if ( ( isset( $info[
'type'] ) && $info[
'type'] ==
'multiselect' ) ||
156 ( isset( $info[
'class'] ) && $info[
'class'] ==
'HTMLMultiSelectField' ) ) {
158 $prefix = isset( $info[
'prefix'] ) ? $info[
'prefix'] :
$name;
162 if (
$user->getOption(
"$prefix$value" ) ) {
169 if ( ( isset( $info[
'type'] ) && $info[
'type'] ==
'checkmatrix' ) ||
170 ( isset( $info[
'class'] ) && $info[
'class'] ==
'HTMLCheckMatrix' ) ) {
173 $prefix = isset( $info[
'prefix'] ) ? $info[
'prefix'] :
$name;
177 foreach ( $rows
as $row ) {
178 if (
$user->getOption(
"$prefix$column-$row" ) ) {
179 $val[] =
"$column-$row";
196 $wgDisableLangConversion, $wgMaxSigChars,
197 $wgEnableEmail, $wgEmailConfirmToEdit, $wgEnableUserEmail, $wgEmailAuthentication,
198 $wgEnotifWatchlist, $wgEnotifUserTalk, $wgEnotifRevealEditorAddress,
202 $userName =
$user->getName();
204 ## User info #####################################
208 'label-message' =>
array(
'username', $userName ),
209 'default' => $userName,
210 'section' =>
'personal/info',
215 'label-message' =>
array(
'uid', $userName ),
216 'default' =>
$user->getId(),
217 'section' =>
'personal/info',
220 # Get groups to which the user belongs
221 $userEffectiveGroups =
$user->getEffectiveGroups();
222 $userGroups = $userMembers =
array();
223 foreach ( $userEffectiveGroups
as $ueg ) {
234 asort( $userGroups );
235 asort( $userMembers );
241 'label' => $context->
msg(
'prefs-memberingroups' )->numParams(
242 count( $userGroups ) )->params( $userName )->parse(),
243 'default' => $context->
msg(
'prefs-memberingroups-type',
244 $lang->commaList( $userGroups ),
245 $lang->commaList( $userMembers )
248 'section' =>
'personal/info',
252 $lang->formatNum(
$user->getEditCount() ) );
257 'label-message' =>
'prefs-edits',
258 'default' => $editCount,
259 'section' =>
'personal/info',
262 if (
$user->getRegistration() ) {
263 $displayUser = $context->
getUser();
264 $userRegistration =
$user->getRegistration();
267 'label-message' =>
'prefs-registration',
268 'default' => $context->
msg(
269 'prefs-registration-date-time',
270 $lang->userTimeAndDate( $userRegistration, $displayUser ),
271 $lang->userDate( $userRegistration, $displayUser ),
272 $lang->userTime( $userRegistration, $displayUser )
274 'section' =>
'personal/info',
278 $canViewPrivateInfo =
$user->isAllowed(
'viewmyprivateinfo' );
279 $canEditPrivateInfo =
$user->isAllowed(
'editmyprivateinfo' );
284 'type' => $canEditPrivateInfo && $wgAuth->allowPropChange(
'realname' ) ?
'text' :
'info',
285 'default' =>
$user->getRealName(),
286 'section' =>
'personal/info',
287 'label-message' =>
'yourrealname',
288 'help-message' =>
'prefs-help-realname',
291 if ( $canEditPrivateInfo && $wgAuth->allowPasswordChange() ) {
293 $context->
msg(
'prefs-resetpass' )->escaped(),
array(),
300 'label-message' =>
'yourpassword',
301 'section' =>
'personal/info',
308 'label-message' =>
'tog-prefershttps',
309 'help-message' =>
'prefs-help-prefershttps',
310 'section' =>
'personal/info'
316 if ( !array_key_exists( $wgLanguageCode,
$languages ) ) {
317 $languages[$wgLanguageCode] = $wgLanguageCode;
328 'section' =>
'personal/i18n',
330 'label-message' =>
'yourlanguage',
335 'section' =>
'personal/i18n',
337 $context->
msg(
'parentheses',
338 $context->
msg(
'gender-unknown' )->text()
339 )->
text() =>
'unknown',
340 $context->
msg(
'gender-female' )->text() =>
'female',
341 $context->
msg(
'gender-male' )->text() =>
'male',
343 'label-message' =>
'yourgender',
344 'help-message' =>
'prefs-help-gender',
348 if ( !$wgDisableLangConversion ) {
349 foreach ( LanguageConverter::$languagesWithVariants
as $langCode ) {
353 if ( count( $variants ) <= 1 ) {
357 $variantArray =
array();
358 foreach ( $variants
as $v ) {
359 $v = str_replace(
'_',
'-', strtolower( $v ) );
360 $variantArray[$v] = $lang->getVariantname( $v,
false );
364 foreach ( $variantArray
as $code =>
$name ) {
370 'label-message' =>
'yourvariant',
373 'section' =>
'personal/i18n',
374 'help-message' =>
'prefs-help-variant',
388 foreach ( $toggles
as $toggle ) {
391 'section' =>
'personal/i18n',
392 'label-message' =>
"tog-$toggle",
397 $oldsigWikiText =
$wgParser->preSaveTransform(
403 $oldsigHTML = $context->
getOutput()->parseInline( $oldsigWikiText,
true,
true );
407 'label-message' =>
'tog-oldsig',
408 'default' => $oldsigHTML,
409 'section' =>
'personal/signature',
412 'type' => $wgAuth->allowPropChange(
'nickname' ) ?
'text' :
'info',
413 'maxlength' => $wgMaxSigChars,
414 'label-message' =>
'yournick',
415 'validation-callback' =>
array(
'Preferences',
'validateSignature' ),
416 'section' =>
'personal/signature',
417 'filter-callback' =>
array(
'Preferences',
'cleanSignature' ),
421 'label-message' =>
'tog-fancysig',
423 'help-message' =>
'prefs-help-signature',
424 'section' =>
'personal/signature'
429 if ( $wgEnableEmail ) {
430 if ( $canViewPrivateInfo ) {
431 $helpMessages[] = $wgEmailConfirmToEdit
432 ?
'prefs-help-email-required'
433 :
'prefs-help-email';
435 if ( $wgEnableUserEmail ) {
437 $helpMessages[] =
'prefs-help-email-others';
440 $emailAddress =
$user->getEmail() ? htmlspecialchars(
$user->getEmail() ) :
'';
441 if ( $canEditPrivateInfo && $wgAuth->allowPropChange(
'emailaddress' ) ) {
444 $context->
msg(
$user->getEmail() ?
'prefs-changeemail' :
'prefs-setemail' )->escaped(),
448 $emailAddress .= $emailAddress ==
'' ?
$link : (
449 $context->
msg(
'word-separator' )->plain()
450 . $context->
msg(
'parentheses' )->rawParams(
$link )->plain()
457 'default' => $emailAddress,
458 'label-message' =>
'youremail',
459 'section' =>
'personal/email',
460 'help-messages' => $helpMessages,
461 #
'cssclass' chosen
below
465 $disableEmailPrefs =
false;
467 if ( $wgEmailAuthentication ) {
468 $emailauthenticationclass =
'mw-email-not-authenticated';
469 if (
$user->getEmail() ) {
470 if (
$user->getEmailAuthenticationTimestamp() ) {
474 $displayUser = $context->
getUser();
475 $emailTimestamp =
$user->getEmailAuthenticationTimestamp();
476 $time = $lang->userTimeAndDate( $emailTimestamp, $displayUser );
477 $d = $lang->userDate( $emailTimestamp, $displayUser );
478 $t = $lang->userTime( $emailTimestamp, $displayUser );
479 $emailauthenticated = $context->
msg(
'emailauthenticated',
480 $time, $d,
$t )->parse() .
'<br />';
481 $disableEmailPrefs =
false;
482 $emailauthenticationclass =
'mw-email-authenticated';
484 $disableEmailPrefs =
true;
485 $emailauthenticated = $context->
msg(
'emailnotauthenticated' )->parse() .
'<br />' .
488 $context->
msg(
'emailconfirmlink' )->escaped()
490 $emailauthenticationclass =
"mw-email-not-authenticated";
493 $disableEmailPrefs =
true;
494 $emailauthenticated = $context->
msg(
'noemailprefs' )->escaped();
495 $emailauthenticationclass =
'mw-email-none';
498 if ( $canViewPrivateInfo ) {
502 'section' =>
'personal/email',
503 'label-message' =>
'prefs-emailconfirm-label',
504 'default' => $emailauthenticated,
506 'cssclass' => $emailauthenticationclass,
512 if ( $wgEnableUserEmail &&
$user->isAllowed(
'sendemail' ) ) {
516 'section' =>
'personal/email',
517 'label-message' =>
'allowemail',
518 'disabled' => $disableEmailPrefs,
522 'section' =>
'personal/email',
523 'label-message' =>
'tog-ccmeonemails',
524 'disabled' => $disableEmailPrefs,
528 if ( $wgEnotifWatchlist ) {
531 'section' =>
'personal/email',
532 'label-message' =>
'tog-enotifwatchlistpages',
533 'disabled' => $disableEmailPrefs,
536 if ( $wgEnotifUserTalk ) {
539 'section' =>
'personal/email',
540 'label-message' =>
'tog-enotifusertalkpages',
541 'disabled' => $disableEmailPrefs,
544 if ( $wgEnotifUserTalk || $wgEnotifWatchlist ) {
547 'section' =>
'personal/email',
548 'label-message' =>
'tog-enotifminoredits',
549 'disabled' => $disableEmailPrefs,
552 if ( $wgEnotifRevealEditorAddress ) {
555 'section' =>
'personal/email',
556 'label-message' =>
'tog-enotifrevealaddr',
557 'disabled' => $disableEmailPrefs,
571 ## Skin #####################################
572 global $wgAllowUserCss, $wgAllowUserJs;
576 'options' => self::generateSkinOptions(
$user, $context ),
578 'section' =>
'rendering/skin',
581 # Create links to user CSS/JS pages for all skins
582 # This code is basically copied from generateSkinOptions(). It'd
583 # be nice to somehow merge this back in there to avoid redundancy.
584 if ( $wgAllowUserCss || $wgAllowUserJs ) {
585 $linkTools =
array();
586 $userName =
$user->getName();
588 if ( $wgAllowUserCss ) {
590 $linkTools[] =
Linker::link( $cssPage, $context->
msg(
'prefs-custom-css' )->escaped() );
593 if ( $wgAllowUserJs ) {
595 $linkTools[] =
Linker::link( $jsPage, $context->
msg(
'prefs-custom-js' )->escaped() );
601 'default' => $context->
getLanguage()->pipeList( $linkTools ),
602 'label-message' =>
'prefs-common-css-js',
603 'section' =>
'rendering/skin',
614 ## Files #####################################
617 'options' => self::getImageSizes( $context ),
618 'label-message' =>
'imagemaxsize',
619 'section' =>
'rendering/files',
623 'options' => self::getThumbSizes( $context ),
624 'label-message' =>
'thumbsize',
625 'section' =>
'rendering/files',
636 ## Date and time #####################################
638 if ( $dateOptions ) {
641 'options' => $dateOptions,
643 'section' =>
'rendering/dateformat',
651 $lang->time( $now,
true ) );
652 $nowserver = $lang->time( $now,
false ) .
653 Html::hidden(
'wpServerTime', (
int)substr( $now, 8, 2 ) * 60 + (
int)substr( $now, 10, 2 ) );
658 'label-message' =>
'servertime',
659 'default' => $nowserver,
660 'section' =>
'rendering/timeoffset',
666 'label-message' =>
'localtime',
667 'default' => $nowlocal,
668 'section' =>
'rendering/timeoffset',
672 $tzOffset =
$user->getOption(
'timecorrection' );
673 $tz = explode(
'|', $tzOffset, 3 );
677 $tzSetting = $tzOffset;
678 if ( count( $tz ) > 1 && $tz[0] ==
'Offset' ) {
680 $tzSetting = sprintf(
'%+03d:%02d', floor( $minDiff / 60 ), abs( $minDiff ) % 60 );
681 } elseif ( count( $tz ) > 1 && $tz[0] ==
'ZoneInfo' &&
684 # Timezone offset can vary with DST
685 $userTZ = timezone_open( $tz[2] );
686 if ( $userTZ !==
false ) {
687 $minDiff = floor( timezone_offset_get( $userTZ, date_create(
'now' ) ) / 60 );
688 $tzSetting =
"ZoneInfo|$minDiff|{$tz[2]}";
693 'class' =>
'HTMLSelectOrOtherField',
694 'label-message' =>
'timezonelegend',
695 'options' => $tzOptions,
696 'default' => $tzSetting,
698 'section' =>
'rendering/timeoffset',
708 ## Diffs ####################################
711 'section' =>
'rendering/diffs',
712 'label-message' =>
'tog-diffonly',
716 'section' =>
'rendering/diffs',
717 'label-message' =>
'tog-norollbackdiff',
720 ## Page Rendering ##############################
721 global $wgAllowUserCssPrefs;
722 if ( $wgAllowUserCssPrefs ) {
726 $context->
msg(
'underline-never' )->text() => 0,
727 $context->
msg(
'underline-always' )->text() => 1,
728 $context->
msg(
'underline-default' )->text() => 2,
730 'label-message' =>
'tog-underline',
731 'section' =>
'rendering/advancedrendering',
735 $stubThresholdValues =
array( 50, 100, 500, 1000, 2000, 5000, 10000 );
736 $stubThresholdOptions =
array( $context->
msg(
'stub-threshold-disabled' )->text() => 0 );
737 foreach ( $stubThresholdValues
as $value ) {
738 $stubThresholdOptions[$context->
msg(
'size-bytes',
$value )->text()] =
$value;
743 'section' =>
'rendering/advancedrendering',
744 'options' => $stubThresholdOptions,
745 'label-raw' => $context->
msg(
'stub-threshold' )->text(),
750 'section' =>
'rendering/advancedrendering',
751 'label-message' =>
'tog-showhiddencats'
756 'section' =>
'rendering/advancedrendering',
757 'label-message' =>
'tog-numberheadings',
767 global $wgAllowUserCssPrefs;
769 ## Editing #####################################
772 'section' =>
'editing/advancedediting',
773 'label-message' =>
'tog-editsectiononrightclick',
777 'section' =>
'editing/advancedediting',
778 'label-message' =>
'tog-editondblclick',
781 if ( $wgAllowUserCssPrefs ) {
784 'section' =>
'editing/editor',
785 'label-message' =>
'editfont-style',
787 $context->
msg(
'editfont-default' )->text() =>
'default',
788 $context->
msg(
'editfont-monospace' )->text() =>
'monospace',
789 $context->
msg(
'editfont-sansserif' )->text() =>
'sans-serif',
790 $context->
msg(
'editfont-serif' )->text() =>
'serif',
796 'label-message' =>
'columns',
797 'section' =>
'editing/editor',
803 'label-message' =>
'rows',
804 'section' =>
'editing/editor',
808 if (
$user->isAllowed(
'minoredit' ) ) {
811 'section' =>
'editing/editor',
812 'label-message' =>
'tog-minordefault',
817 'section' =>
'editing/editor',
818 'label-message' =>
'tog-forceeditsummary',
822 'section' =>
'editing/editor',
823 'label-message' =>
'tog-useeditwarning',
827 'section' =>
'editing/editor',
828 'label-message' =>
'tog-showtoolbar',
833 'section' =>
'editing/preview',
834 'label-message' =>
'tog-previewonfirst',
838 'section' =>
'editing/preview',
839 'label-message' =>
'tog-previewontop',
843 'section' =>
'editing/preview',
844 'label-message' =>
'tog-uselivepreview',
855 global $wgRCMaxAge, $wgRCShowWatchingUsers;
857 ## RecentChanges #####################################
860 'label-message' =>
'recentchangesdays',
861 'section' =>
'rc/displayrc',
863 'max' => ceil( $wgRCMaxAge / ( 3600 * 24 ) ),
864 'help' => $context->
msg(
'recentchangesdays-max' )->numParams(
865 ceil( $wgRCMaxAge / ( 3600 * 24 ) ) )->text()
869 'label-message' =>
'recentchangescount',
870 'help-message' =>
'prefs-help-recentchangescount',
871 'section' =>
'rc/displayrc',
875 'label-message' =>
'tog-usenewrc',
876 'section' =>
'rc/advancedrc',
880 'label-message' =>
'tog-hideminor',
881 'section' =>
'rc/advancedrc',
884 if (
$user->useRCPatrol() ) {
887 'section' =>
'rc/advancedrc',
888 'label-message' =>
'tog-hidepatrolled',
892 'section' =>
'rc/advancedrc',
893 'label-message' =>
'tog-newpageshidepatrolled',
897 if ( $wgRCShowWatchingUsers ) {
900 'section' =>
'rc/advancedrc',
901 'label-message' =>
'tog-shownumberswatching',
912 global $wgUseRCPatrol, $wgEnableAPI, $wgRCMaxAge;
914 $watchlistdaysMax = ceil( $wgRCMaxAge / ( 3600 * 24 ) );
916 ## Watchlist #####################################
920 'max' => $watchlistdaysMax,
921 'section' =>
'watchlist/displaywatchlist',
922 'help' => $context->
msg(
'prefs-watchlist-days-max' )->numParams(
923 $watchlistdaysMax )->text(),
924 'label-message' =>
'prefs-watchlist-days',
930 'label-message' =>
'prefs-watchlist-edits',
931 'help' => $context->
msg(
'prefs-watchlist-edits-max' )->escaped(),
932 'section' =>
'watchlist/displaywatchlist',
936 'section' =>
'watchlist/advancedwatchlist',
937 'label-message' =>
'tog-extendwatchlist',
941 'section' =>
'watchlist/advancedwatchlist',
942 'label-message' =>
'tog-watchlisthideminor',
946 'section' =>
'watchlist/advancedwatchlist',
947 'label-message' =>
'tog-watchlisthidebots',
951 'section' =>
'watchlist/advancedwatchlist',
952 'label-message' =>
'tog-watchlisthideown',
956 'section' =>
'watchlist/advancedwatchlist',
957 'label-message' =>
'tog-watchlisthideanons',
961 'section' =>
'watchlist/advancedwatchlist',
962 'label-message' =>
'tog-watchlisthideliu',
965 if ( $wgUseRCPatrol ) {
968 'section' =>
'watchlist/advancedwatchlist',
969 'label-message' =>
'tog-watchlisthidepatrolled',
974 'edit' =>
'watchdefault',
975 'move' =>
'watchmoves',
976 'delete' =>
'watchdeletion'
980 if (
$user->isAllowed(
'createpage' ) ||
$user->isAllowed(
'createtalk' ) ) {
981 $watchTypes[
'read'] =
'watchcreations';
984 foreach ( $watchTypes
as $action => $pref ) {
985 if (
$user->isAllowed( $action ) ) {
990 'section' =>
'watchlist/advancedwatchlist',
991 'label-message' =>
"tog-$pref",
996 if ( $wgEnableAPI ) {
1002 'section' =>
'watchlist/tokenwatchlist',
1003 'label-message' =>
'prefs-watchlist-token',
1004 'default' =>
$user->getTokenFromOption(
'watchlisttoken' ),
1005 'help-message' =>
'prefs-help-watchlist-token2',
1020 'label-message' =>
'searcheverything-enable',
1021 'section' =>
'searchoptions/advancedsearchoptions',
1024 $nsOptions =
$wgContLang->getFormattedNamespaces();
1025 $nsOptions[0] = $context->
msg(
'blanknamespace' )->text();
1026 foreach ( $nsOptions
as $ns =>
$name ) {
1028 unset( $nsOptions[$ns] );
1033 'type' =>
'multiselect',
1034 'label-message' =>
'defaultns',
1035 'options' => array_flip( $nsOptions ),
1036 'section' =>
'searchoptions/advancedsearchoptions',
1037 'prefix' =>
'searchNs',
1053 global $wgDefaultSkin, $wgAllowUserCss, $wgAllowUserJs;
1057 $previewtext = $context->
msg(
'skin-preview' )->text();
1059 # Only show skins that aren't disabled in $wgSkipSkins
1062 # Sort by UI skin name. First though need to update validSkinNames as sometimes
1063 # the skinkey & UI skinname differ (e.g. "standard" skinkey is "Classic" in the UI).
1064 foreach ( $validSkinNames
as $skinkey => &$skinname ) {
1065 $msg = $context->
msg(
"skinname-{$skinkey}" );
1066 if ( $msg->exists() ) {
1067 $skinname = htmlspecialchars( $msg->text() );
1070 asort( $validSkinNames );
1072 foreach ( $validSkinNames
as $skinkey => $sn ) {
1073 $linkTools =
array();
1075 # Mark the default skin
1076 if ( $skinkey == $wgDefaultSkin ) {
1077 $linkTools[] = $context->
msg(
'default' )->escaped();
1080 # Create preview link
1081 $mplink = htmlspecialchars( $mptitle->getLocalURL(
array(
'useskin' => $skinkey ) ) );
1082 $linkTools[] =
"<a target='_blank' href=\"$mplink\">$previewtext</a>";
1084 # Create links to user CSS/JS pages
1085 if ( $wgAllowUserCss ) {
1087 $linkTools[] =
Linker::link( $cssPage, $context->
msg(
'prefs-custom-css' )->escaped() );
1090 if ( $wgAllowUserJs ) {
1092 $linkTools[] =
Linker::link( $jsPage, $context->
msg(
'prefs-custom-js' )->escaped() );
1095 $display = $sn .
' ' . $context->
msg(
1099 $ret[$display] = $skinkey;
1111 $dateopts = $lang->getDatePreferences();
1116 if ( !in_array(
'default', $dateopts ) ) {
1117 $dateopts[] =
'default';
1122 global $wgDefaultUserOptions;
1123 if ( !in_array( $wgDefaultUserOptions[
'date'], $dateopts ) ) {
1124 $wgDefaultUserOptions[
'date'] =
'default';
1128 foreach ( $dateopts
as $key ) {
1129 if ( $key ==
'default' ) {
1130 $formatted = $context->
msg(
'datedefault' )->escaped();
1132 $formatted = htmlspecialchars( $lang->timeanddate( $epoch,
false, $key ) );
1134 $ret[$formatted] = $key;
1148 $pixels = $context->
msg(
'unit-pixel' )->text();
1150 foreach ( $wgImageLimits
as $index => $limits ) {
1151 $display =
"{$limits[0]}×{$limits[1]}" . $pixels;
1152 $ret[$display] = $index;
1166 $pixels = $context->
msg(
'unit-pixel' )->text();
1168 foreach ( $wgThumbLimits
as $index =>
$size ) {
1169 $display =
$size . $pixels;
1170 $ret[$display] = $index;
1184 if ( mb_strlen( $signature ) > $wgMaxSigChars ) {
1186 $form->msg(
'badsiglength' )->numParams( $wgMaxSigChars )->text() );
1187 } elseif ( isset( $alldata[
'fancysig'] ) &&
1188 $alldata[
'fancysig'] &&
1193 array(
'class' =>
'error' ),
1194 $form->msg(
'badsig' )->text()
1208 if ( isset( $alldata[
'fancysig'] ) && $alldata[
'fancysig'] ) {
1210 $signature =
$wgParser->cleanSig( $signature );
1213 $signature = Parser::cleanSigInSig( $signature );
1229 $formClass =
'PreferencesForm',
1233 if ( count( $remove ) ) {
1234 $removeKeys = array_flip( $remove );
1235 $formDescriptor = array_diff_key( $formDescriptor, $removeKeys );
1239 foreach ( $formDescriptor
as $name => $info ) {
1240 if ( isset( $info[
'type'] ) && $info[
'type'] ===
'api' ) {
1241 unset( $formDescriptor[
$name] );
1248 $htmlForm =
new $formClass( $formDescriptor, $context,
'prefs' );
1250 $htmlForm->setModifiedUser(
$user );
1251 $htmlForm->setId(
'mw-prefs-form' );
1252 $htmlForm->setSubmitText( $context->
msg(
'saveprefs' )->text() );
1253 # Used message keys: 'accesskey-preferences-save', 'tooltip-preferences-save'
1254 $htmlForm->setSubmitTooltip(
'preferences-save' );
1255 $htmlForm->setSubmitID(
'prefsubmit' );
1256 $htmlForm->setSubmitCallback(
array(
'Preferences',
'tryFormSubmit' ) );
1271 if ( $wgLocalTZoffset ==
$timestamp->format(
'Z' ) / 60 ) {
1272 $server_tz_msg = $context->
msg(
1273 'timezoneuseserverdefault',
1277 $tzstring = sprintf(
1279 floor( $wgLocalTZoffset / 60 ),
1280 abs( $wgLocalTZoffset ) % 60
1282 $server_tz_msg = $context->
msg(
'timezoneuseserverdefault', $tzstring )->text();
1284 $opt[$server_tz_msg] =
"System|$wgLocalTZoffset";
1285 $opt[$context->
msg(
'timezoneuseoffset' )->text()] =
'other';
1286 $opt[$context->
msg(
'guesstimezone' )->text()] =
'guess';
1288 if ( function_exists(
'timezone_identifiers_list' ) ) {
1289 # Read timezone list
1290 $tzs = timezone_identifiers_list();
1293 $tzRegions =
array();
1294 $tzRegions[
'Africa'] = $context->
msg(
'timezoneregion-africa' )->text();
1295 $tzRegions[
'America'] = $context->
msg(
'timezoneregion-america' )->text();
1296 $tzRegions[
'Antarctica'] = $context->
msg(
'timezoneregion-antarctica' )->text();
1297 $tzRegions[
'Arctic'] = $context->
msg(
'timezoneregion-arctic' )->text();
1298 $tzRegions[
'Asia'] = $context->
msg(
'timezoneregion-asia' )->text();
1299 $tzRegions[
'Atlantic'] = $context->
msg(
'timezoneregion-atlantic' )->text();
1300 $tzRegions[
'Australia'] = $context->
msg(
'timezoneregion-australia' )->text();
1301 $tzRegions[
'Europe'] = $context->
msg(
'timezoneregion-europe' )->text();
1302 $tzRegions[
'Indian'] = $context->
msg(
'timezoneregion-indian' )->text();
1303 $tzRegions[
'Pacific'] = $context->
msg(
'timezoneregion-pacific' )->text();
1304 asort( $tzRegions );
1306 $prefill = array_fill_keys( array_values( $tzRegions ),
array() );
1307 $opt = array_merge( $opt, $prefill );
1309 $now = date_create(
'now' );
1311 foreach ( $tzs
as $tz ) {
1312 $z = explode(
'/', $tz, 2 );
1314 # timezone_identifiers_list() returns a number of
1315 # backwards-compatibility entries. This filters them out of the
1316 # list presented to the user.
1317 if ( count( $z ) != 2 || !array_key_exists( $z[0], $tzRegions ) ) {
1322 $z[0] = $tzRegions[$z[0]];
1324 $minDiff = floor( timezone_offset_get( timezone_open( $tz ), $now ) / 60 );
1326 $display = str_replace(
'_',
' ', $z[0] .
'/' . $z[1] );
1327 $value =
"ZoneInfo|$minDiff|$tz";
1329 $opt[$z[0]][$display] =
$value;
1350 $data = explode(
'|', $tz, 3 );
1351 switch ( $data[0] ) {
1356 $data = explode(
':', $tz, 2 );
1357 if ( count( $data ) == 2 ) {
1358 $data[0] = intval( $data[0] );
1359 $data[1] = intval( $data[1] );
1360 $minDiff = abs( $data[0] ) * 60 + $data[1];
1361 if ( $data[0] < 0 ) {
1362 $minDiff = - $minDiff;
1365 $minDiff = intval( $data[0] ) * 60;
1368 # Max is +14:00 and min is -12:00, see:
1369 # http://en.wikipedia.org/wiki/Timezone
1370 $minDiff = min( $minDiff, 840 ); # 14:00
1371 $minDiff = max( $minDiff, - 720 ); # -12:00
1372 return 'Offset|' . $minDiff;
1384 global $wgHiddenPrefs, $wgAuth;
1389 if ( !
$user->isAllowedAny(
'editmyprivateinfo',
'editmyoptions' ) ) {
1394 foreach ( array_keys( $formData )
as $name ) {
1395 if ( isset( self::$saveFilters[
$name] ) ) {
1397 call_user_func( self::$saveFilters[
$name], $formData[
$name], $formData );
1403 if ( !in_array(
'realname', $wgHiddenPrefs ) &&
$user->isAllowed(
'editmyprivateinfo' ) && array_key_exists(
'realname', $formData ) ) {
1404 $realName = $formData[
'realname'];
1405 $user->setRealName( $realName );
1408 if (
$user->isAllowed(
'editmyoptions' ) ) {
1409 foreach ( self::$saveBlacklist
as $b ) {
1410 unset( $formData[$b] );
1413 # If users have saved a value for a preference which has subsequently been disabled
1414 # via $wgHiddenPrefs, we don't want to destroy that setting in case the preference
1415 # is subsequently re-enabled
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 );
1423 $user->resetOptions(
'unused',
$form->getContext() );
1425 foreach ( $formData
as $key =>
$value ) {
1430 $user->saveSettings();
1433 $wgAuth->updateExternalDB(
$user );
1447 $urlOptions =
array(
'success' => 1 );
1449 if (
$res ===
'eauth' ) {
1450 $urlOptions[
'eauth'] = 1;
1453 $urlOptions +=
$form->getExtraSuccessRedirectParameters();
1457 $form->getContext()->getOutput()->redirect( $url );
1497 foreach ( $searchableNamespaces
as $ns =>
$name ) {
1498 if (
$user->getOption(
'searchNs' . $ns ) ) {
1518 $this->modifiedUser =
$user;
1525 if ( $this->modifiedUser ===
null ) {
1549 return parent::wrapForm(
$html );
1556 if ( !$this->
getModifiedUser()->isAllowedAny(
'editmyprivateinfo',
'editmyoptions' ) ) {
1560 $html = parent::getButtons();
1580 foreach ( $this->mFlatFields
as $fieldname => $field ) {
1582 $info = $field->mParams;
1583 $prefix = isset( $info[
'prefix'] ) ? $info[
'prefix'] : $fieldname;
1584 foreach ( $field->filterDataForSubmit( $data[$fieldname] )
as $key =>
$value ) {
1585 $data[
"$prefix$key"] =
$value;
1587 unset( $data[$fieldname] );
1599 return $this->
displaySection( $this->mFieldTree,
'',
'mw-prefsection-' );
1609 $legend = parent::getLegend( $key );
static getPreferences( $user, IContextSource $context)
static getThumbSizes(IContextSource $context)
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. $reader:XMLReader object $logInfo:Array of information Return false to stop further processing of the tag 'ImportHandlePageXMLTag':When parsing a XML tag in a page. $reader:XMLReader object $pageInfo:Array of information Return false to stop further processing of the tag 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information Return false to stop further processing of the tag 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. $reader:XMLReader object Return false to stop further processing of the tag 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. $reader:XMLReader object $revisionInfo:Array of information Return false to stop further processing of the tag '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 '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. '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 '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 '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 wfIsTrustedProxy() $ip:IP being check $result:Change this value to override the result of wfIsTrustedProxy() '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 User::isValidEmailAddr(), 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. '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 '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) '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. 'LinkBegin':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
see documentation in includes Linker php for Linker::makeImageLink & $time
static filterTimezoneInput( $tz, $alldata)
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.
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
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 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
msg()
Get a Message object with context set Parameters are the same as wfMessage()
static trySetUserEmail(User $user, $newaddr)
Try to set a user's email address.
static tags( $element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
static editingPreferences( $user, IContextSource $context, &$defaultPreferences)
static $defaultPreferences
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.
usually copyright or history_copyright This message must be in HTML not wikitext $subpages will be ignored and the rest of subPageSubtitle() will run. 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink' whether MediaWiki currently thinks this is a CSS JS page Hooks may change this value to override the return value of Title::isCssOrJsPage(). 'TitleIsAlwaysKnown' whether MediaWiki currently thinks this page is known isMovable() always returns false. $title whether MediaWiki currently thinks this page is movable Hooks may change this value to override the return value of Title::isMovable(). 'TitleIsWikitextPage' whether MediaWiki currently thinks this is a wikitext page Hooks may change this value to override the return value of Title::isWikitextPage() 'TitleMove' use UploadVerification and UploadVerifyFile instead $form
static searchableNamespaces()
Make a list of searchable namespaces and their canonical names.
return false to override stock group addition can be modified try getUserPermissionsErrors userCan checks are continued by internal code can override on output return false to not delete it return false to override the default password checks this Boolean value will be checked to determine if the password was valid return false to implement your own hashing method this String will be used as the hash which may be added to this hook is run right before returning the options to the caller which means it s potentially called dozens or hundreds of times You may want to cache the results of non trivial operations in your hook function for this reason & $defaultOptions
static makeGroupLinkHTML( $group, $text='')
Create a link to the group in HTML, if available; else return the group name.
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 newGood( $value=null)
Factory function for good results.
static searchPreferences( $user, IContextSource $context, &$defaultPreferences)
msg()
Get a Message object with context set.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name.
static filterIntval( $value, $alldata)
static hidden( $name, $value, $attribs=array())
Convenience function to produce an input element with type=hidden.
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 getDateOptions(IContextSource $context)
static tryUISubmit( $formData, $form)
getUser()
Get the User object.
set to $title object and return false for a match for latest after cache objects are set use the ContentHandler facility to handle CSS and JavaScript for highlighting & $link
static linkKnown( $target, $html=null, $customAttribs=array(), $query=array(), $options=array( 'known', 'noclasses'))
Identical to link(), except $options defaults to 'known'.
static getSaveBlacklist()
static getDefaultOptions()
Combine the language default options with any site-specific options and add the default language vari...
static link( $target, $html=null, $customAttribs=array(), $query=array(), $options=array())
This function returns an HTML link to the given target.
controlled by $wgMainCacheType controlled by $wgParserCacheType controlled by $wgMessageCacheType If you set CACHE_NONE to one of the three control default value for MediaWiki still create a but requests to it are no ops and we always fall through to the database If the cache daemon can t be it should also disable itself fairly smoothly By $wgMemc is used but when it is $parserMemc or $messageMemc this is mentioned below
We're now using the HTMLForm object with some customisation to generate the Preferences form.
static getFormObject( $user, IContextSource $context, $formClass='PreferencesForm', array $remove=array())
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
static fetchLanguageNames( $inLanguage=null, $include='mw')
Get an array of language names, indexed by code.
static generateSkinOptions( $user, IContextSource $context)
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
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)
processing should stop and the error should be shown to the user * false
static miscPreferences( $user, IContextSource $context, &$defaultPreferences)
Dummy, kept for backwards-compatibility.
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 & $options
static watchlistPreferences( $user, IContextSource $context, &$defaultPreferences)
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Allows to change the fields on the form that will be generated $name
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.
getUser()
Get the User object.
getTitle()
Get the Title object.
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 getGroupMember( $group, $username='#')
Get the localized descriptive name for a member of a group, if it exists.
Interface for objects which can provide a context on request.
static getGroupName( $group)
Get the localized descriptive name for a group, if it exists.
static profilePreferences( $user, IContextSource $context, &$defaultPreferences)
static getTimezoneOptions(IContextSource $context)
We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going on
you don t have to do a grep find to see where the $wgReverseTitle variable is used
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
getRequest()
Get the WebRequest object.
static getAllowedSkins()
Fetch the list of user-selectable skins in regards to $wgSkipSkins.
static loadOldSearchNs( $user)
static getImageSizes(IContextSource $context)
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
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 externallinks including delete and has completed for all link tables 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 message
getOutput()
Get the OutputPage object.
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 renderingPreferences( $user, IContextSource $context, &$defaultPreferences)
getLanguage()
Get the Language object.
static newFatal( $message)
Factory function for fatal errors.
static cleanSignature( $signature, $alldata, $form)
static datetimePreferences( $user, IContextSource $context, &$defaultPreferences)