|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @package Translator |
|
5
|
|
|
* @author Iurii Makukh <[email protected]> |
|
6
|
|
|
* @copyright Copyright (c) 2017, Iurii Makukh <[email protected]> |
|
7
|
|
|
* @license https://www.gnu.org/licenses/gpl-3.0.en.html GPL-3.0+ |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace gplcart\modules\translator; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Main class for Translator module |
|
14
|
|
|
*/ |
|
15
|
|
|
class Main |
|
16
|
|
|
{ |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Implements hook "module.install.before" |
|
20
|
|
|
* @param null|string $result |
|
21
|
|
|
*/ |
|
22
|
|
|
public function hookModuleInstallBefore(&$result) |
|
23
|
|
|
{ |
|
24
|
|
|
if (!class_exists('ZipArchive')) { |
|
25
|
|
|
$result = gplcart_text('Class ZipArchive does not exist'); |
|
26
|
|
|
} |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Implements hook "route.list" |
|
31
|
|
|
* @param array $routes |
|
32
|
|
|
*/ |
|
33
|
|
|
public function hookRouteList(array &$routes) |
|
34
|
|
|
{ |
|
35
|
|
|
$routes['admin/tool/translator'] = array( |
|
36
|
|
|
'menu' => array( |
|
37
|
|
|
'admin' => 'Translator' // @text |
|
38
|
|
|
), |
|
39
|
|
|
'access' => 'module_translator', |
|
40
|
|
|
'handlers' => array( |
|
41
|
|
|
'controller' => array('gplcart\\modules\\translator\\controllers\\Translator', 'languageTranslator') |
|
42
|
|
|
) |
|
43
|
|
|
); |
|
44
|
|
|
|
|
45
|
|
|
$routes['admin/tool/translator/(\w+)'] = array( |
|
46
|
|
|
'access' => 'module_translator', |
|
47
|
|
|
'handlers' => array( |
|
48
|
|
|
'controller' => array('gplcart\\modules\\translator\\controllers\\Translator', 'filesTranslator') |
|
49
|
|
|
) |
|
50
|
|
|
); |
|
51
|
|
|
|
|
52
|
|
|
$routes['admin/tool/translator/(\w+)/upload'] = array( |
|
53
|
|
|
'access' => 'module_translator_upload', |
|
54
|
|
|
'handlers' => array( |
|
55
|
|
|
'controller' => array('gplcart\\modules\\translator\\controllers\\Translator', 'uploadTranslator') |
|
56
|
|
|
) |
|
57
|
|
|
); |
|
58
|
|
|
|
|
59
|
|
|
$routes['admin/tool/translator/(\w+)/view/([^/]+)'] = array( |
|
60
|
|
|
'access' => 'module_translator', |
|
61
|
|
|
'handlers' => array( |
|
62
|
|
|
'controller' => array('gplcart\\modules\\translator\\controllers\\Translator', 'viewTranslator') |
|
63
|
|
|
) |
|
64
|
|
|
); |
|
65
|
|
|
|
|
66
|
|
|
$routes['admin/tool/translator/(\w+)/import'] = array( |
|
67
|
|
|
'access' => 'module_translator_import', |
|
68
|
|
|
'handlers' => array( |
|
69
|
|
|
'controller' => array('gplcart\\modules\\translator\\controllers\\Translator', 'listImportTranslator') |
|
70
|
|
|
) |
|
71
|
|
|
); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Implements hook "user.role.permissions" |
|
76
|
|
|
* @param array $permissions |
|
77
|
|
|
*/ |
|
78
|
|
|
public function hookUserRolePermissions(array &$permissions) |
|
79
|
|
|
{ |
|
80
|
|
|
$permissions['module_translator'] = 'Translator: access'; // @text |
|
81
|
|
|
$permissions['module_translator_upload'] = 'Translator: upload translations'; // @text |
|
82
|
|
|
$permissions['module_translator_delete'] = 'Translator: delete translations'; // @text |
|
83
|
|
|
$permissions['module_translator_import'] = 'Translator: import translations'; // @text |
|
84
|
|
|
$permissions['module_translator_download'] = 'Translator: download translations'; // @text |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
} |
|
88
|
|
|
|