Merge "Added a separate error message for mkdir failures"
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderSpecialCharacterDataModule.php
1 <?php
2 /**
3 * ResourceLoader 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 * ResourceLoader 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 = [ 'desktop', 'mobile' ];
31
32 /**
33 * Get all the dynamic data.
34 *
35 * @return array
36 */
37 protected function getData() {
38 global $IP;
39 return json_decode( file_get_contents( "$IP/{$this->path}" ) );
40 }
41
42 /**
43 * @param ResourceLoaderContext $context
44 * @return string JavaScript code
45 */
46 public function getScript( ResourceLoaderContext $context ) {
47 return Xml::encodeJsCall(
48 'mw.language.setSpecialCharacters',
49 [
50 $this->getData()
51 ],
52 ResourceLoader::inDebugMode()
53 );
54 }
55
56 /**
57 * @return bool
58 */
59 public function enableModuleContentVersion() {
60 return true;
61 }
62
63 /**
64 * @param ResourceLoaderContext $context
65 * @return array
66 */
67 public function getDependencies( ResourceLoaderContext $context = null ) {
68 return [ 'mediawiki.language' ];
69 }
70
71 /**
72 * @return array
73 */
74 public function getMessages() {
75 return [
76 'special-characters-group-latin',
77 'special-characters-group-latinextended',
78 'special-characters-group-ipa',
79 'special-characters-group-symbols',
80 'special-characters-group-greek',
81 'special-characters-group-greekextended',
82 'special-characters-group-cyrillic',
83 'special-characters-group-arabic',
84 'special-characters-group-arabicextended',
85 'special-characters-group-persian',
86 'special-characters-group-hebrew',
87 'special-characters-group-bangla',
88 'special-characters-group-tamil',
89 'special-characters-group-telugu',
90 'special-characters-group-sinhala',
91 'special-characters-group-devanagari',
92 'special-characters-group-gujarati',
93 'special-characters-group-thai',
94 'special-characters-group-lao',
95 'special-characters-group-khmer',
96 'special-characters-group-canadianaboriginal',
97 'special-characters-title-endash',
98 'special-characters-title-emdash',
99 'special-characters-title-minus'
100 ];
101 }
102 }