From 03bf6ce77958fcd844a128b417070c4f9a921740 Mon Sep 17 00:00:00 2001 From: vvv Date: Mon, 6 Feb 2012 22:14:47 +0000 Subject: [PATCH] Add integration with CodeEditor extension. --- Scripting.php | 9 +++++++-- common/Base.php | 9 ++++++++- common/Hooks.php | 13 +++++++++++++ engines/LuaSandbox/Engine.php | 4 ++++ 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/Scripting.php b/Scripting.php index ff18d656..07d5d2fc 100644 --- a/Scripting.php +++ b/Scripting.php @@ -52,6 +52,7 @@ $wgHooks['ParserTestTables'][] = 'ScriptingHooks::addTestTables'; $wgHooks['CanonicalNamespaces'][] = 'ScriptingHooks::addCanonicalNamespaces'; $wgHooks['ArticleViewCustom'][] = 'ScriptingHooks::handleScriptView'; $wgHooks['TitleIsWikitextPage'][] = 'ScriptingHooks::isWikitextPage'; +$wgHooks['CodeEditorGetPageLanguage'][] = 'ScriptingHooks::getCodeLangauge'; $wgHooks['EditFilter'][] = 'ScriptingHooks::validateScript'; $wgHooks['LinksUpdate'][] = 'ScriptLinksUpdateHooks::updateLinks'; @@ -90,11 +91,15 @@ $wgScriptingNamespaceNumbers = array( ); /** - * Turn on to true if you have linked or copied wikiscripts.php and - * SyntaxHighlight_GeSHi extension is enabled. + * Turn on to true if SyntaxHighlight_GeSHi extension is enabled. */ $wgScriptingUseGeSHi = false; +/** + * Turn on to true if CodeEditor extension is enabled. + */ +$wgScriptingUseCodeEditor = false; + function efDefineScriptingNamespace() { global $wgScriptingNamespaceNumbers; define( 'NS_MODULE', $wgScriptingNamespaceNumbers['Module'] ); diff --git a/common/Base.php b/common/Base.php index c59d1350..234e57fc 100644 --- a/common/Base.php +++ b/common/Base.php @@ -174,11 +174,18 @@ abstract class ScriptingEngineBase { } /** - * Get the language code for GeSHi syntax highlighter. + * Get the language for GeSHi syntax highlighter. */ function getGeSHiLangauge() { return false; } + + /** + * Get the langauge for Ace code editor. + */ + function getCodeEditorLanguage() { + return false; + } } /** diff --git a/common/Hooks.php b/common/Hooks.php index 2c596d84..e12706ed 100644 --- a/common/Hooks.php +++ b/common/Hooks.php @@ -160,6 +160,19 @@ class ScriptingHooks { return true; } } + + public static function getCodeLangauge( $title, &$lang ) { + global $wgParser, $wgScriptingUseCodeEditor; + if( $wgScriptingUseCodeEditor && $title->getNamespace() == NS_MODULE ) { + $engine = Scripting::getEngine( $wgParser ); + if( $engine->getCodeEditorLanguage() ) { + $lang = $engine->getCodeEditorLanguage(); + return false; + } + } + + return true; + } /** * Indicates that modules are not wikitext. diff --git a/engines/LuaSandbox/Engine.php b/engines/LuaSandbox/Engine.php index e7bcccb3..e39d2f3f 100644 --- a/engines/LuaSandbox/Engine.php +++ b/engines/LuaSandbox/Engine.php @@ -42,6 +42,10 @@ class LuaSandboxEngine extends ScriptingEngineBase { return 'lua'; } + public function getCodeEditorLanguage() { + return 'lua'; + } + public function getLimitsReport() { $this->load();