2023-08-15 15:02:31 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace MediaWiki\Minerva;
|
|
|
|
|
2024-02-26 19:47:57 +00:00
|
|
|
use MediaWiki\Config\ConfigFactory;
|
2023-08-15 15:02:31 +00:00
|
|
|
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
|
|
|
|
{
|
2024-02-26 19:47:57 +00:00
|
|
|
private ConfigFactory $configFactory;
|
2024-03-12 19:35:14 +00:00
|
|
|
private SkinOptions $skinOptions;
|
2024-02-26 19:47:57 +00:00
|
|
|
|
|
|
|
public function __construct(
|
2024-03-12 19:35:14 +00:00
|
|
|
ConfigFactory $configFactory,
|
|
|
|
SkinOptions $skinOptions
|
2024-02-26 19:47:57 +00:00
|
|
|
) {
|
|
|
|
$this->configFactory = $configFactory;
|
2024-03-12 19:35:14 +00:00
|
|
|
$this->skinOptions = $skinOptions;
|
2024-02-26 19:47:57 +00:00
|
|
|
}
|
2023-08-15 15:02:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Register mobile web beta features
|
|
|
|
* @see https://www.mediawiki.org/wiki/
|
|
|
|
* Extension:MobileFrontend/MobileFrontendFeaturesRegistration
|
|
|
|
*
|
2024-05-28 19:53:45 +00:00
|
|
|
* @param FeaturesManager $featuresManager
|
2023-08-15 15:02:31 +00:00
|
|
|
*/
|
2024-05-28 19:53:45 +00:00
|
|
|
public function onMobileFrontendFeaturesRegistration( FeaturesManager $featuresManager ) {
|
2024-02-26 19:47:57 +00:00
|
|
|
$config = $this->configFactory->makeConfig( 'minerva' );
|
2023-08-15 15:02:31 +00:00
|
|
|
|
|
|
|
try {
|
2024-05-28 19:53:45 +00:00
|
|
|
$featuresManager->registerFeature(
|
2023-08-15 15:02:31 +00:00
|
|
|
new Feature(
|
|
|
|
'MinervaShowCategories',
|
|
|
|
'skin-minerva',
|
|
|
|
$config->get( 'MinervaShowCategories' )
|
|
|
|
)
|
|
|
|
);
|
2024-05-28 19:53:45 +00:00
|
|
|
$featuresManager->registerFeature(
|
2023-08-15 15:02:31 +00:00
|
|
|
new Feature(
|
|
|
|
'MinervaPageIssuesNewTreatment',
|
|
|
|
'skin-minerva',
|
|
|
|
$config->get( 'MinervaPageIssuesNewTreatment' )
|
|
|
|
)
|
|
|
|
);
|
2024-05-28 19:53:45 +00:00
|
|
|
$featuresManager->registerFeature(
|
2023-08-15 15:02:31 +00:00
|
|
|
new Feature(
|
|
|
|
'MinervaTalkAtTop',
|
|
|
|
'skin-minerva',
|
|
|
|
$config->get( 'MinervaTalkAtTop' )
|
|
|
|
)
|
|
|
|
);
|
2024-05-28 19:53:45 +00:00
|
|
|
$featuresManager->registerFeature(
|
2023-08-15 15:02:31 +00:00
|
|
|
new Feature(
|
|
|
|
'MinervaDonateLink',
|
|
|
|
'skin-minerva',
|
|
|
|
$config->get( 'MinervaDonateLink' )
|
|
|
|
)
|
|
|
|
);
|
2024-05-28 19:53:45 +00:00
|
|
|
$featuresManager->registerFeature(
|
2023-08-15 15:02:31 +00:00
|
|
|
new Feature(
|
|
|
|
'MinervaHistoryInPageActions',
|
|
|
|
'skin-minerva',
|
|
|
|
$config->get( 'MinervaHistoryInPageActions' )
|
|
|
|
)
|
|
|
|
);
|
2024-05-28 19:53:45 +00:00
|
|
|
$featuresManager->registerFeature(
|
2023-08-15 15:02:31 +00:00
|
|
|
new Feature(
|
|
|
|
Hooks::FEATURE_OVERFLOW_PAGE_ACTIONS,
|
|
|
|
'skin-minerva',
|
|
|
|
$config->get( Hooks::FEATURE_OVERFLOW_PAGE_ACTIONS )
|
|
|
|
)
|
|
|
|
);
|
2024-05-28 19:53:45 +00:00
|
|
|
$featuresManager->registerFeature(
|
2023-08-15 15:02:31 +00:00
|
|
|
new Feature(
|
|
|
|
'MinervaAdvancedMainMenu',
|
|
|
|
'skin-minerva',
|
|
|
|
$config->get( 'MinervaAdvancedMainMenu' )
|
|
|
|
)
|
|
|
|
);
|
2024-05-28 19:53:45 +00:00
|
|
|
$featuresManager->registerFeature(
|
2023-08-15 15:02:31 +00:00
|
|
|
new Feature(
|
|
|
|
'MinervaPersonalMenu',
|
|
|
|
'skin-minerva',
|
|
|
|
$config->get( 'MinervaPersonalMenu' )
|
|
|
|
)
|
|
|
|
);
|
2024-05-28 19:53:45 +00:00
|
|
|
$featuresManager->registerFeature(
|
2024-01-30 19:21:36 +00:00
|
|
|
new Feature(
|
|
|
|
'MinervaNightMode',
|
|
|
|
'skin-minerva',
|
|
|
|
$config->get( 'MinervaNightMode' )
|
|
|
|
)
|
|
|
|
);
|
2023-08-15 15:02:31 +00:00
|
|
|
} 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
|
|
|
|
) {
|
2024-03-12 19:35:14 +00:00
|
|
|
$this->skinOptions->setMinervaSkinOptions( $mobileContext, $skin );
|
2023-08-15 15:02:31 +00:00
|
|
|
}
|
|
|
|
}
|