mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/SyntaxHighlight_GeSHi
synced 2024-11-15 10:39:53 +00:00
b6d8b1a5b9
We want to be able to track what styles were added to be able to deliver this information to MediaWiki's live preview functionality (in order to solve bug 24134). This required moving some code in SyntaxHighlight_GeSHi class around. The old way still works and is used for MediaWiki 1.20 and lower. Bug: 24134 Change-Id: Iafd91de8922be55688fedef4e43a8e7f54d4e1cc
57 lines
1.3 KiB
PHP
57 lines
1.3 KiB
PHP
<?php
|
|
|
|
class ResourceLoaderGeSHiModule extends ResourceLoaderModule {
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
protected $lang;
|
|
|
|
/**
|
|
* @param array $info Module definition.
|
|
*/
|
|
function __construct( $info ) {
|
|
$this->lang = $info['lang'];
|
|
}
|
|
|
|
/**
|
|
* @param ResourceLoaderContext $context
|
|
* @return array
|
|
*/
|
|
public function getStyles( ResourceLoaderContext $context ) {
|
|
$geshi = SyntaxHighlight_GeSHi::prepare( '', $this->lang );
|
|
if ( !$geshi->error ) {
|
|
$css = SyntaxHighlight_GeSHi::getCSS( $geshi );
|
|
} else {
|
|
$css = ResourceLoader::makeComment( $geshi->error() );
|
|
}
|
|
|
|
return array( 'all' => $css );
|
|
}
|
|
|
|
/**
|
|
* @param ResourceLoaderContext $context
|
|
* @return int
|
|
*/
|
|
public function getModifiedTime( ResourceLoaderContext $context ) {
|
|
return max( array(
|
|
$this->getDefinitionMtime( $context ),
|
|
self::safeFilemtime( __FILE__ ),
|
|
self::safeFilemtime( __DIR__ . '/SyntaxHighlight_GeSHi.class.php' ),
|
|
self::safeFilemtime( __DIR__ . '/geshi/geshi.php' ),
|
|
self::safeFilemtime( GESHI_LANG_ROOT . "/{$this->lang}.php" ),
|
|
) );
|
|
}
|
|
|
|
/**
|
|
* @param $context ResourceLoaderContext
|
|
* @return array
|
|
*/
|
|
public function getDefinitionSummary( ResourceLoaderContext $context ) {
|
|
return array(
|
|
'class' => get_class( $this ),
|
|
'lang' => $this->lang,
|
|
);
|
|
}
|
|
}
|