| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
namespace MediaWiki\SyntaxHighlight; |
| 22 |
|
| 23 |
use MediaWiki\ResourceLoader as RL; |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
class ResourceLoaderPygmentsModule extends RL\FileModule { |
| 29 |
|
| 30 |
private bool $useBundled; |
| 31 |
|
| 32 |
|
| 33 |
public function __construct( |
| 34 |
array $options = [], |
| 35 |
$localBasePath = null, |
| 36 |
$remoteBasePath = null |
| 37 |
) { |
| 38 |
$this->useBundled = Pygmentize::useBundled(); |
| 39 |
if ( $this->useBundled ) { |
| 40 |
|
| 41 |
array_unshift( $options['styles'], 'pygments.generated.css' ); |
| 42 |
} |
| 43 |
parent::__construct( $options, $localBasePath, $remoteBasePath ); |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
public function supportsURLLoading() { |
| 52 |
return false; |
| 53 |
} |
| 54 |
|
| 55 |
|
| 56 |
public function getStyles( RL\Context $context ) { |
| 57 |
$styles = parent::getStyles( $context ); |
| 58 |
if ( !$this->useBundled ) { |
| 59 |
|
| 60 |
$styles['all'] = Pygmentize::getGeneratedCSS() . ( $styles['all'] ?? '' ); |
| 61 |
} |
| 62 |
|
| 63 |
return $styles; |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
public function getDefinitionSummary( RL\Context $context ) { |
| 68 |
$summary = parent::getDefinitionSummary( $context ); |
| 69 |
if ( !$this->useBundled ) { |
| 70 |
$summary[] = Pygmentize::getVersion(); |
| 71 |
} |
| 72 |
return $summary; |
| 73 |
} |
| 74 |
|
| 75 |
} |