Index: trunk/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php |
— | — | @@ -36,8 +36,9 @@ |
37 | 37 | * some help text and a list of all supported languages. |
38 | 38 | */ |
39 | 39 | |
40 | | -if( !defined( 'MEDIAWIKI' ) ) |
| 40 | +if( !defined( 'MEDIAWIKI' ) ) { |
41 | 41 | die(); |
| 42 | +} |
42 | 43 | |
43 | 44 | $wgExtensionCredits['parserhook']['SyntaxHighlight_GeSHi'] = array( |
44 | 45 | 'path' => __FILE__, |
— | — | @@ -57,8 +58,7 @@ |
58 | 59 | if ( version_compare( $wgVersion, '1.17alpha', '>=' ) ) { |
59 | 60 | // For MediaWiki 1.17 alpha and later. |
60 | 61 | $wgHooks['ExtensionTypes'][] = 'SyntaxHighlight_GeSHi::hSpecialVersion_GeSHi'; |
61 | | -} |
62 | | -else { |
| 62 | +} else { |
63 | 63 | // For pre-MediaWiki 1.17 alpha. |
64 | 64 | $wgHooks['SpecialVersionExtensionTypes'][] = 'SyntaxHighlight_GeSHi::hOldSpecialVersion_GeSHi'; |
65 | 65 | } |
Index: trunk/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php |
— | — | @@ -62,15 +62,19 @@ |
63 | 63 | // Highlighting specific lines |
64 | 64 | if( isset( $args['highlight'] ) ) { |
65 | 65 | $lines = self::parseHighlightLines( $args['highlight'] ); |
66 | | - if ( count($lines) ) $geshi->highlight_lines_extra( $lines ); |
| 66 | + if ( count($lines) ) { |
| 67 | + $geshi->highlight_lines_extra( $lines ); |
| 68 | + } |
67 | 69 | } |
68 | 70 | // Starting line number |
69 | | - if( isset( $args['start'] ) ) |
| 71 | + if( isset( $args['start'] ) ) { |
70 | 72 | $geshi->start_line_numbers_at( $args['start'] ); |
| 73 | + } |
71 | 74 | $geshi->set_header_type( $enclose ); |
72 | 75 | // Strict mode |
73 | | - if( isset( $args['strict'] ) ) |
| 76 | + if( isset( $args['strict'] ) ) { |
74 | 77 | $geshi->enable_strict_mode(); |
| 78 | + } |
75 | 79 | // Format |
76 | 80 | $out = $geshi->parse_code(); |
77 | 81 | $err = $geshi->error(); |
— | — | @@ -93,7 +97,7 @@ |
94 | 98 | wfProfileOut( __METHOD__ ); |
95 | 99 | return $out; |
96 | 100 | } |
97 | | - |
| 101 | + |
98 | 102 | /** |
99 | 103 | * Take an input specifying a list of lines to highlight, returning |
100 | 104 | * a raw list of matching line numbers. |
— | — | @@ -124,7 +128,7 @@ |
125 | 129 | } |
126 | 130 | return $lines; |
127 | 131 | } |
128 | | - |
| 132 | + |
129 | 133 | /** |
130 | 134 | * Validate a provided input range |
131 | 135 | */ |
— | — | @@ -209,8 +213,9 @@ |
210 | 214 | private static function prepare( $text, $lang ) { |
211 | 215 | self::initialise(); |
212 | 216 | $geshi = new GeSHi( $text, $lang ); |
213 | | - if( $geshi->error() == GESHI_ERROR_NO_SUCH_LANG ) |
| 217 | + if( $geshi->error() == GESHI_ERROR_NO_SUCH_LANG ) { |
214 | 218 | return null; |
| 219 | + } |
215 | 220 | $geshi->set_encoding( 'UTF-8' ); |
216 | 221 | $geshi->enable_classes(); |
217 | 222 | $geshi->set_overall_class( "source-$lang" ); |
— | — | @@ -255,8 +260,9 @@ |
256 | 261 | */ |
257 | 262 | private static function formatError( $error = '' ) { |
258 | 263 | $html = ''; |
259 | | - if( $error ) |
| 264 | + if( $error ) { |
260 | 265 | $html .= "<p>{$error}</p>"; |
| 266 | + } |
261 | 267 | $html .= '<p>' . htmlspecialchars( wfMsgForContent( 'syntaxhighlight-specify' ) ) |
262 | 268 | . ' <samp><source lang="html4strict">...</source></samp></p>' |
263 | 269 | . '<p>' . htmlspecialchars( wfMsgForContent( 'syntaxhighlight-supported' ) ) . '</p>' |
— | — | @@ -305,8 +311,9 @@ |
306 | 312 | private static function initialise() { |
307 | 313 | if( !self::$initialised ) { |
308 | 314 | wfLoadExtensionMessages( 'SyntaxHighlight_GeSHi' ); |
309 | | - if( !class_exists( 'GeSHi' ) ) |
| 315 | + if( !class_exists( 'GeSHi' ) ) { |
310 | 316 | require( 'geshi/geshi.php' ); |
| 317 | + } |
311 | 318 | self::$initialised = true; |
312 | 319 | } |
313 | 320 | return true; |
— | — | @@ -321,12 +328,12 @@ |
322 | 329 | $wgExtensionCredits['parserhook']['SyntaxHighlight_GeSHi']['version'] = GESHI_VERSION; |
323 | 330 | return true; |
324 | 331 | } |
325 | | - |
| 332 | + |
326 | 333 | /** |
327 | 334 | * @see SyntaxHighlight_GeSHi::hSpecialVersion_GeSHi |
328 | 335 | */ |
329 | 336 | public static function hOldSpecialVersion_GeSHi( &$sp, &$extensionTypes ) { |
330 | 337 | return self::hSpecialVersion_GeSHi( $extensionTypes ); |
331 | | - } |
| 338 | + } |
332 | 339 | |
333 | 340 | } |
\ No newline at end of file |