-
Notifications
You must be signed in to change notification settings - Fork 15
/
pkg_jdbuilder.php
104 lines (87 loc) · 2.26 KB
/
pkg_jdbuilder.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
<?php
/**
* @package JD Builder
* @author Team Joomdev <info@joomdev.com>
* @copyright 2020 www.joomdev.com
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// no direct access
defined('_JEXEC') or die;
use Joomla\Component\Menus\Administrator\Helper\MenusHelper;
class pkg_jdbuilderInstallerScript
{
private $min_php_version = '7.2';
/**
*
* Function to run before installing the component
*/
public function preflight($type, $parent)
{
if (!$this->passMinimumPHPVersion()) {
return false;
}
}
/**
*
* Function to run when installing the component
* @return void
*/
public function install($parent)
{
// self::installPreset();
}
/**
*
* Function to run when un-installing the component
* @return void
*/
public function uninstall($parent)
{
}
/**
*
* Function to run when updating the component
* @return void
*/
function update($parent)
{
// self::installPreset();
}
/**
*
* Function to run after installing the component
*/
public function postflight($type, $parent)
{
}
private function passMinimumPHPVersion()
{
if (version_compare(PHP_VERSION, $this->min_php_version, 'l')) {
\JFactory::getApplication()->enqueueMessage(
\JText::sprintf(
'You current PHP version is %s. The minimum recommended PHP version for JD Builder is PHP %s.',
'<strong>' . PHP_VERSION . '</strong>',
'<strong>' . $this->min_php_version . '</strong>'
),
'error'
);
return false;
}
return true;
}
public static function installPreset()
{
$version = new \JVersion;
$version = $version->getShortVersion();
$version = substr($version, 0, 1);
if ($version == 3) return;
if (\JFactory::getApplication()->isClient('administrator')) {
$db = \JFactory::getDbo();
$db->setQuery("SELECT * FROM `#__menu` WHERE `alias`='component-com_jdbuilder' AND `client_id`='1'");
$exists = $db->loadObject();
if (!$exists) {
MenusHelper::installPreset('jdbuilder', 'component');
}
}
}
}