mirror of
https://github.com/e107inc/e107.git
synced 2025-07-16 12:36:26 +02:00
Tweak of isCompatible method.
This commit is contained in:
@ -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;
|
$button = e107::getParser()->toGlyph('fa-bolt').ADLAN_121;
|
||||||
$class = 'btn btn-sm btn-warning';
|
$class = 'btn btn-sm btn-warning';
|
||||||
|
@ -998,8 +998,7 @@ class theme_admin_form_ui extends e_admin_form_ui
|
|||||||
$disabled = '';
|
$disabled = '';
|
||||||
$mainTitle = TPVLAN_10;
|
$mainTitle = TPVLAN_10;
|
||||||
|
|
||||||
// if(version_compare($compat,$version, '<=') === false)
|
if(!e107::isCompatible($theme['compatibility'], 'theme'))
|
||||||
if(!e107::isCompatible($theme['compatibility']))
|
|
||||||
{
|
{
|
||||||
$disabled = 'disabled';
|
$disabled = 'disabled';
|
||||||
$mainTitle = defset('TPVLAN_97', "This theme requires a newer version of e107.");
|
$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.
|
* Returns true if the number is compatible with this version of e107.
|
||||||
* @param string $version The minimum version requirement
|
* @param string $version The minimum version requirement
|
||||||
|
* @param string theme|plugin
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function isCompatible($version)
|
public static function isCompatible($version, $mode)
|
||||||
{
|
{
|
||||||
|
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
|
|
||||||
$e107info = [];
|
$e107info = [];
|
||||||
@ -5573,9 +5575,9 @@ class e107
|
|||||||
$e107 = $tp->filter($e107info['e107_version'], 'version');
|
$e107 = $tp->filter($e107info['e107_version'], 'version');
|
||||||
$version = $tp->filter($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, '>=');
|
return version_compare($e107 ,$version, '>=');
|
||||||
|
@ -1953,7 +1953,7 @@ class e107Test extends \Codeception\Test\Unit
|
|||||||
public function testIsCompatible()
|
public function testIsCompatible()
|
||||||
{
|
{
|
||||||
// version => expected
|
// version => expected
|
||||||
$tests = array (
|
$testPlugin = array (
|
||||||
'1' => false, // assumed incompatible.
|
'1' => false, // assumed incompatible.
|
||||||
'1.2.3' => false,
|
'1.2.3' => false,
|
||||||
'1.2' => false,
|
'1.2' => false,
|
||||||
@ -1971,16 +1971,38 @@ class e107Test extends \Codeception\Test\Unit
|
|||||||
);
|
);
|
||||||
|
|
||||||
$e107 = $this->e107;
|
$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);
|
$this->assertSame($expected, $result);
|
||||||
// $ret[$input] = $result;
|
// $ret[$input] = $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
public function testIni_set()
|
public function testIni_set()
|
||||||
|
Reference in New Issue
Block a user