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