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;
|
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
|
|
|
|
|
|
|
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-09-21 23:13:50 +00:00
|
|
|
null
|
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( [
|
2022-09-21 23:13:50 +00:00
|
|
|
new HashConfig( [] ),
|
2021-08-05 14:30:31 +00:00
|
|
|
$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,
|
2022-09-21 23:13:50 +00:00
|
|
|
/* $overrideName = */ ''
|
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(),
|
|
|
|
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-10-25 21:52:46 +00:00
|
|
|
// Feature: Page tools menu
|
2022-09-28 17:52:01 +00:00
|
|
|
// ================================
|
|
|
|
$featureManager->registerRequirement(
|
|
|
|
new OverridableConfigRequirement(
|
|
|
|
$services->getMainConfig(),
|
|
|
|
$context->getUser(),
|
|
|
|
$context->getRequest(),
|
|
|
|
null,
|
2022-10-25 21:52:46 +00:00
|
|
|
Constants::CONFIG_PAGE_TOOLS,
|
|
|
|
Constants::REQUIREMENT_PAGE_TOOLS
|
2022-09-28 17:52:01 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
$featureManager->registerFeature(
|
2022-10-25 21:52:46 +00:00
|
|
|
Constants::FEATURE_PAGE_TOOLS,
|
2022-09-28 17:52:01 +00:00
|
|
|
[
|
|
|
|
Constants::REQUIREMENT_FULLY_INITIALISED,
|
2022-10-25 21:52:46 +00:00
|
|
|
Constants::REQUIREMENT_PAGE_TOOLS,
|
2022-09-28 17:52:01 +00:00
|
|
|
]
|
|
|
|
);
|
|
|
|
|
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,
|
|
|
|
Constants::REQUIREMENT_PAGE_TOOLS_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,
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
2020-03-13 17:22:59 +00:00
|
|
|
return $featureManager;
|
2020-02-20 16:37:33 +00:00
|
|
|
}
|
|
|
|
];
|