forked from Quantum-Manager/quantummanager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.php
138 lines (120 loc) · 3.38 KB
/
script.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
/**
* @package quantummanager
* @author Dmitry Tsymbal <[email protected]>
* @copyright Copyright © 2019 Delo Design & NorrNext. All rights reserved.
* @license GNU General Public License version 3 or later; see license.txt
* @link https://www.norrnext.com
*/
use Joomla\CMS\Factory;
defined('_JEXEC') or die;
/**
* Quantummanager script file.
*
* @package A package name
* @since 1.0
*/
class Com_QuantummanagerInstallerScript
{
/**
* Minimum PHP version required to install the extension.
*
* @var string
*
* @since 0.0.1
*/
protected $minimumPhp = '7.1';
/**
* Minimum Joomla version required to install the extension.
*
* @var string
*
* @since 0.0.1
*/
protected $minimumJoomla = '3.9.0';
/**
* @var string
*/
protected $helpURL = 'https://norrnext.com/docs/joomla-extensions/quantum-manager';
/**
* Extensions for php
* @var array
*/
protected $extensions = [
'fileinfo',
'curl',
'mbstring'
];
/**
* Constructor
*
* @param JAdapterInstance $adapter The object responsible for running this script
*/
public function __construct(JAdapterInstance $adapter) {}
/**
* Called before any type of action
*
* @param string $route Which action is happening (install|uninstall|discover_install|update)
* @param JAdapterInstance $adapter The object responsible for running this script
*
* @return boolean True on success
*/
public function preflight($route, JAdapterInstance $adapter)
{
$app = Factory::getApplication();
if (!(version_compare(PHP_VERSION, '7.1.0') >= 0))
{
$app->enqueueMessage(Text::sprintf('COM_QUANTUMMANAGER_ERROR_COMPATIBLE_PHP', $this->minimumPhp),
'error');
return false;
}
jimport('joomla.version');
$jversion = new JVersion();
if (!$jversion->isCompatible('3.7'))
{
$app->enqueueMessage(Text::sprintf('COM_QUANTUMMANAGER_ERROR_COMPATIBLE_PHP', $this->minimumJoomla),
'error');
return false;
}
//Check extension
$extensionsNotLoaded = [];
foreach ($this->extensions as $extension)
{
if(!extension_loaded($extension))
{
$extensionsNotLoaded[] = $extension;
}
}
if(count($extensionsNotLoaded))
{
$app->enqueueMessage(Text::sprintf('COM_QUANTUMMANAGER_ERROR_EXTENSIONS', implode(',', $extensionsNotLoaded)),
'error');
return false;
}
}
/**
* This method is called after a component is updated.
*
* @param \stdClass $parent - Parent object calling object.
*
* @return void
*/
public function update($parent)
{
JLoader::register('QuantummanagerHelper', JPATH_ROOT . '/administrator/components/com_quantummanager/helpers/quantummanager.php');
QuantummanagerHelper::setComponentsParams('helpURL', $this->helpURL);
}
/**
* Called after any type of action
*
* @param string $route Which action is happening (install|uninstall|discover_install|update)
* @param JAdapterInstance $adapter The object responsible for running this script
*
* @return boolean True on success
*/
public function postflight($route, JAdapterInstance $adapter)
{
JLoader::register('QuantummanagerHelper', JPATH_ROOT . '/administrator/components/com_quantummanager/helpers/quantummanager.php');
QuantummanagerHelper::setComponentsParams('helpURL', $this->helpURL);
}
}