-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
script.php
91 lines (75 loc) · 2.55 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
<?php
/**
* @package Herzog Dupont for YOOtheme Pro
* @author Thomas Weidlich
* @copyright Copyright (C) 2021-2024 Thomas Weidlich
* @license GNU General Public License version 3, see LICENSE
*/
// No direct access
defined('_JEXEC') or die;
class plgSystemHerzogdupontInstallerScript
{
protected $minimumPHPVersion = '8.0.0';
protected $minimumJoomlaVersion = '4.0.0';
protected $minimumYOOthemeVersion = '4.3.0';
public function install($parent)
{
// Enable the extension
$this->enablePlugin();
return true;
}
public function uninstall($parent)
{
}
public function update($parent)
{
}
public function preflight($type, $parent)
{
// Check the minimum PHP version
if (!version_compare(PHP_VERSION, $this->minimumPHPVersion, '>='))
{
$msg = '<p>You need PHP ' . $this->minimumPHPVersion . ' or later to install this plugin.</p>';
JLog::add($msg, JLog::WARNING, 'jerror');
return false;
}
// Check the minimum Joomla! version
if (!version_compare(JVERSION, $this->minimumJoomlaVersion, '>='))
{
$msg = '<p>You need Joomla! ' . $this->minimumJoomlaVersion . ' or later to install this plugin.</p>';
JLog::add($msg, JLog::WARNING, 'jerror');
return false;
}
// Check the minimum YOOtheme Pro version
$yoothemeManifest = simplexml_load_file(JPATH_SITE . '/templates/yootheme/templateDetails.xml');
if (!$yoothemeManifest or !version_compare((string) $yoothemeManifest->version, $this->minimumYOOthemeVersion, '>='))
{
$msg = '<p>You need YOOtheme Pro ' . $this->minimumYOOthemeVersion . ' or later to install this plugin.</p>';
JLog::add($msg, JLog::WARNING, 'jerror');
return false;
}
return true;
}
public function postflight($type, $parent)
{
}
private function enablePlugin()
{
try
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->update($db->qn('#__extensions'))
->set($db->qn('enabled') . ' = ' . $db->q(1))
->where('type = ' . $db->q('plugin'))
->where('folder = ' . $db->q('system'))
->where('element = ' . $db->q('herzogdupont'));
$db->setQuery($query);
$db->execute();
}
catch (\Exception $e)
{
return;
}
}
}