-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
pkg_script.php
40 lines (32 loc) · 1.21 KB
/
pkg_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
<?php defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Version;
use Joomla\CMS\Language\Text;
class pkg_attrsInstallerScript
{
function preflight($type, $parent)
{
if (strtolower($type) === 'uninstall') {
return true;
}
$minJoomlaVersion = $parent->getManifest()->attributes()->version[0];
if (!class_exists('Joomla\CMS\Version')) {
JFactory::getApplication()->enqueueMessage(JText::sprintf('J_JOOMLA_COMPATIBLE', JText::_($parent->getName()), $minJoomlaVersion), 'error');
return false;
}
$msg = '';
$ver = new Version();
$name = Text::_($parent->getName());
$minPhpVersion = $parent->getManifest()->php_minimum[0];
if (version_compare($ver->getShortVersion(), $minJoomlaVersion, 'lt')) {
$msg .= Text::sprintf('PKG_SNIPPET_JOOMLA_COMPATIBLE', $name, $minJoomlaVersion);
}
if (version_compare(phpversion(), $minPhpVersion, 'lt')) {
$msg .= Text::sprintf('PKG_SNIPPET_PHP_COMPATIBLE', $name, $minPhpVersion);
}
if ($msg) {
Factory::getApplication()->enqueueMessage($msg, 'error');
return false;
}
}
}