mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-24 06:13:54 +00:00
f614ce6687
Adds a config flag, `MinervaNightMode`, and wires it up as a skin option for enabling/disabling the night mode toggle (sold separately) Additionally, allow this feature to be enabled via the `minervanightmode` query param For now, turning the flag on will result in the class `skin-nightmode-clientpref-1` being added to the HTML element, but in a later change this will be updated to switch values based on the forthcoming client pref Bug: T355118 Change-Id: I35848ab80ee75d324ceb35d17794e2d3e620cc19
117 lines
2.8 KiB
PHP
117 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Minerva;
|
|
|
|
use MediaWiki\MediaWikiServices;
|
|
use MobileContext;
|
|
use MobileFrontend\Features\Feature;
|
|
use MobileFrontend\Features\FeaturesManager;
|
|
use MobileFrontend\Hooks\MobileFrontendFeaturesRegistrationHook;
|
|
use MobileFrontend\Hooks\RequestContextCreateSkinMobileHook;
|
|
use RuntimeException;
|
|
use Skin;
|
|
|
|
/**
|
|
* Hooks from MobileFrontend extension,
|
|
* which is optional to use with this skin.
|
|
*/
|
|
class MobileFrontendHooks implements
|
|
MobileFrontendFeaturesRegistrationHook,
|
|
RequestContextCreateSkinMobileHook
|
|
{
|
|
|
|
/**
|
|
* Register mobile web beta features
|
|
* @see https://www.mediawiki.org/wiki/
|
|
* Extension:MobileFrontend/MobileFrontendFeaturesRegistration
|
|
*
|
|
* @param FeaturesManager $featureManager
|
|
*/
|
|
public function onMobileFrontendFeaturesRegistration( FeaturesManager $featureManager ) {
|
|
$config = MediaWikiServices::getInstance()->getConfigFactory()
|
|
->makeConfig( 'minerva' );
|
|
|
|
try {
|
|
$featureManager->registerFeature(
|
|
new Feature(
|
|
'MinervaShowCategories',
|
|
'skin-minerva',
|
|
$config->get( 'MinervaShowCategories' )
|
|
)
|
|
);
|
|
$featureManager->registerFeature(
|
|
new Feature(
|
|
'MinervaPageIssuesNewTreatment',
|
|
'skin-minerva',
|
|
$config->get( 'MinervaPageIssuesNewTreatment' )
|
|
)
|
|
);
|
|
$featureManager->registerFeature(
|
|
new Feature(
|
|
'MinervaTalkAtTop',
|
|
'skin-minerva',
|
|
$config->get( 'MinervaTalkAtTop' )
|
|
)
|
|
);
|
|
$featureManager->registerFeature(
|
|
new Feature(
|
|
'MinervaDonateLink',
|
|
'skin-minerva',
|
|
$config->get( 'MinervaDonateLink' )
|
|
)
|
|
);
|
|
$featureManager->registerFeature(
|
|
new Feature(
|
|
'MinervaHistoryInPageActions',
|
|
'skin-minerva',
|
|
$config->get( 'MinervaHistoryInPageActions' )
|
|
)
|
|
);
|
|
$featureManager->registerFeature(
|
|
new Feature(
|
|
Hooks::FEATURE_OVERFLOW_PAGE_ACTIONS,
|
|
'skin-minerva',
|
|
$config->get( Hooks::FEATURE_OVERFLOW_PAGE_ACTIONS )
|
|
)
|
|
);
|
|
$featureManager->registerFeature(
|
|
new Feature(
|
|
'MinervaAdvancedMainMenu',
|
|
'skin-minerva',
|
|
$config->get( 'MinervaAdvancedMainMenu' )
|
|
)
|
|
);
|
|
$featureManager->registerFeature(
|
|
new Feature(
|
|
'MinervaPersonalMenu',
|
|
'skin-minerva',
|
|
$config->get( 'MinervaPersonalMenu' )
|
|
)
|
|
);
|
|
$featureManager->registerFeature(
|
|
new Feature(
|
|
'MinervaNightMode',
|
|
'skin-minerva',
|
|
$config->get( 'MinervaNightMode' )
|
|
)
|
|
);
|
|
} catch ( RuntimeException $e ) {
|
|
// features already registered...
|
|
// due to a bug it's possible for this to run twice
|
|
// https://phabricator.wikimedia.org/T165068
|
|
}
|
|
}
|
|
|
|
/**
|
|
* BeforePageDisplayMobile hook handler.
|
|
*
|
|
* @param MobileContext $mobileContext
|
|
* @param Skin $skin
|
|
*/
|
|
public function onRequestContextCreateSkinMobile(
|
|
MobileContext $mobileContext, Skin $skin
|
|
) {
|
|
Hooks::setMinervaSkinOptions( $mobileContext, $skin );
|
|
}
|
|
}
|