mirror of
https://github.com/joomla-extensions/jedchecker.git
synced 2024-11-01 19:22:31 +00:00
94 lines
2.3 KiB
PHP
94 lines
2.3 KiB
PHP
<?php
|
|
/**
|
|
* @author eaxs
|
|
* @date 07/06/2012
|
|
* @copyright Copyright (C) 2008 - 2012 compojoom.com . All rights reserved.
|
|
* @license GNU General Public License version 2 or later; see LICENSE
|
|
*/
|
|
|
|
defined('_JEXEC') or die('Restricted access');
|
|
|
|
|
|
// Include the rule base class
|
|
require_once(JPATH_COMPONENT_ADMINISTRATOR.'/models/rule.php');
|
|
|
|
|
|
/**
|
|
* This class searches all xml manifestes for a valid license.
|
|
*
|
|
*/
|
|
class jedcheckerRulesXMLinfo extends JEDcheckerRule
|
|
{
|
|
/**
|
|
* The formal ID of this rule. For example: SE1.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $id = 'INFO_XML';
|
|
|
|
/**
|
|
* The title or caption of this rule.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $title = 'COM_JEDCHECKER_INFO_XML';
|
|
|
|
/**
|
|
* The description of this rule.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'COM_JEDCHECKER_INFO_XML_DESC';
|
|
|
|
|
|
/**
|
|
* Initiates the search and check
|
|
*
|
|
* @return void
|
|
*/
|
|
public function check()
|
|
{
|
|
// Find all XML files of the extension
|
|
$files = JFolder::files($this->basedir, '.xml$', true, true);
|
|
|
|
// Iterate through all the xml files
|
|
foreach ($files as $file)
|
|
{
|
|
// Try to find the license
|
|
$this->find($file);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* Reads a file and searches for the license
|
|
*
|
|
* @param string $file The path to the file
|
|
* @return boolean True if the license was found, otherwise False.
|
|
*/
|
|
protected function find($file)
|
|
{
|
|
$xml = JFactory::getXML($file);
|
|
|
|
// Failed to parse the xml file.
|
|
// Assume that this is not a extension manifest
|
|
if (!$xml) 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;
|
|
}
|
|
|
|
$info[] = JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_XML',(string)$xml->name);
|
|
$info[] = JText::sprintf('COM_JEDCHECKER_INFO_XML_VERSION_XML', (string)$xml->version);
|
|
$info[] = JText::sprintf('COM_JEDCHECKER_INFO_XML_CREATIONDATE_XML', (string)$xml->creationDate);
|
|
$this->report->addInfo($file, implode('<br />',$info));
|
|
|
|
|
|
// All checks passed. Return true
|
|
return true;
|
|
}
|
|
}
|