Merge "Fix typo and improve code comments in LinkTarget"
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderSpecialCharacterDataModule.php
index 5c91709..222135c 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * Resource loader module for populating special characters data for some
+ * ResourceLoader module for populating special characters data for some
  * editing extensions to use.
  *
  * This program is free software; you can redistribute it and/or modify
  */
 
 /**
- * Resource loader module for populating special characters data for some
+ * ResourceLoader module for populating special characters data for some
  * editing extensions to use.
  */
 class ResourceLoaderSpecialCharacterDataModule extends ResourceLoaderModule {
        private $path = "resources/src/mediawiki.language/specialcharacters.json";
-       protected $targets = array( 'desktop', 'mobile' );
+       protected $targets = [ 'desktop', 'mobile' ];
 
        /**
         * Get all the dynamic data.
@@ -35,7 +35,8 @@ class ResourceLoaderSpecialCharacterDataModule extends ResourceLoaderModule {
         * @return array
         */
        protected function getData() {
-               return json_decode( file_get_contents( $this->path ) );
+               global $IP;
+               return json_decode( file_get_contents( "$IP/{$this->path}" ) );
        }
 
        /**
@@ -45,41 +46,33 @@ class ResourceLoaderSpecialCharacterDataModule extends ResourceLoaderModule {
        public function getScript( ResourceLoaderContext $context ) {
                return Xml::encodeJsCall(
                        'mw.language.setSpecialCharacters',
-                       array(
+                       [
                                $this->getData()
-                       ),
+                       ],
                        ResourceLoader::inDebugMode()
                );
        }
 
        /**
-        * @param ResourceLoaderContext $context
-        * @return int UNIX timestamp
+        * @return bool
         */
-       public function getModifiedTime( ResourceLoaderContext $context ) {
-               return static::safeFilemtime( $this->path );
+       public function enableModuleContentVersion() {
+               return true;
        }
 
        /**
         * @param ResourceLoaderContext $context
-        * @return string Hash
-        */
-       public function getModifiedHash( ResourceLoaderContext $context ) {
-               return md5( serialize( $this->getData() ) );
-       }
-
-       /**
         * @return array
         */
-       public function getDependencies() {
-               return array( 'mediawiki.language' );
+       public function getDependencies( ResourceLoaderContext $context = null ) {
+               return [ 'mediawiki.language' ];
        }
 
        /**
         * @return array
         */
        public function getMessages() {
-               return array(
+               return [
                        'special-characters-group-latin',
                        'special-characters-group-latinextended',
                        'special-characters-group-ipa',
@@ -102,6 +95,6 @@ class ResourceLoaderSpecialCharacterDataModule extends ResourceLoaderModule {
                        'special-characters-title-endash',
                        'special-characters-title-emdash',
                        'special-characters-title-minus'
-               );
+               ];
        }
 }