Add integration with CodeEditor extension.

This commit is contained in:
vvv 2012-02-06 22:14:47 +00:00
parent eb6f95b6ce
commit 03bf6ce779
4 changed files with 32 additions and 3 deletions

View file

@ -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'] );

View file

@ -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;
}
}
/**

View file

@ -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.

View file

@ -42,6 +42,10 @@ class LuaSandboxEngine extends ScriptingEngineBase {
return 'lua';
}
public function getCodeEditorLanguage() {
return 'lua';
}
public function getLimitsReport() {
$this->load();