Merge "Add page_restrictions to readlock in lockSearchindex"
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderSpecialCharacterDataModule.php
1 <?php
2 /**
3 * Resource loader module for populating special characters data for some
4 * editing extensions to use.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * http://www.gnu.org/copyleft/gpl.html
20 *
21 * @file
22 */
23
24 /**
25 * Resource loader module for populating special characters data for some
26 * editing extensions to use.
27 */
28 class ResourceLoaderSpecialCharacterDataModule extends ResourceLoaderModule {
29 private $path = "resources/src/mediawiki.language/specialcharacters.json";
30 protected $targets = array( 'desktop', 'mobile' );
31
32 /**
33 * Get all the dynamic data.
34 *
35 * @return array
36 */
37 protected function getData() {
38 return json_decode( file_get_contents( $this->path ) );
39 }
40
41 /**
42 * @param ResourceLoaderContext $context
43 * @return string JavaScript code
44 */
45 public function getScript( ResourceLoaderContext $context ) {
46 return Xml::encodeJsCall(
47 'mw.language.setSpecialCharacters',
48 array(
49 $this->getData()
50 ),
51 ResourceLoader::inDebugMode()
52 );
53 }
54
55 /**
56 * @param ResourceLoaderContext $context
57 * @return int UNIX timestamp
58 */
59 public function getModifiedTime( ResourceLoaderContext $context ) {
60 return static::safeFilemtime( $this->path );
61 }
62
63 /**
64 * @param ResourceLoaderContext $context
65 * @return string Hash
66 */
67 public function getModifiedHash( ResourceLoaderContext $context ) {
68 return md5( serialize( $this->getData() ) );
69 }
70
71 /**
72 * @return array
73 */
74 public function getDependencies() {
75 return array( 'mediawiki.language' );
76 }
77
78 /**
79 * @return array
80 */
81 public function getMessages() {
82 return array(
83 'special-characters-group-latin',
84 'special-characters-group-latinextended',
85 'special-characters-group-ipa',
86 'special-characters-group-symbols',
87 'special-characters-group-greek',
88 'special-characters-group-cyrillic',
89 'special-characters-group-arabic',
90 'special-characters-group-arabicextended',
91 'special-characters-group-persian',
92 'special-characters-group-hebrew',
93 'special-characters-group-bangla',
94 'special-characters-group-tamil',
95 'special-characters-group-telugu',
96 'special-characters-group-sinhala',
97 'special-characters-group-devanagari',
98 'special-characters-group-gujarati',
99 'special-characters-group-thai',
100 'special-characters-group-lao',
101 'special-characters-group-khmer',
102 'special-characters-title-endash',
103 'special-characters-title-emdash',
104 'special-characters-title-minus'
105 );
106 }
107 }