2020-02-20 16:37:33 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Service Wirings for Vector skin
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @since 1.35
|
|
|
|
*/
|
|
|
|
|
|
|
|
use MediaWiki\MediaWikiServices;
|
2022-05-23 07:32:40 +00:00
|
|
|
use MediaWiki\Skins\Vector\Constants;
|
|
|
|
use MediaWiki\Skins\Vector\FeatureManagement\FeatureManager;
|
2023-04-11 22:12:52 +00:00
|
|
|
use MediaWiki\Skins\Vector\FeatureManagement\Requirements\ABRequirement;
|
2022-05-23 07:32:40 +00:00
|
|
|
use MediaWiki\Skins\Vector\FeatureManagement\Requirements\DynamicConfigRequirement;
|
2022-10-21 17:39:16 +00:00
|
|
|
use MediaWiki\Skins\Vector\FeatureManagement\Requirements\LimitedWidthContentRequirement;
|
2022-12-07 22:15:31 +00:00
|
|
|
use MediaWiki\Skins\Vector\FeatureManagement\Requirements\LoggedInRequirement;
|
2022-05-23 07:32:40 +00:00
|
|
|
use MediaWiki\Skins\Vector\FeatureManagement\Requirements\OverridableConfigRequirement;
|
2022-12-01 20:05:06 +00:00
|
|
|
use MediaWiki\Skins\Vector\FeatureManagement\Requirements\UserPreferenceRequirement;
|
2020-02-20 16:37:33 +00:00
|
|
|
|
2022-12-24 01:06:10 +00:00
|
|
|
// PHP unit does not understand code coverage for this file
|
|
|
|
// as the @covers annotation cannot cover a specific file
|
|
|
|
// This is partly tested in ServiceWiringTest.php
|
|
|
|
// @codeCoverageIgnoreStart
|
|
|
|
|
2020-02-20 16:37:33 +00:00
|
|
|
return [
|
2021-05-03 14:19:12 +00:00
|
|
|
Constants::SERVICE_FEATURE_MANAGER => static function ( MediaWikiServices $services ) {
|
2020-03-13 17:22:59 +00:00
|
|
|
$featureManager = new FeatureManager();
|
2020-03-25 20:36:44 +00:00
|
|
|
|
2020-04-29 14:13:27 +00:00
|
|
|
$featureManager->registerRequirement(
|
|
|
|
new DynamicConfigRequirement(
|
2020-03-25 20:36:44 +00:00
|
|
|
$services->getMainConfig(),
|
|
|
|
Constants::CONFIG_KEY_FULLY_INITIALISED,
|
|
|
|
Constants::REQUIREMENT_FULLY_INITIALISED
|
2020-04-29 14:13:27 +00:00
|
|
|
)
|
|
|
|
);
|
2020-03-13 17:22:59 +00:00
|
|
|
|
2020-04-20 16:38:01 +00:00
|
|
|
$context = RequestContext::getMain();
|
|
|
|
|
2020-08-18 21:30:25 +00:00
|
|
|
// Feature: Languages in sidebar
|
|
|
|
// ================================
|
2021-04-29 00:47:25 +00:00
|
|
|
$featureManager->registerRequirement(
|
2021-07-12 23:04:09 +00:00
|
|
|
new OverridableConfigRequirement(
|
2021-04-29 00:47:25 +00:00
|
|
|
$services->getMainConfig(),
|
|
|
|
$context->getUser(),
|
|
|
|
$context->getRequest(),
|
2021-07-12 23:04:09 +00:00
|
|
|
Constants::CONFIG_KEY_LANGUAGE_IN_HEADER,
|
2023-05-03 16:55:40 +00:00
|
|
|
Constants::REQUIREMENT_LANGUAGE_IN_HEADER
|
2021-04-29 00:47:25 +00:00
|
|
|
)
|
2020-08-18 21:30:25 +00:00
|
|
|
);
|
|
|
|
|
2021-08-05 14:30:31 +00:00
|
|
|
// ---
|
|
|
|
|
|
|
|
// Temporary T286932 - remove after languages A/B test is finished.
|
|
|
|
$requirementName = 'T286932';
|
|
|
|
|
2022-09-21 23:13:50 +00:00
|
|
|
// MultiConfig checks each config in turn, allowing us to override the main config for specific keys.
|
2021-08-05 14:30:31 +00:00
|
|
|
$config = new MultiConfig( [
|
2023-04-11 22:12:52 +00:00
|
|
|
new HashConfig( [
|
|
|
|
Constants::REQUIREMENT_ZEBRA_AB_TEST => true,
|
|
|
|
] ),
|
2021-08-05 14:30:31 +00:00
|
|
|
$services->getMainConfig(),
|
|
|
|
] );
|
|
|
|
|
2023-04-11 22:12:52 +00:00
|
|
|
$featureManager->registerRequirement(
|
|
|
|
new ABRequirement(
|
|
|
|
$services->getMainConfig(),
|
|
|
|
$context->getUser(),
|
2023-05-22 17:54:41 +00:00
|
|
|
'skin-vector-zebra-experiment',
|
|
|
|
Constants::REQUIREMENT_ZEBRA_AB_TEST
|
2023-04-11 22:12:52 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2021-08-05 14:30:31 +00:00
|
|
|
$featureManager->registerRequirement(
|
|
|
|
new OverridableConfigRequirement(
|
|
|
|
$config,
|
|
|
|
$context->getUser(),
|
|
|
|
$context->getRequest(),
|
|
|
|
Constants::CONFIG_KEY_LANGUAGE_IN_HEADER,
|
2023-04-11 22:12:52 +00:00
|
|
|
$requirementName
|
2021-08-05 14:30:31 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
// ---
|
|
|
|
|
2020-08-18 21:30:25 +00:00
|
|
|
$featureManager->registerFeature(
|
|
|
|
Constants::FEATURE_LANGUAGE_IN_HEADER,
|
|
|
|
[
|
|
|
|
Constants::REQUIREMENT_FULLY_INITIALISED,
|
|
|
|
Constants::REQUIREMENT_LANGUAGE_IN_HEADER,
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
2021-12-03 23:33:21 +00:00
|
|
|
// Feature: T293470: Language in main page header
|
|
|
|
// ================================
|
|
|
|
$featureManager->registerRequirement(
|
|
|
|
new OverridableConfigRequirement(
|
|
|
|
$services->getMainConfig(),
|
|
|
|
$context->getUser(),
|
|
|
|
$context->getRequest(),
|
|
|
|
Constants::CONFIG_LANGUAGE_IN_MAIN_PAGE_HEADER,
|
2022-05-12 16:11:24 +00:00
|
|
|
Constants::REQUIREMENT_LANGUAGE_IN_MAIN_PAGE_HEADER
|
2021-12-03 23:33:21 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$featureManager->registerSimpleRequirement(
|
|
|
|
Constants::REQUIREMENT_IS_MAIN_PAGE,
|
|
|
|
$context->getTitle() ? $context->getTitle()->isMainPage() : false
|
|
|
|
);
|
|
|
|
|
|
|
|
$featureManager->registerFeature(
|
|
|
|
Constants::FEATURE_LANGUAGE_IN_MAIN_PAGE_HEADER,
|
|
|
|
[
|
|
|
|
Constants::REQUIREMENT_FULLY_INITIALISED,
|
|
|
|
Constants::REQUIREMENT_IS_MAIN_PAGE,
|
|
|
|
Constants::REQUIREMENT_LANGUAGE_IN_HEADER,
|
|
|
|
Constants::REQUIREMENT_LANGUAGE_IN_MAIN_PAGE_HEADER
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
2021-08-04 17:54:35 +00:00
|
|
|
// Feature: Sticky header
|
|
|
|
// ================================
|
|
|
|
$featureManager->registerRequirement(
|
|
|
|
new OverridableConfigRequirement(
|
|
|
|
$services->getMainConfig(),
|
|
|
|
$context->getUser(),
|
|
|
|
$context->getRequest(),
|
|
|
|
Constants::CONFIG_STICKY_HEADER,
|
2022-05-12 16:11:24 +00:00
|
|
|
Constants::REQUIREMENT_STICKY_HEADER
|
2021-08-04 17:54:35 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$featureManager->registerFeature(
|
|
|
|
Constants::FEATURE_STICKY_HEADER,
|
|
|
|
[
|
|
|
|
Constants::REQUIREMENT_FULLY_INITIALISED,
|
|
|
|
Constants::REQUIREMENT_STICKY_HEADER
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
2022-12-07 22:15:31 +00:00
|
|
|
// Feature: Page tools pinned
|
|
|
|
// ================================
|
|
|
|
$featureManager->registerRequirement(
|
|
|
|
new LoggedInRequirement(
|
|
|
|
$context->getUser(),
|
|
|
|
Constants::REQUIREMENT_LOGGED_IN
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$featureManager->registerRequirement(
|
|
|
|
new UserPreferenceRequirement(
|
|
|
|
$context->getUser(),
|
|
|
|
$services->getUserOptionsLookup(),
|
|
|
|
Constants::PREF_KEY_PAGE_TOOLS_PINNED,
|
|
|
|
Constants::REQUIREMENT_PAGE_TOOLS_PINNED,
|
|
|
|
$context->getTitle()
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$featureManager->registerFeature(
|
|
|
|
Constants::FEATURE_PAGE_TOOLS_PINNED,
|
|
|
|
[
|
|
|
|
Constants::REQUIREMENT_FULLY_INITIALISED,
|
|
|
|
Constants::REQUIREMENT_LOGGED_IN,
|
|
|
|
Constants::REQUIREMENT_PAGE_TOOLS_PINNED
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
2023-02-23 21:23:46 +00:00
|
|
|
// Feature: Table of Contents pinned
|
|
|
|
// ================================
|
|
|
|
$featureManager->registerRequirement(
|
|
|
|
new UserPreferenceRequirement(
|
|
|
|
$context->getUser(),
|
|
|
|
$services->getUserOptionsLookup(),
|
|
|
|
Constants::PREF_KEY_TOC_PINNED,
|
|
|
|
Constants::REQUIREMENT_TOC_PINNED,
|
|
|
|
$context->getTitle()
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$featureManager->registerFeature(
|
|
|
|
Constants::FEATURE_TOC_PINNED,
|
|
|
|
[
|
|
|
|
Constants::REQUIREMENT_FULLY_INITIALISED,
|
|
|
|
Constants::REQUIREMENT_TOC_PINNED
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
2022-12-15 22:52:24 +00:00
|
|
|
// Feature: Main menu pinned
|
|
|
|
// ================================
|
|
|
|
$featureManager->registerRequirement(
|
|
|
|
new UserPreferenceRequirement(
|
|
|
|
$context->getUser(),
|
|
|
|
$services->getUserOptionsLookup(),
|
|
|
|
Constants::PREF_KEY_MAIN_MENU_PINNED,
|
|
|
|
Constants::REQUIREMENT_MAIN_MENU_PINNED,
|
|
|
|
$context->getTitle()
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$featureManager->registerFeature(
|
|
|
|
Constants::FEATURE_MAIN_MENU_PINNED,
|
|
|
|
[
|
|
|
|
Constants::REQUIREMENT_FULLY_INITIALISED,
|
|
|
|
Constants::REQUIREMENT_LOGGED_IN,
|
|
|
|
Constants::REQUIREMENT_MAIN_MENU_PINNED
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
2022-10-21 17:39:16 +00:00
|
|
|
// Feature: Max Width (skin)
|
|
|
|
// ================================
|
|
|
|
$featureManager->registerRequirement(
|
2022-12-01 20:05:06 +00:00
|
|
|
new UserPreferenceRequirement(
|
2022-10-21 17:39:16 +00:00
|
|
|
$context->getUser(),
|
|
|
|
$services->getUserOptionsLookup(),
|
2022-12-01 20:05:06 +00:00
|
|
|
Constants::PREF_KEY_LIMITED_WIDTH,
|
|
|
|
Constants::REQUIREMENT_LIMITED_WIDTH,
|
2022-10-21 17:39:16 +00:00
|
|
|
$context->getTitle()
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$featureManager->registerFeature(
|
|
|
|
Constants::FEATURE_LIMITED_WIDTH,
|
|
|
|
[
|
|
|
|
Constants::REQUIREMENT_FULLY_INITIALISED,
|
2022-12-01 20:05:06 +00:00
|
|
|
Constants::REQUIREMENT_LIMITED_WIDTH
|
2022-10-21 17:39:16 +00:00
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
// Feature: Max Width (content)
|
|
|
|
// ================================
|
|
|
|
$featureManager->registerRequirement(
|
|
|
|
new LimitedWidthContentRequirement(
|
|
|
|
$services->getMainConfig(),
|
|
|
|
$context->getRequest(),
|
|
|
|
$context->getTitle()
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$featureManager->registerFeature(
|
|
|
|
Constants::FEATURE_LIMITED_WIDTH_CONTENT,
|
|
|
|
[
|
|
|
|
Constants::REQUIREMENT_FULLY_INITIALISED,
|
|
|
|
Constants::REQUIREMENT_LIMITED_WIDTH_CONTENT,
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
2023-03-28 19:59:27 +00:00
|
|
|
// Feature: T332448: feature Zebra#9 design update
|
|
|
|
// ================================
|
|
|
|
$featureManager->registerRequirement(
|
|
|
|
new OverridableConfigRequirement(
|
|
|
|
$services->getMainConfig(),
|
|
|
|
$context->getUser(),
|
|
|
|
$context->getRequest(),
|
|
|
|
Constants::CONFIG_ZEBRA_DESIGN,
|
2023-05-03 16:55:40 +00:00
|
|
|
Constants::REQUIREMENT_ZEBRA_DESIGN
|
2023-03-28 19:59:27 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
$featureManager->registerFeature(
|
|
|
|
Constants::FEATURE_ZEBRA_DESIGN,
|
|
|
|
[
|
|
|
|
Constants::REQUIREMENT_FULLY_INITIALISED,
|
|
|
|
Constants::REQUIREMENT_ZEBRA_DESIGN,
|
2023-04-11 22:12:52 +00:00
|
|
|
Constants::REQUIREMENT_ZEBRA_AB_TEST
|
2023-03-28 19:59:27 +00:00
|
|
|
]
|
|
|
|
);
|
|
|
|
|
2023-08-15 22:49:44 +00:00
|
|
|
// Feature: T343928: Feature Font Size.
|
|
|
|
// ================================
|
|
|
|
$featureManager->registerRequirement(
|
|
|
|
new OverridableConfigRequirement(
|
|
|
|
$services->getMainConfig(),
|
|
|
|
$context->getUser(),
|
|
|
|
$context->getRequest(),
|
|
|
|
Constants::CONFIG_KEY_FONT_SIZE,
|
|
|
|
Constants::REQUIREMENT_FONT_SIZE
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
// Register 'custom-font-size' as the default requirement
|
|
|
|
$featureManager->registerFeature(
|
|
|
|
Constants::FEATURE_FONT_SIZE,
|
|
|
|
[
|
|
|
|
Constants::REQUIREMENT_FULLY_INITIALISED,
|
|
|
|
Constants::REQUIREMENT_FONT_SIZE
|
|
|
|
]
|
|
|
|
);
|
2020-03-13 17:22:59 +00:00
|
|
|
return $featureManager;
|
2020-02-20 16:37:33 +00:00
|
|
|
}
|
|
|
|
];
|
2022-12-24 01:06:10 +00:00
|
|
|
|
|
|
|
// @codeCoverageIgnoreEnd
|