mirror of
https://github.com/e107inc/e107.git
synced 2025-03-14 01:19:44 +01:00
Tweak of isCompatible method.
This commit is contained in:
parent
0527993d98
commit
800f8734bf
@ -1845,7 +1845,7 @@ class plugin_form_online_ui extends e_admin_form_ui
|
||||
}
|
||||
|
||||
|
||||
if(!e107::isCompatible($compat))
|
||||
if(!e107::isCompatible($compat, 'plugin'))
|
||||
{
|
||||
$button = e107::getParser()->toGlyph('fa-bolt').ADLAN_121;
|
||||
$class = 'btn btn-sm btn-warning';
|
||||
|
@ -998,8 +998,7 @@ class theme_admin_form_ui extends e_admin_form_ui
|
||||
$disabled = '';
|
||||
$mainTitle = TPVLAN_10;
|
||||
|
||||
// if(version_compare($compat,$version, '<=') === false)
|
||||
if(!e107::isCompatible($theme['compatibility']))
|
||||
if(!e107::isCompatible($theme['compatibility'], 'theme'))
|
||||
{
|
||||
$disabled = 'disabled';
|
||||
$mainTitle = defset('TPVLAN_97', "This theme requires a newer version of e107.");
|
||||
|
@ -5561,10 +5561,12 @@ class e107
|
||||
/**
|
||||
* Returns true if the number is compatible with this version of e107.
|
||||
* @param string $version The minimum version requirement
|
||||
* @param string theme|plugin
|
||||
* @return bool
|
||||
*/
|
||||
public static function isCompatible($version)
|
||||
public static function isCompatible($version, $mode)
|
||||
{
|
||||
|
||||
$tp = e107::getParser();
|
||||
|
||||
$e107info = [];
|
||||
@ -5573,9 +5575,9 @@ class e107
|
||||
$e107 = $tp->filter($e107info['e107_version'], 'version');
|
||||
$version = $tp->filter($version, 'version');
|
||||
|
||||
if((int) $version === 1) // version 1, assumed to be incompatible.
|
||||
if(((int) $version === 1)) // version 1, assumed to be incompatible.
|
||||
{
|
||||
return false;
|
||||
return ($mode === 'plugin') ? false : true;
|
||||
}
|
||||
|
||||
return version_compare($e107 ,$version, '>=');
|
||||
|
@ -1953,7 +1953,7 @@ class e107Test extends \Codeception\Test\Unit
|
||||
public function testIsCompatible()
|
||||
{
|
||||
// version => expected
|
||||
$tests = array (
|
||||
$testPlugin = array (
|
||||
'1' => false, // assumed incompatible.
|
||||
'1.2.3' => false,
|
||||
'1.2' => false,
|
||||
@ -1971,16 +1971,38 @@ class e107Test extends \Codeception\Test\Unit
|
||||
);
|
||||
|
||||
$e107 = $this->e107;
|
||||
// $ret = [];
|
||||
foreach($tests as $input=>$expected)
|
||||
|
||||
foreach($testPlugin as $input=>$expected)
|
||||
{
|
||||
$result = $e107::isCompatible($input);
|
||||
$result = $e107::isCompatible($input, 'plugin');
|
||||
$this->assertSame($expected, $result);
|
||||
}
|
||||
|
||||
$testTheme = array (
|
||||
'1' => true, // assumed incompatible.
|
||||
'1.2.3' => true,
|
||||
'1.2' => true,
|
||||
'2' => true, // assumed to work with all versions from 2+
|
||||
'2.0' => true, // assumed to work with all versions from 2+
|
||||
'2.3' => true, // assumed to work with all versions from 2.3 onward.
|
||||
'2.1.0' => true,
|
||||
'2.2.0' => true,
|
||||
'2.3.0' => true,
|
||||
'2.3.1' => true,
|
||||
'1.7b' => true,
|
||||
'2.9' => false,
|
||||
'2.9.2' => false,
|
||||
'3' => false,
|
||||
);
|
||||
|
||||
foreach($testTheme as $input=>$expected)
|
||||
{
|
||||
$result = $e107::isCompatible($input, 'theme');
|
||||
$this->assertSame($expected, $result);
|
||||
// $ret[$input] = $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
/*
|
||||
public function testIni_set()
|
||||
|
Loading…
x
Reference in New Issue
Block a user