35use OOUI\SearchInputWidget;
57 parent::__construct(
'Preferences' );
60 $this->preferencesFactory = $preferencesFactory ?? $services->getPreferencesFactory();
61 $this->userOptionsManager = $userOptionsManager ?? $services->getUserOptionsManager();
72 $out->disallowUserJs(); # Prevent hijacked user scripts from sniffing passwords etc.
77 if ( $par ==
'reset' ) {
83 $out->addModules(
'mediawiki.special.preferences.ooui' );
84 $out->addModuleStyles( [
85 'mediawiki.special.preferences.styles.ooui',
86 'oojs-ui-widgets.styles',
90 if ( $session->get(
'specialPreferencesSaveSuccess' ) ) {
92 $session->remove(
'specialPreferencesSaveSuccess' );
93 $out->addModuleStyles(
'mediawiki.notification.convertmessagebox.styles' );
100 $this->
msg(
'savedprefs' )->text()
102 'mw-preferences-messagebox mw-notify-success'
111 $user = $this->
getUser()->getInstanceForUpdate() ?: $this->
getUser();
117 $sectionTitles = $htmlForm->getPreferenceSections();
120 foreach ( $sectionTitles as $key ) {
123 'label' => $htmlForm->getLegend( $key ),
126 $out->addJsConfigVars(
'wgPreferencesTabs', $prefTabs );
128 $out->addHTML(
new FieldLayout(
129 new SearchInputWidget( [
130 'placeholder' => $this->
msg(
'searchprefs' )->text(),
133 'classes' => [
'mw-prefs-search' ],
134 'label' => $this->
msg(
'searchprefs' )->text(),
135 'invisibleLabel' =>
true,
149 $form = $this->preferencesFactory->getForm( $user, $context, PreferencesFormOOUI::class );
154 if ( !$this->
getAuthority()->isAllowed(
'editmyoptions' ) ) {
158 $this->
getOutput()->addWikiMsg(
'prefs-reset-intro' );
163 'label-message' =>
'prefs-reset-confirm',
168 HTMLForm::factory(
'ooui', $desc, $this->
getContext(),
'prefs-restore' )
170 ->setSubmitTextMsg(
'restoreprefs' )
171 ->setSubmitDestructive()
172 ->setSubmitCallback( [ $this,
'submitReset' ] )
179 if ( !$this->
getAuthority()->isAllowed(
'editmyoptions' ) ) {
183 $user = $this->
getUser()->getInstanceForUpdate();
184 $this->userOptionsManager->resetOptions( $user, $this->
getContext(),
'all' );
185 $user->saveSettings();
188 $this->
getRequest()->getSession()->set(
'specialPreferencesSaveSuccess', 1 );
205class_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.
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.
requireNamedUser( $reasonMsg='exception-nologin-text', $titleMsg='exception-nologin')
If the user is not logged in or is a temporary user, throws UserNotLoggedIn.
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 Per default the message key is the canonical name o...
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Show an error when a user tries to do something they do not have the necessary permissions for.
Interface for objects which can provide a MediaWiki context on request.