Index: trunk/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php |
— | — | @@ -54,14 +54,10 @@ |
55 | 55 | $wgAutoloadClasses['SyntaxHighlight_GeSHi'] = $dir . 'SyntaxHighlight_GeSHi.class.php'; |
56 | 56 | $wgHooks['ShowRawCssJs'][] = 'SyntaxHighlight_GeSHi::viewHook'; |
57 | 57 | $wgHooks['ParserFirstCallInit'][] = 'efSyntaxHighlight_GeSHiSetup'; |
| 58 | +$wgHooks['ExtensionTypes'][] = 'SyntaxHighlight_GeSHi::hSpecialVersion_GeSHi'; |
58 | 59 | |
59 | | -if ( version_compare( $wgVersion, '1.17alpha', '>=' ) ) { |
60 | | - // For MediaWiki 1.17 alpha and later. |
61 | | - $wgHooks['ExtensionTypes'][] = 'SyntaxHighlight_GeSHi::hSpecialVersion_GeSHi'; |
62 | | -} else { |
63 | | - // For pre-MediaWiki 1.17 alpha. |
64 | | - $wgHooks['SpecialVersionExtensionTypes'][] = 'SyntaxHighlight_GeSHi::hOldSpecialVersion_GeSHi'; |
65 | | -} |
| 60 | +$wgAutoloadClasses['HighlightGeSHilocal'] = $dir . 'SyntaxHighlight_GeSHi.local.php'; |
| 61 | +$wgResourceModules['ext.geshi.local'] = array( 'class' => 'HighlightGeSHilocal' ); |
66 | 62 | |
67 | 63 | /** |
68 | 64 | * Register parser hook |
Index: trunk/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php |
— | — | @@ -21,7 +21,7 @@ |
22 | 22 | * @return string |
23 | 23 | */ |
24 | 24 | public static function parserHook( $text, $args = array(), $parser ) { |
25 | | - global $wgSyntaxHighlightDefaultLang, $wgUseTidy; |
| 25 | + global $wgSyntaxHighlightDefaultLang, $wgUseSiteCss, $wgUseTidy; |
26 | 26 | wfProfileIn( __METHOD__ ); |
27 | 27 | self::initialise(); |
28 | 28 | $text = rtrim( $text ); |
— | — | @@ -103,6 +103,10 @@ |
104 | 104 | // Register CSS |
105 | 105 | $parser->mOutput->addHeadItem( self::buildHeadItem( $geshi ), "source-{$lang}" ); |
106 | 106 | |
| 107 | + if( $wgUseSiteCss ) { |
| 108 | + $parser->mOutput->addModuleStyles( 'ext.geshi.local' ); |
| 109 | + } |
| 110 | + |
107 | 111 | $encloseTag = $enclose === GESHI_HEADER_NONE ? 'span' : 'div'; |
108 | 112 | $attribs = Sanitizer::validateTagAttributes( $args, $encloseTag ); |
109 | 113 | |
— | — | @@ -220,6 +224,7 @@ |
221 | 225 | * @return bool |
222 | 226 | */ |
223 | 227 | public static function viewHook( $text, $title, $output ) { |
| 228 | + global $wgUseSiteCss; |
224 | 229 | // Determine the language |
225 | 230 | $matches = array(); |
226 | 231 | preg_match( '!\.(css|js)$!u', $title->getText(), $matches ); |
— | — | @@ -232,6 +237,9 @@ |
233 | 238 | // Done |
234 | 239 | $output->addHeadItem( "source-$lang", self::buildHeadItem( $geshi ) ); |
235 | 240 | $output->addHTML( "<div dir=\"ltr\">{$out}</div>" ); |
| 241 | + if( $wgUseSiteCss ) { |
| 242 | + $output->addModuleStyles( 'ext.geshi.local' ); |
| 243 | + } |
236 | 244 | return false; |
237 | 245 | } |
238 | 246 | } |
— | — | @@ -279,14 +287,6 @@ |
280 | 288 | $css[] = $geshi->get_stylesheet( false ); |
281 | 289 | $css[] = '/*]]>*/'; |
282 | 290 | $css[] = '</style>'; |
283 | | - if( $wgUseSiteCss ) { |
284 | | - $title = Title::makeTitle( NS_MEDIAWIKI, 'Geshi.css' ); |
285 | | - $q = "usemsgcache=yes&action=raw&ctype=text/css&smaxage={$wgSquidMaxage}"; |
286 | | - $css[] = '<style type="text/css">/*<![CDATA[*/'; |
287 | | - $css[] = '@import "' . $title->getLocalUrl( $q ) . '";'; |
288 | | - $css[] = '/*]]>*/'; |
289 | | - $css[] = '</style>'; |
290 | | - } |
291 | 291 | return implode( "\n", $css ); |
292 | 292 | } |
293 | 293 | |