r50693 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50692‎ | r50693 | r50694 >
Date:15:21, 17 May 2009
Author:soxred93
Status:resolved
Tags:
Comment:
Add optional $wgSyntaxHighlightDefaultLang parameter; allows people to set a default language that shows up if the lang parameter is missing.
Modified paths:
  • /trunk/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php (modified) (history)
  • /trunk/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php
@@ -50,6 +50,7 @@
5151 'url' => 'http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi',
5252 );
5353
 54+$wgSyntaxHighlightDefaultLang = null; //Change this in LocalSettings.php
5455 $dir = dirname(__FILE__) . '/';
5556 $wgExtensionMessagesFiles['SyntaxHighlight_GeSHi'] = $dir . 'SyntaxHighlight_GeSHi.i18n.php';
5657 $wgAutoloadClasses['SyntaxHighlight_GeSHi'] = $dir . 'SyntaxHighlight_GeSHi.class.php';
Index: trunk/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php
@@ -21,6 +21,7 @@
2222 * @return string
2323 */
2424 public static function parserHook( $text, $args = array(), $parser ) {
 25+ global $wgSyntaxHighlightDefaultLang;
2526 self::initialise();
2627 $text = rtrim( $text );
2728 // Don't trim leading spaces away, just the linefeeds
@@ -29,7 +30,12 @@
3031 if( isset( $args['lang'] ) ) {
3132 $lang = strtolower( $args['lang'] );
3233 } else {
33 - return self::formatError( htmlspecialchars( wfMsgForContent( 'syntaxhighlight-err-language' ) ) );
 34+ // language is not specified. Check if default exists, if yes, use it.
 35+ if ( !is_null($wgSyntaxHighlightDefaultLang) ) {
 36+ $lang = strtolower($wgSyntaxHighlightDefaultLang);
 37+ } else {
 38+ return self::formatError( htmlspecialchars( wfMsgForContent( 'syntaxhighlight-err-language' ) ) );
 39+ }
3440 }
3541 if( !preg_match( '/^[a-z_0-9-]*$/', $lang ) )
3642 return self::formatError( htmlspecialchars( wfMsgForContent( 'syntaxhighlight-err-language' ) ) );

Follow-up revisions

RevisionCommit summaryAuthorDate
r50751Follow-up to r50693 "Add optional $wgSyntaxHighlightDefaultLang parameter; al...brion20:28, 18 May 2009

Status & tagging log