if ( $request->getSessionData( 'specialPreferencesSaveSuccess' ) ) {
// Remove session data for the success message
$request->setSessionData( 'specialPreferencesSaveSuccess', null );
+ $out->addModuleStyles( 'mediawiki.notification.convertmessagebox.styles' );
- $out->wrapWikiMsg(
+ $out->addHtml(
Html::rawElement(
'div',
- array(
- 'class' => 'mw-preferences-messagebox successbox',
- 'id' => 'mw-preferences-success'
- ),
- Html::element( 'p', array(), '$1' )
- ),
- 'savedprefs'
+ [
+ 'class' => 'mw-preferences-messagebox mw-notify-success successbox',
+ 'id' => 'mw-preferences-success',
+ 'data-mw-autohide' => 'false',
+ ],
+ Html::element( 'p', [], $this->msg( 'savedprefs' )->text() )
+ )
);
}
$this->addHelpLink( 'Help:Preferences' );
// Load the user from the master to reduce CAS errors on double post (T95839)
- $user = $this->getUser()->getInstanceForUpdate() ?: $this->getUser();
+ if ( $this->getRequest()->wasPosted() ) {
+ $user = $this->getUser()->getInstanceForUpdate() ?: $this->getUser();
+ } else {
+ $user = $this->getUser();
+ }
$htmlForm = Preferences::getFormObject( $user, $this->getContext() );
- $htmlForm->setSubmitCallback( array( 'Preferences', 'tryUISubmit' ) );
+ $htmlForm->setSubmitCallback( [ 'Preferences', 'tryUISubmit' ] );
$sectionTitles = $htmlForm->getPreferenceSections();
$prefTabs = '';
foreach ( $sectionTitles as $key ) {
$prefTabs .= Html::rawElement( 'li',
- array(
+ [
'role' => 'presentation',
'class' => ( $key === 'personal' ) ? 'selected' : null
- ),
+ ],
Html::rawElement( 'a',
- array(
+ [
'id' => 'preftab-' . $key,
'role' => 'tab',
'href' => '#mw-prefsection-' . $key,
'aria-controls' => 'mw-prefsection-' . $key,
'aria-selected' => ( $key === 'personal' ) ? 'true' : 'false',
'tabIndex' => ( $key === 'personal' ) ? 0 : -1,
- ),
+ ],
$htmlForm->getLegend( $key )
)
);
$out->addHTML(
Html::rawElement( 'ul',
- array(
+ [
'id' => 'preftoc',
'role' => 'tablist'
- ),
+ ],
$prefTabs )
);
$htmlForm->show();
$context = new DerivativeContext( $this->getContext() );
$context->setTitle( $this->getPageTitle( 'reset' ) ); // Reset subpage
- $htmlForm = new HTMLForm( array(), $context, 'prefs-restore' );
+ $htmlForm = new HTMLForm( [], $context, 'prefs-restore' );
$htmlForm->setSubmitTextMsg( 'restoreprefs' );
$htmlForm->setSubmitDestructive();
- $htmlForm->setSubmitCallback( array( $this, 'submitReset' ) );
+ $htmlForm->setSubmitCallback( [ $this, 'submitReset' ] );
$htmlForm->suppressReset();
$htmlForm->show();