Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| Hooks | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
4 | |
100.00% |
1 / 1 |
| onBeforePageDisplay | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
4 | |||
| 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\IncidentReporting; |
| 21 | |
| 22 | use MediaWiki\Hook\BeforePageDisplayHook; |
| 23 | use OutputPage; |
| 24 | use Skin; |
| 25 | |
| 26 | class Hooks implements BeforePageDisplayHook { |
| 27 | |
| 28 | /** |
| 29 | * @param OutputPage $out |
| 30 | * @param Skin $skin |
| 31 | * Hook: BeforePageDisplay |
| 32 | */ |
| 33 | public function onBeforePageDisplay( $out, $skin ): void { |
| 34 | /** If IncidentReporting is not enabled do nothing. */ |
| 35 | if ( !$out->getConfig()->get( 'IncidentReportingReportButtonEnabled' ) ) { |
| 36 | return; |
| 37 | } |
| 38 | |
| 39 | /** If IncidentReporting is enabled check we are in correct namespace and skin then add modules */ |
| 40 | if ( in_array( $out->getTitle()->getNamespace(), |
| 41 | $out->getConfig()->get( 'IncidentReportingEnabledNamespaces' ) ) && |
| 42 | in_array( $skin->getSkinName(), $out->getConfig()->get( 'IncidentReportingEnabledSkins' ) ) ) { |
| 43 | $out->addModules( [ 'ext.incidentReporting' ] ); |
| 44 | $out->addHtml( '<div id="ext-incidentreporting-app"></div>' ); |
| 45 | } |
| 46 | } |
| 47 | } |