33use OOUI\SearchInputWidget;
50 parent::__construct(
'Preferences' );
53 $this->preferencesFactory = $preferencesFactory ?? $services->getPreferencesFactory();
54 $this->userOptionsManager = $userOptionsManager ?? $services->getUserOptionsManager();
65 $out->disallowUserJs(); # Prevent hijacked user scripts from sniffing passwords etc.
70 if ( $par ==
'reset' ) {
76 $out->addModules(
'mediawiki.special.preferences.ooui' );
77 $out->addModuleStyles( [
78 'mediawiki.special.preferences.styles.ooui',
79 'oojs-ui-widgets.styles',
83 if ( $session->get(
'specialPreferencesSaveSuccess' ) ) {
85 $session->remove(
'specialPreferencesSaveSuccess' );
86 $out->addModuleStyles( [
87 'mediawiki.codex.messagebox.styles',
88 'mediawiki.notification.convertmessagebox.styles'
96 $this->
msg(
'savedprefs' )->text()
98 'mw-preferences-messagebox mw-notify-success'
107 $user = $this->
getUser()->getInstanceForUpdate() ?: $this->
getUser();
113 $sectionTitles = $htmlForm->getPreferenceSections();
116 foreach ( $sectionTitles as $key ) {
119 'label' => $htmlForm->getLegend( $key ),
122 $out->addJsConfigVars(
'wgPreferencesTabs', $prefTabs );
124 $out->addHTML(
new FieldLayout(
125 new SearchInputWidget( [
126 'placeholder' => $this->
msg(
'searchprefs' )->text(),
129 'classes' => [
'mw-prefs-search' ],
130 'label' => $this->
msg(
'searchprefs' )->text(),
131 'invisibleLabel' =>
true,
145 $form = $this->preferencesFactory->getForm( $user, $context, PreferencesFormOOUI::class );
150 if ( !$this->
getAuthority()->isAllowed(
'editmyoptions' ) ) {
154 $this->
getOutput()->addWikiMsg(
'prefs-reset-intro' );
159 'label-message' =>
'prefs-reset-confirm',
164 HTMLForm::factory(
'ooui', $desc, $this->
getContext(),
'prefs-restore' )
166 ->setSubmitTextMsg(
'restoreprefs' )
167 ->setSubmitDestructive()
175 if ( !$this->
getAuthority()->isAllowed(
'editmyoptions' ) ) {
179 $user = $this->
getUser()->getInstanceForUpdate();
180 $this->userOptionsManager->resetAllOptions( $user );
181 $user->saveSettings();
184 $this->
getRequest()->getSession()->set(
'specialPreferencesSaveSuccess', 1 );
201class_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.