X-Git-Url: https://git.heureux-cyclage.org/index.php?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialPreferences.php;h=ed2daffa7c86abdf6a796d0cc563b11c72af70e8;hb=486e566cfef612de6773df435a74d5fc37e27174;hp=eee5b641a36ce3829fdf09b5474a830e2d3aa6eb;hpb=dcdb8e463e3b2be121c61c91df13ea36d270a602;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialPreferences.php b/includes/specials/SpecialPreferences.php index eee5b641a3..ed2daffa7c 100644 --- a/includes/specials/SpecialPreferences.php +++ b/includes/specials/SpecialPreferences.php @@ -50,8 +50,8 @@ class SpecialPreferences extends SpecialPage { return; } - $out->addModules( 'mediawiki.special.preferences' ); - $out->addModuleStyles( 'mediawiki.special.preferences.styles' ); + $out->addModules( 'mediawiki.special.preferences.ooui' ); + $out->addModuleStyles( 'mediawiki.special.preferences.styles.ooui' ); $session = $this->getRequest()->getSession(); if ( $session->get( 'specialPreferencesSaveSuccess' ) ) { @@ -81,42 +81,34 @@ class SpecialPreferences extends SpecialPage { $user = $this->getUser(); } - $htmlForm = Preferences::getFormObject( $user, $this->getContext() ); + $htmlForm = $this->getFormObject( $user, $this->getContext() ); $htmlForm->setSubmitCallback( [ 'Preferences', 'tryUISubmit' ] ); - $sectionTitles = $htmlForm->getPreferenceSections(); - - $prefTabs = ''; - foreach ( $sectionTitles as $key ) { - $prefTabs .= Html::rawElement( 'li', - [ - 'role' => 'presentation', - 'class' => ( $key === 'personal' ) ? 'selected' : null - ], - Html::rawElement( 'a', - [ - '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 ) - ) - ); + + $prefTabs = []; + foreach ( $htmlForm->getPreferenceSections() as $key ) { + $prefTabs[] = [ + 'name' => $key, + 'label' => $htmlForm->getLegend( $key ), + ]; } + $out->addJsConfigVars( 'wgPreferencesTabs', $prefTabs ); + + // TODO: Render fake tabs here to avoid FOUC. + // $out->addHTML( $fakeTabs ); - $out->addHTML( - Html::rawElement( 'ul', - [ - 'id' => 'preftoc', - 'role' => 'tablist' - ], - $prefTabs ) - ); $htmlForm->show(); } + /** + * Get the preferences form to use. + * @param User $user The user. + * @param IContextSource $context The context. + * @return PreferencesForm|HTMLForm + */ + protected function getFormObject( $user, IContextSource $context ) { + return Preferences::getFormObject( $user, $context ); + } + private function showResetForm() { if ( !$this->getUser()->isAllowed( 'editmyoptions' ) ) { throw new PermissionsError( 'editmyoptions' ); @@ -126,7 +118,7 @@ class SpecialPreferences extends SpecialPage { $context = new DerivativeContext( $this->getContext() ); $context->setTitle( $this->getPageTitle( 'reset' ) ); // Reset subpage - $htmlForm = new HTMLForm( [], $context, 'prefs-restore' ); + $htmlForm = HTMLForm::factory( 'ooui', [], $context, 'prefs-restore' ); $htmlForm->setSubmitTextMsg( 'restoreprefs' ); $htmlForm->setSubmitDestructive(); @@ -148,7 +140,7 @@ class SpecialPreferences extends SpecialPage { // Set session data for the success message $this->getRequest()->getSession()->set( 'specialPreferencesSaveSuccess', 1 ); - $url = $this->getPageTitle()->getFullURL(); + $url = $this->getPageTitle()->getFullUrlForRedirect(); $this->getOutput()->redirect( $url ); return true;