mediawiki-extensions-CodeMi.../CodeMirror.hooks.php
Pavel Astakhov b70b84a762 fix variables that was added with hook MagicWordwgVariableIDs (v 1.11.2)
Change-Id: Ic40e1e055e71585ed3e1706f356eafe7817f35a2
2014-09-04 09:37:11 +06:00

45 lines
1.2 KiB
PHP

<?php
class CodeMirrorHooks {
static $globalVariableScript = array();
/**
*
* @global Parser $wgParser
* @global Language $wgContLang
* @param EditPage $editPage
* @param OutputPage $output
* @return boolean
*/
public static function onEditPageShowEditFormInitial( EditPage $editPage, OutputPage $output ) {
global $wgParser, $wgContLang;
if ( false === isset( $wgParser->mFunctionSynonyms ) ) {
$wgParser->initialiseVariables();
$wgParser->firstCallInit();
}
self::$globalVariableScript['Tags'] = $wgParser->getTags();
$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;
}
}
}
$output->addModules( 'ext.CodeMirror' );
return true;
}
public static function onMakeGlobalVariablesScript( array &$vars ) {
foreach ( self::$globalVariableScript as $key=> $value ) {
$vars["extCodeMirror$key"] = $value;
}
}
}