33
2
mirror of https://github.com/joomla-extensions/jedchecker.git synced 2024-11-27 15:26:36 +00:00

Merge PR #118 into develop

This commit is contained in:
Llewellyn van der Merwe 2021-08-31 12:05:30 +02:00
commit aeafb2fb73
Signed by: Llewellyn
GPG Key ID: EFC0C720A240551C

View File

@ -15,6 +15,9 @@ defined('_JEXEC') or die('Restricted access');
// Include the rule base class // Include the rule base class
require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php'; require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php';
// Include the helper class
require_once JPATH_COMPONENT_ADMINISTRATOR . '/libraries/helper.php';
/** /**
* class JedcheckerRulesXMLUpdateServer * class JedcheckerRulesXMLUpdateServer
* *
@ -60,7 +63,7 @@ class JedcheckerRulesXMLUpdateServer extends JEDcheckerRule
public function check() public function check()
{ {
// Find all XML files of the extension // Find all XML files of the extension
$files = JFolder::files($this->basedir, '\.xml$', true, true); $files = JEDCheckerHelper::findManifests($this->basedir);
// Find XML package file // Find XML package file
$packageFile = $this->checkPackageXML($files); $packageFile = $this->checkPackageXML($files);
@ -88,17 +91,13 @@ class JedcheckerRulesXMLUpdateServer extends JEDcheckerRule
{ {
$xml = simplexml_load_file($file); $xml = simplexml_load_file($file);
// Check if this is an XML and an extension manifest
if ($xml && ($xml->getName() == 'install' || $xml->getName() == 'extension'))
{
// Check if extension attribute 'type' is for a package // Check if extension attribute 'type' is for a package
if($xml->attributes()->type == 'package') if ($xml && (string) $xml['type'] === 'package')
{ {
$packageCount++; $packageCount++;
$this->find($file); $this->find($file);
} }
} }
}
// No XML file found for package // No XML file found for package
if ($packageCount == 0) if ($packageCount == 0)
@ -125,8 +124,7 @@ class JedcheckerRulesXMLUpdateServer extends JEDcheckerRule
{ {
$xml = simplexml_load_file($file); $xml = simplexml_load_file($file);
// Check if this is an XML and an extension manifest if ($xml)
if ($xml && ($xml->getName() == 'install' || $xml->getName() == 'extension'))
{ {
$directories = explode('/', substr($file, 0, strrpos( $file, '/'))); $directories = explode('/', substr($file, 0, strrpos( $file, '/')));
$XMLFiles[] = array( $XMLFiles[] = array(
@ -190,13 +188,6 @@ class JedcheckerRulesXMLUpdateServer extends JEDcheckerRule
return true; return true;
} }
// Check if this is an extension manifest
// 1.5 uses 'install', 1.6 uses 'extension'
if ($xml->getName() != 'install' && $xml->getName() != 'extension')
{
return true;
}
// Check if there is an updateservers tag // Check if there is an updateservers tag
if (!isset($xml->updateservers)) if (!isset($xml->updateservers))
{ {