1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @package Base |
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\base; |
11
|
|
|
|
12
|
|
|
use gplcart\core\Module; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Main class for Base module |
16
|
|
|
*/ |
17
|
|
|
class Base extends Module |
18
|
|
|
{ |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Constructor |
22
|
|
|
*/ |
23
|
|
|
public function __construct() |
24
|
|
|
{ |
25
|
|
|
parent::__construct(); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Implements hook "route.list" |
30
|
|
|
* @param array $routes |
31
|
|
|
*/ |
32
|
|
|
public function hookRouteList(array &$routes) |
33
|
|
|
{ |
34
|
|
|
$routes['install/(\d+)'] = array( |
35
|
|
|
'handlers' => array( |
36
|
|
|
'controller' => array('gplcart\\modules\\base\\controllers\\Install', 'stepInstall') |
37
|
|
|
) |
38
|
|
|
); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Implements hook "install.handlers" |
43
|
|
|
* @param array $handlers |
44
|
|
|
*/ |
45
|
|
|
public function hookInstallHandlers(array &$handlers) |
46
|
|
|
{ |
47
|
|
|
$language = $this->getLanguage(); |
48
|
|
|
|
49
|
|
|
$handlers['base'] = array( |
50
|
|
|
'module' => 'base', |
51
|
|
|
'title' => $language->text('Base'), |
52
|
|
|
'steps' => array( |
53
|
|
|
1 => array('title' => $language->text('Configure modules')), |
54
|
|
|
2 => array('title' => $language->text('Create demo')), |
55
|
|
|
3 => array('title' => $language->text('Finish installation')) |
56
|
|
|
), |
57
|
|
|
'handlers' => array( |
58
|
|
|
'install' => array('gplcart\\modules\\base\\handlers\\Installer', 'install'), |
59
|
|
|
'install_1' => array('gplcart\\modules\\base\\handlers\\Installer', 'installModules'), |
60
|
|
|
'install_2' => array('gplcart\\modules\\base\\handlers\\Installer', 'installDemo'), |
61
|
|
|
'install_3' => array('gplcart\\modules\\base\\handlers\\Installer', 'installFinish') |
62
|
|
|
) |
63
|
|
|
); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Implements hook "install.before" |
68
|
|
|
* @param array $data |
69
|
|
|
* @param mixed $result |
70
|
|
|
*/ |
71
|
|
|
public function hookInstallBefore(array $data, &$result) |
72
|
|
|
{ |
73
|
|
|
/* @var $model \gplcart\modules\base\models\Installer */ |
74
|
|
|
$model = $this->getModel('Installer', 'base'); |
75
|
|
|
|
76
|
|
|
if ($data['installer'] === 'base' && empty($data['step']) && !$model->hasAllRequiredModules()) { |
77
|
|
|
$result = array( |
78
|
|
|
'redirect' => '', |
79
|
|
|
'severity' => 'warning', |
80
|
|
|
'message' => $this->getLanguage()->text('You cannot use this installer because some modules are missed in your distribution') |
81
|
|
|
); |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Implements hook "template.render" |
87
|
|
|
* @param array $templates |
88
|
|
|
*/ |
89
|
|
|
public function hookTemplateRender(array &$templates) |
90
|
|
|
{ |
91
|
|
|
if (substr($templates[0], -15) === 'dashboard/intro' && $this->config->get('installer') === 'base') { |
92
|
|
|
$templates[0] = $this->getTemplate('base', 'intro'); |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
} |
97
|
|
|
|