2014-08-20 17:03:46 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
class CodeMirrorHooks {
|
|
|
|
|
2014-08-29 04:05:50 +00:00
|
|
|
static $globalVariableScript = array();
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @global Parser $wgParser
|
2014-09-04 03:37:11 +00:00
|
|
|
* @global Language $wgContLang
|
2014-08-29 04:05:50 +00:00
|
|
|
* @param EditPage $editPage
|
|
|
|
* @param OutputPage $output
|
|
|
|
* @return boolean
|
|
|
|
*/
|
2014-08-20 17:03:46 +00:00
|
|
|
public static function onEditPageShowEditFormInitial( EditPage $editPage, OutputPage $output ) {
|
2014-09-04 03:37:11 +00:00
|
|
|
global $wgParser, $wgContLang;
|
2014-08-29 04:05:50 +00:00
|
|
|
if ( false === isset( $wgParser->mFunctionSynonyms ) ) {
|
2014-09-04 03:37:11 +00:00
|
|
|
$wgParser->initialiseVariables();
|
2014-08-29 04:05:50 +00:00
|
|
|
$wgParser->firstCallInit();
|
|
|
|
}
|
2014-09-03 05:04:56 +00:00
|
|
|
self::$globalVariableScript['Tags'] = $wgParser->getTags();
|
2014-09-04 03:37:11 +00:00
|
|
|
|
|
|
|
$mw = $wgContLang->getMagicWords();
|
|
|
|
self::$globalVariableScript['FunctionSynonyms'] = $wgParser->mFunctionSynonyms;
|
|
|
|
foreach ( MagicWord::getVariableIDs() as $name ) {
|
|
|
|
if ( isset( $mw[$name] ) ) {
|
|
|
|
$caseSensitive = array_shift( $mw[$name] ) == 0 ? 0 : 1;
|
|
|
|
foreach ( $mw[$name] as $n ) {
|
|
|
|
self::$globalVariableScript['FunctionSynonyms'][$caseSensitive][ $caseSensitive ? $n : $wgContLang->lc( $n ) ] = $name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-20 17:03:46 +00:00
|
|
|
$output->addModules( 'ext.CodeMirror' );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-09-03 05:04:56 +00:00
|
|
|
public static function onMakeGlobalVariablesScript( array &$vars ) {
|
2014-08-29 04:05:50 +00:00
|
|
|
foreach ( self::$globalVariableScript as $key=> $value ) {
|
|
|
|
$vars["extCodeMirror$key"] = $value;
|
|
|
|
}
|
|
|
|
}
|
2014-08-20 17:03:46 +00:00
|
|
|
}
|