mirror of
https://github.com/joomla-extensions/jedchecker.git
synced 2024-09-28 21:19:07 +00:00
change unknown children and attribute to just an info-level message
This commit is contained in:
parent
ae251b5d5b
commit
49b383514e
@ -58,6 +58,13 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule
|
|||||||
*/
|
*/
|
||||||
protected $warnings;
|
protected $warnings;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of infos.
|
||||||
|
*
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
protected $infos;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rules for XML nodes
|
* Rules for XML nodes
|
||||||
* ? - single, optional
|
* ? - single, optional
|
||||||
@ -153,6 +160,7 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule
|
|||||||
|
|
||||||
$this->errors = array();
|
$this->errors = array();
|
||||||
$this->warnings = array();
|
$this->warnings = array();
|
||||||
|
$this->infos = array();
|
||||||
|
|
||||||
// Validate manifest
|
// Validate manifest
|
||||||
$this->validateXml($xml, 'extension');
|
$this->validateXml($xml, 'extension');
|
||||||
@ -167,6 +175,11 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule
|
|||||||
$this->report->addWarning($file, implode('<br />', $this->warnings));
|
$this->report->addWarning($file, implode('<br />', $this->warnings));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (count($this->infos))
|
||||||
|
{
|
||||||
|
$this->report->addInfo($file, implode('<br />', $this->infos));
|
||||||
|
}
|
||||||
|
|
||||||
// All checks passed. Return true
|
// All checks passed. Return true
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -186,12 +199,12 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule
|
|||||||
{
|
{
|
||||||
foreach ($node->attributes() as $attr)
|
foreach ($node->attributes() as $attr)
|
||||||
{
|
{
|
||||||
$attrName = (string)$attr->getName();
|
$attrName = (string) $attr->getName();
|
||||||
|
|
||||||
if (!in_array($attrName, $DTDattributes, true))
|
if (!in_array($attrName, $DTDattributes, true))
|
||||||
{
|
{
|
||||||
// The node has unknown attribute
|
// The node has unknown attribute
|
||||||
$this->warnings[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_ATTRIBUTE', $name, $attrName);
|
$this->infos[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_ATTRIBUTE', $name, $attrName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -202,7 +215,7 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule
|
|||||||
// No children
|
// No children
|
||||||
if ($node->count() > 0)
|
if ($node->count() > 0)
|
||||||
{
|
{
|
||||||
$this->warnings[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILDREN', $name);
|
$this->infos[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILDREN', $name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif (!isset($this->DTDNodeRules[$name]['*']))
|
elseif (!isset($this->DTDNodeRules[$name]['*']))
|
||||||
@ -248,13 +261,14 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule
|
|||||||
{
|
{
|
||||||
$childNames[$child->getName()] = 1;
|
$childNames[$child->getName()] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$childNames = array_keys($childNames);
|
$childNames = array_keys($childNames);
|
||||||
|
|
||||||
foreach ($childNames as $child)
|
foreach ($childNames as $child)
|
||||||
{
|
{
|
||||||
if (!isset($DTDchildren[$child]))
|
if (!isset($DTDchildren[$child]))
|
||||||
{
|
{
|
||||||
$this->warnings[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILD', $name, $child);
|
$this->infos[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILD', $name, $child);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -287,6 +301,7 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Extra check for menu nodes
|
||||||
* @param SimpleXMLElement $node XML node
|
* @param SimpleXMLElement $node XML node
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
|
Loading…
Reference in New Issue
Block a user