31
2
mirror of https://github.com/joomla-extensions/jedchecker.git synced 2024-06-12 01:42:20 +00:00

Update Servers for packages

This commit is contained in:
Jaz Parkyn 2017-01-13 09:39:46 +00:00
parent 5b57ec94d5
commit d3c39165df

View File

@ -52,6 +52,10 @@ class JedcheckerRulesXMLUpdateServer extends JEDcheckerRule
// Find all XML files of the extension
$files = JFolder::files($this->basedir, '.xml$', true, true);
// Find XML package file
$packageFile = $this->checkPackageXML($files);
if (!$packageFile){
// Iterate through all the xml files
foreach ($files as $file)
{
@ -59,13 +63,48 @@ class JedcheckerRulesXMLUpdateServer extends JEDcheckerRule
$this->find($file);
}
}
}
/**
* Reads a file and searches for the license
* Reads a file and searches for package xml file
*
* @param string $file - The path to the file
*
* @return boolean True if the license was found, otherwise False.
* @return boolean True if the package xml file was found, otherwise False.
*/
protected function checkPackageXML($files)
{
$packageCount = 0;
foreach ($files as $file)
{
$xml = JFactory::getXml($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
if($xml->attributes()->type == 'package'){
$packageCount++;
$this->find($file);
}
}
}
// No XML file found for package
if ($packageCount == 0){
return false;
} else {
return true;
}
}
/**
* Reads a file and searches for the update server
*
* @param string $file - The path to the file
*
* @return boolean True if the update server was found, otherwise False.
*/
protected function find($file)
{