Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
ResourceLoaderGlobalSiteModule
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
2 / 2
7
100.00% covered (success)
100.00%
1 / 1
 getPages
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
1 / 1
6
 getGroup
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2/**
3 * ResourceLoader module for global site customizations.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @author Kunal Mehta
22 */
23
24namespace MediaWiki\GlobalCssJs;
25
26use MediaWiki\ResourceLoader\Context;
27
28/**
29 * Module for sitewide global customizations
30 */
31class ResourceLoaderGlobalSiteModule extends ResourceLoaderGlobalModule {
32
33    /** @inheritDoc */
34    protected $origin = self::ORIGIN_USER_SITEWIDE;
35
36    /**
37     * @param Context $context
38     * @return array
39     */
40    protected function getPages( Context $context ) {
41        $config = $this->getConfig();
42        if ( !$config->get( 'UseGlobalSiteCssJs' ) ) {
43            return [];
44        }
45
46        $pages = [];
47
48        if ( $this->type === 'style' && $config->get( 'UseSiteCss' ) ) {
49            $pages["MediaWiki:Global.css"] = [ 'type' => 'style' ];
50            $pages['MediaWiki:Global-' . $context->getSkin() . '.css'] = [ 'type' => 'style' ];
51        } elseif ( $this->type === 'script' && $config->get( 'UseSiteJs' ) ) {
52            $pages["MediaWiki:Global.js"] = [ 'type' => 'script' ];
53            $pages['MediaWiki:Global-' . $context->getSkin() . '.js'] = [ 'type' => 'script' ];
54        }
55
56        return $pages;
57    }
58
59    /**
60     * @return string
61     */
62    public function getGroup() {
63        return 'site';
64    }
65}