This repository has been archived by the owner on Jul 21, 2021. It is now read-only.
/
installerScript.php
69 lines (58 loc) · 1.97 KB
/
installerScript.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
<?php
/**
* Use in your extension manifest file (any tag is optional!!!!!):
* <minimumPhp>7.0.0</minimumPhp>
* <minimumJoomla>3.9.0</minimumJoomla>
* Yes, use 999999 to match '3.9'. Otherwise comparison will fail.
* <maximumJoomla>3.9.999999</maximumJoomla>
* <maximumPhp>7.3.999999</maximumPhp>
* <allowDowngrades>1</allowDowngrades>
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Installer\InstallerScript;
use Joomla\CMS\Log\Log;
class plgEditorsxtdSyntaxhighlighterGhsvsInstallerScript extends InstallerScript
{
public function preflight($type, $parent)
{
$manifest = @$parent->getManifest();
if ($manifest instanceof SimpleXMLElement)
{
if ($type === 'update' || $type === 'install' || $type === 'discover_install')
{
$minimumPhp = trim((string) $manifest->minimumPhp);
$minimumJoomla = trim((string) $manifest->minimumJoomla);
// Custom
$maximumPhp = trim((string) $manifest->maximumPhp);
$maximumJoomla = trim((string) $manifest->maximumJoomla);
$this->minimumPhp = $minimumPhp ? $minimumPhp : $this->minimumPhp;
$this->minimumJoomla = $minimumJoomla ? $minimumJoomla : $this->minimumJoomla;
if ($maximumJoomla && version_compare(JVERSION, $maximumJoomla, '>'))
{
$msg = 'Your Joomla version (' . JVERSION . ') is too high for this extension. Maximum Joomla version is: ' . $maximumJoomla . '.';
Log::add($msg, Log::WARNING, 'jerror');
}
// Check for the maximum PHP version before continuing
if ($maximumPhp && version_compare(PHP_VERSION, $maximumPhp, '>'))
{
$msg = 'Your PHP version (' . PHP_VERSION . ') is too high for this extension. Maximum PHP version is: ' . $maximumPhp . '.';
Log::add($msg, Log::WARNING, 'jerror');
}
if (isset($msg))
{
return false;
}
}
if (trim((string) $manifest->allowDowngrades))
{
$this->allowDowngrades = true;
}
}
if (!parent::preflight($type, $parent))
{
return false;
}
return true;
}
}