Debian Codegraph @

extensions/Cite/src/ResourceLoader/CiteCSSFileModule.php

raw symbols SCIP
1 <?php
2
3 namespace Cite\ResourceLoader;
4
5 use MediaWiki\MediaWikiServices;
6 use 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 */
14 class 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.$lang.less";
31 if ( file_exists( $this->getLocalPath( $langStyleFile ) ) ) {
32 $this->styles[] = $langStyleFile;
33 break;
34 }
35 }
36 }
37
38 }