2015-04-29 16:07:09 +00:00
|
|
|
<?php
|
2017-12-28 14:55:49 +00:00
|
|
|
|
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-04-20 16:08:44 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
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
|
|
|
|
) {
|
|
|
|
global $wgContLang;
|
|
|
|
|
|
|
|
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.
|
2016-05-09 23:36:49 +00:00
|
|
|
$langCodes = array_merge( [ $wgContLang->getCode() ],
|
2015-04-29 16:07:09 +00:00
|
|
|
$wgContLang->getFallbackLanguages() );
|
|
|
|
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
|
|
|
}
|