Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 9 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
Hooks | |
0.00% |
0 / 9 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
onBeforePageDisplay | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |||
onResourceLoaderGetConfigVars | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | /** |
3 | * This program is free software; you can redistribute it and/or modify |
4 | * it under the terms of the GNU General Public License as published by |
5 | * the Free Software Foundation; either version 2 of the License, or |
6 | * (at your option) any later version. |
7 | * |
8 | * This program is distributed in the hope that it will be useful, |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * GNU General Public License for more details. |
12 | * |
13 | * You should have received a copy of the GNU General Public License along |
14 | * with this program; if not, write to the Free Software Foundation, Inc., |
15 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
16 | * |
17 | * @file |
18 | */ |
19 | |
20 | namespace MediaWiki\Extension\ExternalGuidance; |
21 | |
22 | use MediaWiki\Config\Config; |
23 | use MediaWiki\Output\Hook\BeforePageDisplayHook; |
24 | use MediaWiki\Output\OutputPage; |
25 | use MediaWiki\ResourceLoader\Hook\ResourceLoaderGetConfigVarsHook; |
26 | use Skin; |
27 | |
28 | /** |
29 | * Hooks for ExternalGuidance extension |
30 | */ |
31 | class Hooks implements |
32 | BeforePageDisplayHook, |
33 | ResourceLoaderGetConfigVarsHook |
34 | { |
35 | /** |
36 | * @param OutputPage $out |
37 | * @param Skin $skin |
38 | */ |
39 | public function onBeforePageDisplay( $out, $skin ): void { |
40 | global $wgExternalGuidanceEnableContextDetection; |
41 | |
42 | if ( $wgExternalGuidanceEnableContextDetection === true && |
43 | $skin->getSkinName() === 'minerva' |
44 | ) { |
45 | $out->addModules( 'mw.externalguidance.init' ); |
46 | } |
47 | } |
48 | |
49 | /** |
50 | * @param array &$vars |
51 | * @param string $skin |
52 | * @param Config $config |
53 | */ |
54 | public function onResourceLoaderGetConfigVars( array &$vars, $skin, Config $config ): void { |
55 | global $wgExternalGuidanceMTReferrers, $wgExternalGuidanceSiteTemplates, |
56 | $wgExternalGuidanceDomainCodeMapping; |
57 | $vars['wgExternalGuidanceMTReferrers'] = $wgExternalGuidanceMTReferrers; |
58 | $vars['wgExternalGuidanceSiteTemplates'] = $wgExternalGuidanceSiteTemplates; |
59 | $vars['wgExternalGuidanceDomainCodeMapping'] = $wgExternalGuidanceDomainCodeMapping; |
60 | } |
61 | |
62 | } |