Add optional $wgSyntaxHighlightDefaultLang parameter; allows people to set a default language that shows up if the lang parameter is missing.

This commit is contained in:
X! 2009-05-17 15:21:37 +00:00
parent 32c8d4d479
commit 72521f6b30
2 changed files with 8 additions and 1 deletions

View file

@ -21,6 +21,7 @@ class SyntaxHighlight_GeSHi {
* @return string
*/
public static function parserHook( $text, $args = array(), $parser ) {
global $wgSyntaxHighlightDefaultLang;
self::initialise();
$text = rtrim( $text );
// Don't trim leading spaces away, just the linefeeds
@ -28,8 +29,13 @@ class SyntaxHighlight_GeSHi {
// Validate language
if( isset( $args['lang'] ) ) {
$lang = strtolower( $args['lang'] );
} else {
// language is not specified. Check if default exists, if yes, use it.
if ( !is_null($wgSyntaxHighlightDefaultLang) ) {
$lang = strtolower($wgSyntaxHighlightDefaultLang);
} else {
return self::formatError( htmlspecialchars( wfMsgForContent( 'syntaxhighlight-err-language' ) ) );
}
}
if( !preg_match( '/^[a-z_0-9-]*$/', $lang ) )
return self::formatError( htmlspecialchars( wfMsgForContent( 'syntaxhighlight-err-language' ) ) );

View file

@ -50,6 +50,7 @@ $wgExtensionCredits['parserhook']['SyntaxHighlight_GeSHi'] = array(
'url' => 'http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi',
);
$wgSyntaxHighlightDefaultLang = null; //Change this in LocalSettings.php
$dir = dirname(__FILE__) . '/';
$wgExtensionMessagesFiles['SyntaxHighlight_GeSHi'] = $dir . 'SyntaxHighlight_GeSHi.i18n.php';
$wgAutoloadClasses['SyntaxHighlight_GeSHi'] = $dir . 'SyntaxHighlight_GeSHi.class.php';