Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
CiteCSSFileModule
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
3
1<?php
2
3namespace Cite\ResourceLoader;
4
5use MediaWiki\MediaWikiServices;
6use MediaWiki\ResourceLoader\FileModule;
7
8/**
9 * ResourceLoader FileModule for adding the content language Cite CSS
10 *
11 * @copyright 2011-2018 VisualEditor Team's Cite sub-team and others; see AUTHORS.txt
12 * @license MIT
13 */
14class CiteCSSFileModule extends FileModule {
15
16    /**
17     * @inheritDoc
18     */
19    public function __construct(
20        array $options = [],
21        $localBasePath = null,
22        $remoteBasePath = null
23    ) {
24        $contLang = MediaWikiServices::getInstance()->getContentLanguage();
25        parent::__construct( $options, $localBasePath, $remoteBasePath );
26
27        // Get the content language code, and all the fallbacks. The first that
28        // has a ext.cite.style.<lang code>.css file present will be used.
29        foreach ( [ $contLang->getCode(), ...$contLang->getFallbackLanguages() ] as $lang ) {
30            $langStyleFile = 'ext.cite.style.' . strtr( $lang, '-', '_' ) . '.css';
31            if ( file_exists( $this->getLocalPath( $langStyleFile ) ) ) {
32                $this->styles[] = $langStyleFile;
33                break;
34            }
35        }
36    }
37
38}