Merge "mw.htmlform: Fix hiding of the textbox for 'selectorother' fields on page...
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderJqueryMsgModule.php
index b905781..01476ed 100644 (file)
@@ -18,7 +18,6 @@
  * http://www.gnu.org/copyleft/gpl.html
  *
  * @file
- * @author Brad Jorsch
  */
 
 /**
@@ -34,7 +33,7 @@ class ResourceLoaderJqueryMsgModule extends ResourceLoaderFileModule {
                $fileScript = parent::getScript( $context );
 
                $tagData = Sanitizer::getRecognizedTagData();
-               $parserDefaults = array();
+               $parserDefaults = [];
                $parserDefaults['allowedHtmlElements'] = array_merge(
                        array_keys( $tagData['htmlpairs'] ),
                        array_diff(
@@ -43,20 +42,41 @@ class ResourceLoaderJqueryMsgModule extends ResourceLoaderFileModule {
                        )
                );
 
-               $dataScript = Xml::encodeJsCall( 'mw.jqueryMsg.setParserDefaults', array( $parserDefaults ) );
+               $mainDataScript = Xml::encodeJsCall( 'mw.jqueryMsg.setParserDefaults', [ $parserDefaults ] );
 
-               return $fileScript . $dataScript;
+               // Associative array mapping magic words (e.g. SITENAME)
+               // to their values.
+               $magicWords = [
+                       'SITENAME' => $this->getConfig()->get( 'Sitename' ),
+               ];
+
+               Hooks::run( 'ResourceLoaderJqueryMsgModuleMagicWords', [ $context, &$magicWords ] );
+
+               $magicWordExtendData = [
+                       'magic' => $magicWords,
+               ];
+
+               $magicWordDataScript = Xml::encodeJsCall( 'mw.jqueryMsg.setParserDefaults', [
+                       $magicWordExtendData,
+                       /* deep= */ true
+               ] );
+
+               return $fileScript . $mainDataScript . $magicWordDataScript;
        }
 
        /**
-        * @param ResourceLoaderContext $context
-        * @return array|null
+       * @param ResourceLoaderContext $context
+       * @return array
+       */
+       public function getScriptURLsForDebug( ResourceLoaderContext $context ) {
+               // Bypass file module urls
+               return ResourceLoaderModule::getScriptURLsForDebug( $context );
+       }
+
+       /**
+        * @return bool
         */
-       public function getDefinitionSummary( ResourceLoaderContext $context ) {
-               $summary = parent::getDefinitionSummary( $context );
-               $summary[] = array(
-                       'sanitizerData' => Sanitizer::getRecognizedTagData()
-               );
-               return $summary;
+       public function enableModuleContentVersion() {
+               return true;
        }
 }