$this->getFrontendConfiguraton() ] ) . "\n" . parent::getScript( $context ); } /** * @inheritdoc */ public function supportsURLLoading() { // This module does not support loading URLs, because it inserts // JS config vars into the module by the getScript function. return false; } /** * @inheritdoc */ public function enableModuleContentVersion() { return true; } /** * Returns an array of variables for CodeMirror to work (tags and so on) * * @global Parser $wgParser * @global Language $wgContLang * @return array */ private function getFrontendConfiguraton() { global $wgParser, $wgContLang; // Use the content language, not the user language. (See T170130.) $lang = $wgContLang; $registry = ExtensionRegistry::getInstance(); if ( !isset( $wgParser->mFunctionSynonyms ) ) { $wgParser->initialiseVariables(); $wgParser->firstCallInit(); } // initialize configuration $config = [ 'pluginModules' => $registry->getAttribute( 'CodeMirrorPluginModules' ), 'tagModes' => $registry->getAttribute( 'CodeMirrorTagModes' ), 'tags' => array_fill_keys( $wgParser->getTags(), true ), 'doubleUnderscore' => [ [], [] ], 'functionSynonyms' => $wgParser->mFunctionSynonyms, 'urlProtocols' => $wgParser->mUrlProtocols, 'linkTrailCharacters' => $lang->linkTrail(), ]; $mw = $lang->getMagicWords(); foreach ( MagicWord::getDoubleUnderscoreArray()->names as $name ) { if ( isset( $mw[$name] ) ) { $caseSensitive = array_shift( $mw[$name] ) == 0 ? 0 : 1; foreach ( $mw[$name] as $n ) { $n = $caseSensitive ? $n : $lang->lc( $n ); $config['doubleUnderscore'][$caseSensitive][$n] = $name; } } else { $config['doubleUnderscore'][0][] = $name; } } foreach ( MagicWord::getVariableIDs() as $name ) { if ( isset( $mw[$name] ) ) { $caseSensitive = array_shift( $mw[$name] ) == 0 ? 0 : 1; foreach ( $mw[$name] as $n ) { $n = $caseSensitive ? $n : $lang->lc( $n ); $config['functionSynonyms'][$caseSensitive][$n] = $name; } } } return $config; } }