2015-04-29 16:07:09 +00:00
|
|
|
<?php
|
2017-12-28 14:55:49 +00:00
|
|
|
|
2019-09-02 18:53:09 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
|
2015-04-29 16:07:09 +00:00
|
|
|
/**
|
|
|
|
* ResourceLoaderFileModule for adding the content language Cite CSS
|
|
|
|
*
|
2018-01-03 01:05:45 +00:00
|
|
|
* @copyright 2011-2018 VisualEditor Team's Cite sub-team and others; see AUTHORS.txt
|
2017-12-29 12:12:35 +00:00
|
|
|
* @license MIT
|
2015-04-29 16:07:09 +00:00
|
|
|
*/
|
|
|
|
class CiteCSSFileModule extends ResourceLoaderFileModule {
|
2017-12-28 14:55:49 +00:00
|
|
|
|
2015-04-29 16:07:09 +00:00
|
|
|
public function __construct(
|
2016-05-09 23:36:49 +00:00
|
|
|
$options = [],
|
2015-04-29 16:07:09 +00:00
|
|
|
$localBasePath = null,
|
|
|
|
$remoteBasePath = null
|
|
|
|
) {
|
2019-09-02 18:53:09 +00:00
|
|
|
$contLang = MediaWikiServices::getInstance()->getContentLanguage();
|
2015-04-29 16:07:09 +00:00
|
|
|
parent::__construct( $options, $localBasePath, $remoteBasePath );
|
|
|
|
|
|
|
|
// Get the content language code, and all the fallbacks. The first that
|
|
|
|
// has a ext.cite.style.<lang code>.css file present will be used.
|
2019-09-02 18:53:09 +00:00
|
|
|
$langCodes = array_merge(
|
|
|
|
[ $contLang->getCode() ],
|
|
|
|
$contLang->getFallbackLanguages()
|
|
|
|
);
|
2015-04-29 16:07:09 +00:00
|
|
|
foreach ( $langCodes as $lang ) {
|
|
|
|
$langStyleFile = 'ext.cite.style.' . $lang . '.css';
|
|
|
|
$localPath = $this->getLocalPath( $langStyleFile );
|
|
|
|
if ( file_exists( $localPath ) ) {
|
|
|
|
$this->styles[] = $langStyleFile;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-12-28 14:55:49 +00:00
|
|
|
|
2015-04-29 16:07:09 +00:00
|
|
|
}
|