From d7b87ac836b23230957cda8be551cca40c5574e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Dziewo=C5=84ski?= Date: Sat, 10 May 2014 23:28:07 +0200 Subject: [PATCH] Use ContentGetParserOutput hook instead of ShowRawCssJs Depends on I58679856 in core MediaWiki. This breaks compatibility with MW < 1.24. Bug: 64859 Change-Id: Idf4ad4397101a4d19be2ac773cd4bad52188d903 --- SyntaxHighlight_GeSHi.class.php | 40 ++++----------------------------- SyntaxHighlight_GeSHi.php | 9 +------- 2 files changed, 5 insertions(+), 44 deletions(-) diff --git a/SyntaxHighlight_GeSHi.class.php b/SyntaxHighlight_GeSHi.class.php index 4c31fbe0..e816492f 100644 --- a/SyntaxHighlight_GeSHi.class.php +++ b/SyntaxHighlight_GeSHi.class.php @@ -229,41 +229,6 @@ class SyntaxHighlight_GeSHi { return $enclose; } - /** - * Hook into Article::view() to provide syntax highlighting for - * custom CSS and JavaScript pages. - * - * B/C for MW 1.20 and before. 1.21 and later use renderHook() instead. - * - * @param string $text - * @param Title $title - * @param OutputPage $output - * @return bool - */ - public static function viewHook( $text, $title, $output ) { - global $wgUseSiteCss; - // Determine the language - $matches = array(); - preg_match( '!\.(css|js)$!u', $title->getText(), $matches ); - $lang = isset( $matches[1] ) && $matches[1] == 'css' ? 'css' : 'javascript'; - // Attempt to format - $geshi = self::prepare( $text, $lang ); - if( $geshi instanceof GeSHi ) { - $out = $geshi->parse_code(); - if( !$geshi->error() ) { - // Done - $output->addHeadItem( "source-$lang", self::buildHeadItem( $geshi ) ); - $output->addHTML( "
{$out}
" ); - if( $wgUseSiteCss ) { - $output->addModuleStyles( 'ext.geshi.local' ); - } - return false; - } - } - // Bottle out - return true; - } - /** * Hook into Content::getParserOutput to provide syntax highlighting for * script content. @@ -272,7 +237,7 @@ class SyntaxHighlight_GeSHi { * @since MW 1.21 */ public static function renderHook( Content $content, Title $title, - ParserOptions $options, $generateHtml, ParserOutput &$output + $revId, ParserOptions $options, $generateHtml, ParserOutput &$output ) { global $wgSyntaxHighlightModels, $wgUseSiteCss; @@ -382,11 +347,14 @@ class SyntaxHighlight_GeSHi { * Prepare a CSS snippet suitable for use as a ParserOutput/OutputPage * head item. * + * Not used anymore, kept for backwards-compatibility with other extensions. + * * @deprecated * @param GeSHi $geshi * @return string */ public static function buildHeadItem( $geshi ) { + wfDeprecated( __METHOD__ ); $css = array(); $css[] = '