Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
80.00% |
4 / 5 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| BeforePageDisplayHookHandler | |
80.00% |
4 / 5 |
|
0.00% |
0 / 1 |
4.13 | |
0.00% |
0 / 1 |
| onBeforePageDisplay | |
80.00% |
4 / 5 |
|
0.00% |
0 / 1 |
4.13 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace WikimediaBadges; |
| 4 | |
| 5 | use MediaWiki\Output\Hook\BeforePageDisplayHook; |
| 6 | use MediaWiki\Registration\ExtensionRegistry; |
| 7 | use UniversalLanguageSelector\Hooks; |
| 8 | |
| 9 | /** |
| 10 | * Handler for the BeforePageDisplay hook. |
| 11 | * |
| 12 | * @since 0.1 |
| 13 | * |
| 14 | * @license GPL-2.0-or-later |
| 15 | * @author Bene* < benestar.wikimedia@gmail.com > |
| 16 | */ |
| 17 | class BeforePageDisplayHookHandler implements BeforePageDisplayHook { |
| 18 | |
| 19 | /** @inheritDoc */ |
| 20 | public function onBeforePageDisplay( $out, $skin ): void { |
| 21 | if ( $out->getProperty( 'wikibase_badges' ) ) { |
| 22 | // Always load the base styles: the v2 styles only apply once the |
| 23 | // JS-based ULS rewrite mounts, so this is the no-JS fallback. |
| 24 | $out->addModuleStyles( 'ext.wikimediaBadges' ); |
| 25 | |
| 26 | if ( |
| 27 | ExtensionRegistry::getInstance()->isLoaded( 'UniversalLanguageSelector' ) && |
| 28 | Hooks::isLanguageSelectorV2Enabled( $skin, $out->getConfig() ) |
| 29 | ) { |
| 30 | $out->addModuleStyles( 'ext.wikimediaBadges.ulsV2' ); |
| 31 | } |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | } |