forked from CMTV/XF2A-Code
-
Notifications
You must be signed in to change notification settings - Fork 2
/
EventsListener.php
41 lines (33 loc) · 1.02 KB
/
EventsListener.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
/**
* Code xF2 addon by CMTV
* Enjoy!
*/
namespace CMTV\Code;
use XF\Util\Arr;
class EventsListener
{
public static function commonLanguages(array &$data, \XF\Mvc\Controller $controller)
{
$commonLanguages = Arr::stringToArray(\XF::options()->CMTV_Code_commonLanguages, '/\r?\n/');
foreach ($commonLanguages as $key => $commonLanguage)
{
if (!array_key_exists($commonLanguage, $data['params']['languages']))
{
unset($commonLanguages[$key]);
}
}
$data['params']['commonLanguages'] = $commonLanguages;
}
public static function codeLanguages(array &$languages)
{
$langOptions = json_decode(\XF::options()->CMTV_Code_langOptions, true);
if ($langOptions === null)
return;
foreach ($langOptions as $lang => $options)
{
if ($languages[$lang] === null) continue;
$languages[$lang] = array_merge_recursive($languages[$lang], $options);
}
}
}