32use OOUI\SearchInputWidget;
54 parent::__construct(
'Preferences' );
57 $this->preferencesFactory = $preferencesFactory ?? $services->getPreferencesFactory();
58 $this->userOptionsManager = $userOptionsManager ?? $services->getUserOptionsManager();
69 $out->disallowUserJs(); # Prevent hijacked user scripts from sniffing passwords etc.
74 if ( $par ==
'reset' ) {
80 $out->addModules(
'mediawiki.special.preferences.ooui' );
81 $out->addModuleStyles( [
82 'mediawiki.special.preferences.styles.ooui',
83 'oojs-ui-widgets.styles',
87 if ( $session->get(
'specialPreferencesSaveSuccess' ) ) {
89 $session->remove(
'specialPreferencesSaveSuccess' );
90 $out->addModuleStyles(
'mediawiki.notification.convertmessagebox.styles' );
97 $this->
msg(
'savedprefs' )->text()
99 'mw-preferences-messagebox mw-notify-success'
108 $user = $this->
getUser()->getInstanceForUpdate() ?: $this->
getUser();
114 $sectionTitles = $htmlForm->getPreferenceSections();
117 foreach ( $sectionTitles as $key ) {
120 'label' => $htmlForm->getLegend( $key ),
123 $out->addJsConfigVars(
'wgPreferencesTabs', $prefTabs );
125 $out->addHTML(
new FieldLayout(
126 new SearchInputWidget( [
127 'placeholder' => $this->
msg(
'searchprefs' )->text(),
130 'classes' => [
'mw-prefs-search' ],
131 'label' => $this->
msg(
'searchprefs' )->text(),
132 'invisibleLabel' =>
true,
146 $form = $this->preferencesFactory->getForm( $user, $context, PreferencesFormOOUI::class );
151 if ( !$this->
getAuthority()->isAllowed(
'editmyoptions' ) ) {
155 $this->
getOutput()->addWikiMsg(
'prefs-reset-intro' );
160 'label-message' =>
'prefs-reset-confirm',
165 HTMLForm::factory(
'ooui', $desc, $this->
getContext(),
'prefs-restore' )
167 ->setSubmitTextMsg(
'restoreprefs' )
168 ->setSubmitDestructive()
169 ->setSubmitCallback( [ $this,
'submitReset' ] )
176 if ( !$this->
getAuthority()->isAllowed(
'editmyoptions' ) ) {
180 $user = $this->
getUser()->getInstanceForUpdate();
181 $this->userOptionsManager->resetAllOptions( $user );
182 $user->saveSettings();
185 $this->
getRequest()->getSession()->set(
'specialPreferencesSaveSuccess', 1 );
202class_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 By default the message key is the canonical name of...
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.