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;
|
|
|
|
use MediaWiki\Skins\Vector\FeatureManagement\Requirements\DynamicConfigRequirement;
|
|
|
|
use MediaWiki\Skins\Vector\FeatureManagement\Requirements\OverridableConfigRequirement;
|
2022-08-01 18:23:14 +00:00
|
|
|
use MediaWiki\Skins\Vector\FeatureManagement\Requirements\TableOfContentsTreatmentRequirement;
|
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-08-25 17:58:18 +00:00
|
|
|
$services->getCentralIdLookupFactory()->getNonLocalLookup(),
|
2021-07-12 23:04:09 +00:00
|
|
|
Constants::CONFIG_KEY_LANGUAGE_IN_HEADER,
|
|
|
|
Constants::REQUIREMENT_LANGUAGE_IN_HEADER,
|
2022-05-12 16:11:24 +00:00
|
|
|
null,
|
2021-07-12 23:04:09 +00:00
|
|
|
Constants::CONFIG_LANGUAGE_IN_HEADER_TREATMENT_AB_TEST
|
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';
|
|
|
|
|
|
|
|
// MultiConfig checks each config in turn, allowing us to override the main config for specific keys. In this
|
|
|
|
// case, override the "VectorLanguageInHeaderABTest" configuration value so that the following requirement
|
|
|
|
// always buckets the user as if the language treatment A/B test were running.
|
|
|
|
$config = new MultiConfig( [
|
|
|
|
new HashConfig( [
|
|
|
|
Constants::CONFIG_LANGUAGE_IN_HEADER_TREATMENT_AB_TEST => true,
|
|
|
|
] ),
|
|
|
|
$services->getMainConfig(),
|
|
|
|
] );
|
|
|
|
|
|
|
|
$featureManager->registerRequirement(
|
|
|
|
new OverridableConfigRequirement(
|
|
|
|
$config,
|
|
|
|
$context->getUser(),
|
|
|
|
$context->getRequest(),
|
2021-08-25 17:58:18 +00:00
|
|
|
$services->getCentralIdLookupFactory()->getNonLocalLookup(),
|
2021-08-05 14:30:31 +00:00
|
|
|
Constants::CONFIG_KEY_LANGUAGE_IN_HEADER,
|
|
|
|
$requirementName,
|
|
|
|
/* $overrideName = */ '',
|
|
|
|
Constants::CONFIG_LANGUAGE_IN_HEADER_TREATMENT_AB_TEST
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
// ---
|
|
|
|
|
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(),
|
|
|
|
null,
|
|
|
|
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-12-07 20:28:58 +00:00
|
|
|
// Feature: T295555: Language switch alert in sidebar
|
|
|
|
// ================================
|
|
|
|
$featureManager->registerRequirement(
|
|
|
|
new OverridableConfigRequirement(
|
|
|
|
$services->getMainConfig(),
|
|
|
|
$context->getUser(),
|
|
|
|
$context->getRequest(),
|
|
|
|
null,
|
|
|
|
Constants::CONFIG_LANGUAGE_ALERT_IN_SIDEBAR,
|
2022-05-12 16:11:24 +00:00
|
|
|
Constants::REQUIREMENT_LANGUAGE_ALERT_IN_SIDEBAR
|
2021-12-07 20:28:58 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$featureManager->registerFeature(
|
|
|
|
Constants::FEATURE_LANGUAGE_ALERT_IN_SIDEBAR,
|
|
|
|
[
|
|
|
|
Constants::REQUIREMENT_FULLY_INITIALISED,
|
|
|
|
Constants::REQUIREMENT_LANGUAGE_IN_HEADER,
|
|
|
|
Constants::REQUIREMENT_LANGUAGE_ALERT_IN_SIDEBAR
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
2021-08-04 17:54:35 +00:00
|
|
|
// Feature: Sticky header
|
|
|
|
// ================================
|
|
|
|
$featureManager->registerRequirement(
|
|
|
|
new OverridableConfigRequirement(
|
|
|
|
$services->getMainConfig(),
|
|
|
|
$context->getUser(),
|
|
|
|
$context->getRequest(),
|
|
|
|
null,
|
|
|
|
Constants::CONFIG_STICKY_HEADER,
|
2022-05-12 16:11:24 +00:00
|
|
|
Constants::REQUIREMENT_STICKY_HEADER
|
2021-08-04 17:54:35 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2021-10-26 21:34:05 +00:00
|
|
|
$featureManager->registerRequirement(
|
|
|
|
new OverridableConfigRequirement(
|
|
|
|
$services->getMainConfig(),
|
|
|
|
$context->getUser(),
|
|
|
|
$context->getRequest(),
|
|
|
|
null,
|
|
|
|
Constants::CONFIG_STICKY_HEADER_EDIT,
|
2022-05-12 16:11:24 +00:00
|
|
|
Constants::REQUIREMENT_STICKY_HEADER_EDIT
|
2021-10-26 21:34:05 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2021-08-04 17:54:35 +00:00
|
|
|
$featureManager->registerFeature(
|
|
|
|
Constants::FEATURE_STICKY_HEADER,
|
|
|
|
[
|
|
|
|
Constants::REQUIREMENT_FULLY_INITIALISED,
|
|
|
|
Constants::REQUIREMENT_STICKY_HEADER
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
2021-10-26 21:34:05 +00:00
|
|
|
$featureManager->registerFeature(
|
|
|
|
Constants::FEATURE_STICKY_HEADER_EDIT,
|
|
|
|
[
|
|
|
|
Constants::REQUIREMENT_FULLY_INITIALISED,
|
|
|
|
Constants::REQUIREMENT_STICKY_HEADER,
|
|
|
|
Constants::REQUIREMENT_STICKY_HEADER_EDIT,
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
2022-08-01 18:23:14 +00:00
|
|
|
// T313435 Feature: Table of Contents
|
|
|
|
// Temporary - remove after TOC A/B test is finished.
|
|
|
|
// ================================
|
|
|
|
$featureManager->registerRequirement(
|
|
|
|
new TableOfContentsTreatmentRequirement(
|
|
|
|
$services->getMainConfig(),
|
|
|
|
$context->getUser(),
|
|
|
|
$services->getCentralIdLookupFactory()->getNonLocalLookup()
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$featureManager->registerFeature(
|
|
|
|
Constants::FEATURE_TABLE_OF_CONTENTS,
|
|
|
|
[
|
|
|
|
Constants::REQUIREMENT_FULLY_INITIALISED,
|
|
|
|
Constants::REQUIREMENT_TABLE_OF_CONTENTS,
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
2022-09-02 14:53:17 +00:00
|
|
|
// Temporary feature: Visual enhancements
|
|
|
|
// ================================
|
|
|
|
$featureManager->registerRequirement(
|
|
|
|
new OverridableConfigRequirement(
|
|
|
|
$services->getMainConfig(),
|
|
|
|
$context->getUser(),
|
|
|
|
$context->getRequest(),
|
|
|
|
$services->getCentralIdLookupFactory()->getNonLocalLookup(),
|
|
|
|
Constants::CONFIG_KEY_VISUAL_ENHANCEMENTS,
|
|
|
|
Constants::REQUIREMENT_VISUAL_ENHANCEMENTS
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$featureManager->registerFeature(
|
|
|
|
Constants::FEATURE_VISUAL_ENHANCEMENTS,
|
|
|
|
[
|
|
|
|
Constants::REQUIREMENT_FULLY_INITIALISED,
|
|
|
|
Constants::REQUIREMENT_VISUAL_ENHANCEMENTS,
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
2020-03-13 17:22:59 +00:00
|
|
|
return $featureManager;
|
2020-02-20 16:37:33 +00:00
|
|
|
}
|
|
|
|
];
|