mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/SyntaxHighlight_GeSHi
synced 2024-11-15 02:24:07 +00:00
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:
parent
32c8d4d479
commit
72521f6b30
|
@ -21,6 +21,7 @@ class SyntaxHighlight_GeSHi {
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function parserHook( $text, $args = array(), $parser ) {
|
public static function parserHook( $text, $args = array(), $parser ) {
|
||||||
|
global $wgSyntaxHighlightDefaultLang;
|
||||||
self::initialise();
|
self::initialise();
|
||||||
$text = rtrim( $text );
|
$text = rtrim( $text );
|
||||||
// Don't trim leading spaces away, just the linefeeds
|
// Don't trim leading spaces away, just the linefeeds
|
||||||
|
@ -29,7 +30,12 @@ class SyntaxHighlight_GeSHi {
|
||||||
if( isset( $args['lang'] ) ) {
|
if( isset( $args['lang'] ) ) {
|
||||||
$lang = strtolower( $args['lang'] );
|
$lang = strtolower( $args['lang'] );
|
||||||
} else {
|
} else {
|
||||||
return self::formatError( htmlspecialchars( wfMsgForContent( 'syntaxhighlight-err-language' ) ) );
|
// 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 ) )
|
if( !preg_match( '/^[a-z_0-9-]*$/', $lang ) )
|
||||||
return self::formatError( htmlspecialchars( wfMsgForContent( 'syntaxhighlight-err-language' ) ) );
|
return self::formatError( htmlspecialchars( wfMsgForContent( 'syntaxhighlight-err-language' ) ) );
|
||||||
|
|
|
@ -50,6 +50,7 @@ $wgExtensionCredits['parserhook']['SyntaxHighlight_GeSHi'] = array(
|
||||||
'url' => 'http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi',
|
'url' => 'http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$wgSyntaxHighlightDefaultLang = null; //Change this in LocalSettings.php
|
||||||
$dir = dirname(__FILE__) . '/';
|
$dir = dirname(__FILE__) . '/';
|
||||||
$wgExtensionMessagesFiles['SyntaxHighlight_GeSHi'] = $dir . 'SyntaxHighlight_GeSHi.i18n.php';
|
$wgExtensionMessagesFiles['SyntaxHighlight_GeSHi'] = $dir . 'SyntaxHighlight_GeSHi.i18n.php';
|
||||||
$wgAutoloadClasses['SyntaxHighlight_GeSHi'] = $dir . 'SyntaxHighlight_GeSHi.class.php';
|
$wgAutoloadClasses['SyntaxHighlight_GeSHi'] = $dir . 'SyntaxHighlight_GeSHi.class.php';
|
||||||
|
|
Loading…
Reference in a new issue