self::getFrontendConfiguraton() ] ); } /** * Returns an array of variables for CodeMirror to work (tags and so on) * * @return array */ private static function getFrontendConfiguraton() { // Use the content language, not the user language. (See T170130.) $lang = MediaWikiServices::getInstance()->getContentLanguage(); $registry = ExtensionRegistry::getInstance(); $parser = MediaWikiServices::getInstance()->getParser(); $mwConfig = MediaWikiServices::getInstance()->getMainConfig(); $tagModes = $registry->getAttribute( 'CodeMirrorTagModes' ); $tagNames = array_merge( $parser->getTags(), array_keys( $tagModes ) ); // initialize configuration $config = [ 'useV6' => $mwConfig->get( 'CodeMirrorV6' ), 'lineNumberingNamespaces' => $mwConfig->get( 'CodeMirrorLineNumberingNamespaces' ), 'templateFoldingNamespaces' => $mwConfig->get( 'CodeMirrorTemplateFoldingNamespaces' ), 'pluginModules' => $registry->getAttribute( 'CodeMirrorPluginModules' ), 'tagModes' => $tagModes, 'tags' => array_fill_keys( $tagNames, true ), 'doubleUnderscore' => [ [], [] ], 'functionSynonyms' => $parser->getFunctionSynonyms(), 'urlProtocols' => $parser->getUrlProtocols(), 'linkTrailCharacters' => $lang->linkTrail(), ]; $mw = $lang->getMagicWords(); $magicWordFactory = $parser->getMagicWordFactory(); foreach ( $magicWordFactory->getDoubleUnderscoreArray()->getNames() 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 ( $magicWordFactory->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; } }