diff --git a/includes/Constants.php b/includes/Constants.php index ba5e9d1..066738d 100644 --- a/includes/Constants.php +++ b/includes/Constants.php @@ -101,11 +101,26 @@ final class Constants { */ public const FEATURE_LATEST_SKIN = 'LatestSkin'; + /** + * @var string + */ + public const FEATURE_LANGUAGE_IN_HEADER = 'LanguageInHeader'; + /** * @var string */ public const CONFIG_KEY_DISABLE_SIDEBAR_PERSISTENCE = 'VectorDisableSidebarPersistence'; + /** + * @var string + */ + public const CONFIG_KEY_LANGUAGE_IN_HEADER = 'VectorLanguageInHeader'; + + /** + * @var string + */ + public const REQUIREMENT_LANGUAGE_IN_HEADER = 'LanguageInHeader'; + // These are used for query parameters. /** * Override the skin version user preference and site Config. See readme. diff --git a/includes/ServiceWiring.php b/includes/ServiceWiring.php index cddcf54..e41df62 100644 --- a/includes/ServiceWiring.php +++ b/includes/ServiceWiring.php @@ -66,6 +66,25 @@ return [ ] ); + // Feature: Languages in sidebar + // ================================ + $featureManager->registerRequirement( + new DynamicConfigRequirement( + $services->getMainConfig(), + Constants::CONFIG_KEY_LANGUAGE_IN_HEADER, + Constants::REQUIREMENT_LANGUAGE_IN_HEADER + ) + ); + + $featureManager->registerFeature( + Constants::FEATURE_LANGUAGE_IN_HEADER, + [ + Constants::REQUIREMENT_FULLY_INITIALISED, + Constants::REQUIREMENT_LATEST_SKIN_VERSION, + Constants::REQUIREMENT_LANGUAGE_IN_HEADER, + ] + ); + return $featureManager; } ]; diff --git a/includes/SkinVector.php b/includes/SkinVector.php index f61ea0f..c50f711 100644 --- a/includes/SkinVector.php +++ b/includes/SkinVector.php @@ -88,6 +88,16 @@ class SkinVector extends SkinMustache { parent::__construct( $options ); } + /** + * @return bool + */ + private function isLanguagesInHeader() { + $featureManager = VectorServices::getFeatureManager(); + return $featureManager->isFeatureEnabled( + Constants::FEATURE_LANGUAGE_IN_HEADER + ); + } + /** * @inheritDoc */ @@ -97,8 +107,6 @@ class SkinVector extends SkinMustache { $out = $skin->getOutput(); $title = $out->getTitle(); - $featureManager = VectorServices::getFeatureManager(); - // Naming conventions for Mustache parameters. // // Value type (first segment): @@ -130,6 +138,7 @@ class SkinVector extends SkinMustache { 'input-location' => $this->getSearchBoxInputLocation(), 'sidebar-visible' => $this->isSidebarVisible(), + 'is-language-in-header' => $this->isLanguagesInHeader(), ] ); if ( $skin->getUser()->isRegistered() ) { @@ -228,6 +237,10 @@ class SkinVector extends SkinMustache { case 'personal': $type = self::MENU_TYPE_DEFAULT; break; + case 'lang': + $type = $this->isLanguagesInHeader() ? + self::MENU_TYPE_DROPDOWN : self::MENU_TYPE_PORTAL; + break; default: $type = self::MENU_TYPE_PORTAL; break; diff --git a/includes/templates/Sidebar.mustache b/includes/templates/Sidebar.mustache index c9331bf..3a916ba 100644 --- a/includes/templates/Sidebar.mustache +++ b/includes/templates/Sidebar.mustache @@ -18,5 +18,7 @@ {{/data-emphasized-sidebar-action}} {{#array-portlets-rest}}{{>Menu}}{{/array-portlets-rest}} + {{^is-language-in-header}} {{#data-portlets.data-languages}}{{>Menu}}{{/data-portlets.data-languages}} + {{/is-language-in-header}} diff --git a/includes/templates/skin.mustache b/includes/templates/skin.mustache index 0ee31db..0d7694c 100644 --- a/includes/templates/skin.mustache +++ b/includes/templates/skin.mustache @@ -52,7 +52,15 @@
{{{html-site-notice}}}
{{>Indicators}} + {{^is-language-in-header}}

{{{html-title}}}

+ {{/is-language-in-header}} + {{#is-language-in-header}} +
+

{{{html-title}}}

+ {{#data-portlets.data-languages}}{{>Menu}}{{/data-portlets.data-languages}} +
+ {{/is-language-in-header}}
{{#page-isarticle}}
{{msg-tagline}}
{{/page-isarticle}}
{{{html-subtitle}}}
diff --git a/resources/skins.vector.styles/layout-default.less b/resources/skins.vector.styles/layout-default.less index b927ee5..b0b6506 100644 --- a/resources/skins.vector.styles/layout-default.less +++ b/resources/skins.vector.styles/layout-default.less @@ -317,3 +317,19 @@ body { } } } + +main.mw-body { + header { + border-bottom: 1px solid @border-color-base; + .mixin-clearfix(); + + h1 { + border-bottom: 0; + float: left; + } + } + + #p-lang { + float: right; + } +} diff --git a/skin.json b/skin.json index 4d75743..7a2c65c 100644 --- a/skin.json +++ b/skin.json @@ -29,6 +29,7 @@ "mediawiki.ui.icon" ], "messages": [ + "otherlanguages", "tooltip-p-logo", "vector-opt-out-tooltip", "vector-opt-out", @@ -215,6 +216,9 @@ "VectorDefaultSidebarVisibleForAnonymousUser": { "value": false }, + "VectorLanguageInHeader": { + "value": false + }, "VectorDisableSidebarPersistence": { "value": false, "description": "@var boolean Temporary feature flag that disables saving the sidebar expanded/collapsed state as a user-preference (triggered via clicking the main menu icon). This is intended as a temporary kill-switch in the event that the DB is overloaded with writes to the user_options table."