OutputPage: Load skin-appropriate OOUI theme
authorBartosz Dziewoński <matma.rex@gmail.com>
Thu, 23 Jul 2015 16:37:53 +0000 (18:37 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Thu, 23 Jul 2015 17:38:44 +0000 (19:38 +0200)
We allow skins to choose the appropriate OOUI theme for it
using 'SkinOOUIThemes', but we ignored that here. Luckily this
was not a problem for the Apex theme (the only one other than
the default, MediaWiki theme), the additional CSS classes
this generated were just ignored.

Depends on Apex and MonoBook skins being updated to use canonical
case for theme names, see I1a88092f0ceb210c642bbee875e368ded3c186f8.

Change-Id: I368804cca141acf9cc15a348d9b7244046395a70

includes/OutputPage.php

index e832b82..22c6890 100644 (file)
@@ -3952,7 +3952,14 @@ class OutputPage extends ContextSource {
         * @since 1.25
         */
        public function enableOOUI() {
-               OOUI\Theme::setSingleton( new OOUI\MediaWikiTheme() );
+               $themes = ExtensionRegistry::getInstance()->getAttribute( 'SkinOOUIThemes' );
+               // Make keys (skin names) lowercase for case-insensitive matching.
+               $themes = array_change_key_case( $themes, CASE_LOWER );
+               $skinName = strtolower( $this->getSkin()->getSkinName() );
+               $theme = isset( $themes[ $skinName ] ) ? $themes[ $skinName ] : 'MediaWiki';
+               // For example, 'OOUI\MediaWikiTheme'.
+               $themeClass = "OOUI\\{$theme}Theme";
+               OOUI\Theme::setSingleton( new $themeClass() );
                OOUI\Element::setDefaultDir( $this->getLanguage()->getDir() );
                $this->addModuleStyles( array(
                        'oojs-ui.styles',