1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @package Installer |
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\installer; |
11
|
|
|
|
12
|
|
|
use gplcart\core\Container; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Main class for Installer module |
16
|
|
|
*/ |
17
|
|
|
class Main |
18
|
|
|
{ |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Implements hook "module.install.before" |
22
|
|
|
* @param null|string $result |
23
|
|
|
*/ |
24
|
|
|
public function hookModuleInstallBefore(&$result) |
25
|
|
|
{ |
26
|
|
|
if (!class_exists('ZipArchive')) { |
27
|
|
|
$result = $this->getTranslationModel()->text('Class ZipArchive does not exist'); |
28
|
|
|
} |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Implements hook "route.list" |
33
|
|
|
* @param array $routes |
34
|
|
|
*/ |
35
|
|
|
public function hookRouteList(array &$routes) |
36
|
|
|
{ |
37
|
|
|
$routes['admin/module/install'] = array( |
38
|
|
|
'menu' => array('admin' => /* @text */'Install'), |
39
|
|
|
'access' => 'module_installer_upload', |
40
|
|
|
'handlers' => array( |
41
|
|
|
'controller' => array('gplcart\\modules\\installer\\controllers\\Upload', 'editUpload') |
42
|
|
|
) |
43
|
|
|
); |
44
|
|
|
|
45
|
|
|
$routes['admin/module/install/download'] = array( |
46
|
|
|
'access' => 'module_installer_download', |
47
|
|
|
'handlers' => array( |
48
|
|
|
'controller' => array('gplcart\\modules\\installer\\controllers\\Download', 'editDownload') |
49
|
|
|
) |
50
|
|
|
); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Implements hook "user.permissions" |
55
|
|
|
* @param array $permissions |
56
|
|
|
*/ |
57
|
|
|
public function hookUserPermissions(array &$permissions) |
58
|
|
|
{ |
59
|
|
|
$permissions['module_installer_upload'] = /* @text */'Installer: upload modules'; |
60
|
|
|
$permissions['module_installer_download'] = /* @text */'Installer: download modules'; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Implements hook "job.handlers" |
65
|
|
|
* @param array $handlers |
66
|
|
|
*/ |
67
|
|
|
public function hookJobHandlers(array &$handlers) |
68
|
|
|
{ |
69
|
|
|
$handlers['installer_download_module'] = array( |
70
|
|
|
'handlers' => array( |
71
|
|
|
'process' => array('gplcart\\modules\\installer\\handlers\\Download', 'process') |
72
|
|
|
), |
73
|
|
|
); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Implements hook "hook.cron" |
78
|
|
|
*/ |
79
|
|
|
public function hookCron() |
80
|
|
|
{ |
81
|
|
|
gplcart_file_delete_recursive(gplcart_file_private_module('installer')); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Translation UI model class instance |
86
|
|
|
* @return \gplcart\core\models\Translation |
87
|
|
|
*/ |
88
|
|
|
protected function getTranslationModel() |
89
|
|
|
{ |
90
|
|
|
return Container::get('gplcart\\core\\models\\Translation'); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
} |
94
|
|
|
|