X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialPreferences.php;h=0bc9147fad5cd806e24198e7b800dedcee02836b;hb=1dd54d80af8403c0f36746f482a46ffb41fb28ed;hp=27b6a07c733a299d6cffdf1341c95148438c7140;hpb=4cc846987ba86d34d2d717c7fcff9ca9a09e6b6f;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialPreferences.php b/includes/specials/SpecialPreferences.php index 27b6a07c73..0bc9147fad 100644 --- a/includes/specials/SpecialPreferences.php +++ b/includes/specials/SpecialPreferences.php @@ -29,35 +29,15 @@ use MediaWiki\MediaWikiServices; * @ingroup SpecialPage */ class SpecialPreferences extends SpecialPage { - /** - * @var bool Whether OOUI should be enabled here - */ - private $oouiEnabled = false; - function __construct() { parent::__construct( 'Preferences' ); } - /** - * Check if OOUI mode is enabled, by config or query string - * - * @since 1.32 - * @param IContextSource $context The context. - * @return bool - */ - public static function isOouiEnabled( IContextSource $context ) { - return $context->getRequest()->getFuzzyBool( 'ooui', - $context->getConfig()->get( 'OOUIPreferences' ) - ); - } - public function doesWrites() { return true; } public function execute( $par ) { - $this->oouiEnabled = static::isOouiEnabled( $this->getContext() ); - $this->setHeaders(); $this->outputHeader(); $out = $this->getOutput(); @@ -72,14 +52,12 @@ class SpecialPreferences extends SpecialPage { return; } - if ( $this->oouiEnabled ) { - $out->addModules( 'mediawiki.special.preferences.ooui' ); - $out->addModuleStyles( 'mediawiki.special.preferences.styles.ooui' ); - $out->addModuleStyles( 'oojs-ui-widgets.styles' ); - } else { - $out->addModules( 'mediawiki.special.preferences' ); - $out->addModuleStyles( 'mediawiki.special.preferences.styles' ); - } + $out->addModules( 'mediawiki.special.preferences.ooui' ); + $out->addModuleStyles( [ + 'mediawiki.special.preferences.styles.ooui', + 'mediawiki.widgets.TagMultiselectWidget.styles', + ] ); + $out->addModuleStyles( 'oojs-ui-widgets.styles' ); $session = $this->getRequest()->getSession(); if ( $session->get( 'specialPreferencesSaveSuccess' ) ) { @@ -112,49 +90,14 @@ class SpecialPreferences extends SpecialPage { $htmlForm = $this->getFormObject( $user, $this->getContext() ); $sectionTitles = $htmlForm->getPreferenceSections(); - if ( $this->oouiEnabled ) { - $prefTabs = []; - foreach ( $sectionTitles as $key ) { - $prefTabs[] = [ - 'name' => $key, - 'label' => $htmlForm->getLegend( $key ), - ]; - } - $out->addJsConfigVars( 'wgPreferencesTabs', $prefTabs ); - } else { - - $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 ) - ) - ); - } - - $out->addHTML( - Html::rawElement( 'ul', - [ - 'id' => 'preftoc', - 'role' => 'tablist' - ], - $prefTabs ) - ); + $prefTabs = []; + foreach ( $sectionTitles as $key ) { + $prefTabs[] = [ + 'name' => $key, + 'label' => $htmlForm->getLegend( $key ), + ]; } - - $htmlForm->addHiddenField( 'ooui', $this->oouiEnabled ? '1' : '0' ); + $out->addJsConfigVars( 'wgPreferencesTabs', $prefTabs ); $htmlForm->show(); } @@ -163,15 +106,11 @@ class SpecialPreferences extends SpecialPage { * Get the preferences form to use. * @param User $user The user. * @param IContextSource $context The context. - * @return PreferencesForm|HTMLForm + * @return PreferencesFormOOUI|HTMLForm */ protected function getFormObject( $user, IContextSource $context ) { $preferencesFactory = MediaWikiServices::getInstance()->getPreferencesFactory(); - if ( $this->oouiEnabled ) { - $form = $preferencesFactory->getForm( $user, $context, PreferencesFormOOUI::class ); - } else { - $form = $preferencesFactory->getForm( $user, $context, PreferencesFormLegacy::class ); - } + $form = $preferencesFactory->getForm( $user, $context, PreferencesFormOOUI::class ); return $form; } @@ -184,9 +123,7 @@ class SpecialPreferences extends SpecialPage { $context = new DerivativeContext( $this->getContext() ); $context->setTitle( $this->getPageTitle( 'reset' ) ); // Reset subpage - $htmlForm = HTMLForm::factory( - $this->oouiEnabled ? 'ooui' : 'vform', [], $context, 'prefs-restore' - ); + $htmlForm = HTMLForm::factory( 'ooui', [], $context, 'prefs-restore' ); $htmlForm->setSubmitTextMsg( 'restoreprefs' ); $htmlForm->setSubmitDestructive();