20use OOUI\SearchInputWidget;
36 parent::__construct(
'Preferences' );
39 $this->preferencesFactory = $preferencesFactory ?? $services->getPreferencesFactory();
40 $this->userOptionsManager = $userOptionsManager ?? $services->getUserOptionsManager();
53 $out->disallowUserJs(); # Prevent hijacked user scripts from sniffing passwords etc.
58 if ( $par ==
'reset' ) {
64 $out->addModules(
'mediawiki.special.preferences.ooui' );
65 $out->addModuleStyles( [
66 'mediawiki.special.preferences.styles.ooui',
67 'oojs-ui-widgets.styles',
71 if ( $session->get(
'specialPreferencesSaveSuccess' ) ) {
73 $session->remove(
'specialPreferencesSaveSuccess' );
74 $out->addModuleStyles( [
75 'mediawiki.codex.messagebox.styles',
76 'mediawiki.notification.convertmessagebox.styles'
84 $this->
msg(
'savedprefs' )->text()
86 'mw-preferences-messagebox mw-notify-success'
95 $user = $this->
getUser()->getInstanceFromPrimary() ?? $this->
getUser();
101 $sectionTitles = $htmlForm->getPreferenceSections();
104 foreach ( $sectionTitles as $key ) {
107 'label' => $htmlForm->getLegend( $key ),
110 $out->addJsConfigVars(
'wgPreferencesTabs', $prefTabs );
112 $out->addHTML( (
new FieldLayout(
113 new SearchInputWidget( [
114 'placeholder' => $this->
msg(
'searchprefs' )->text(),
117 'classes' => [
'mw-prefs-search' ],
118 'label' => $this->
msg(
'searchprefs' )->text(),
119 'invisibleLabel' =>
true,
133 $form = $this->preferencesFactory->getForm( $user, $context, PreferencesFormOOUI::class );
138 if ( !$this->
getAuthority()->isAllowed(
'editmyoptions' ) ) {
142 $this->
getOutput()->addWikiMsg(
'prefs-reset-intro' );
147 'label-message' =>
'prefs-reset-confirm',
152 HTMLForm::factory(
'ooui', $desc, $this->
getContext(),
'prefs-restore' )
154 ->setSubmitTextMsg(
'restoreprefs' )
155 ->setSubmitDestructive()
167 if ( !$this->
getAuthority()->isAllowed(
'editmyoptions' ) ) {
172 $this->userOptionsManager->resetAllOptions( $user );
173 $this->userOptionsManager->saveOptions( $user );
176 $this->
getRequest()->getSession()->set(
'specialPreferencesSaveSuccess', 1 );
194class_alias( SpecialPreferences::class,
'SpecialPreferences' );
Parent class for all special pages.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getUser()
Shortcut to get the User executing this instance.
requireNamedUser( $reasonMsg='exception-nologin-text', $titleMsg='exception-nologin', bool $alwaysRedirectToLoginPage=false)
If the user is not logged in or is a temporary user, throws UserNotLoggedIn.
getPageTitle( $subpage=false)
Get a self-referential title object.
checkReadOnly()
If the wiki is currently in readonly mode, throws a ReadOnlyError.
getContext()
Gets the context this SpecialPage is executed in.
getRequest()
Get the WebRequest being used for this instance.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getOutput()
Get the OutputPage being used for this instance.
getAuthority()
Shortcut to get the Authority executing this instance.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages By default the message key is the canonical name of...
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Interface for objects which can provide a MediaWiki context on request.