31
2
mirror of https://github.com/joomla-extensions/jedchecker.git synced 2024-06-05 06:50:47 +00:00

rule to found missed/incorrent client attribute

This commit is contained in:
Denis Ryabov 2021-04-04 14:26:31 +03:00
parent a426ccfd0e
commit 4ed9b2c64d
2 changed files with 17 additions and 0 deletions

View File

@ -90,3 +90,5 @@ COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILD="Node <%1$s> contains unknown <%2
COM_JEDCHECKER_MANIFEST_EMPTY_CHILD="Found empty <%s> element"
COM_JEDCHECKER_MANIFEST_MENU_UNUSED_ATTRIBUTE="Menu item attribute '%s' is not used with 'link' attribute"
COM_JEDCHECKER_MANIFEST_MISSED_METHOD_UPGRADE="Without the method="upgrade" attribute the extension package cannot be upgraded"
COM_JEDCHECKER_MANIFEST_MISSED_ATTRIBUTE="The node <%1$s> doesn't contain required '%2$s' attribute"
COM_JEDCHECKER_MANIFEST_UNKNOWN_ATTRIBUTE_VALUE="The node <%1$s> has attribute '%2$s' with unknown value "%3$s""

View File

@ -173,6 +173,21 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule
$this->report->addWarning($file, JText::_('COM_JEDCHECKER_MANIFEST_MISSED_METHOD_UPGRADE'));
}
// check 'client' attribute is "site" or "administrator" (for module/template only)
if ($type === 'module' || $type === 'template')
{
$client = (string) $xml['client'];
if (!isset($xml['client']))
{
$this->report->addError($file, JText::sprintf('COM_JEDCHECKER_MANIFEST_MISSED_ATTRIBUTE', $xml->getName(), 'client'));
}
elseif ($client !== 'site' && $client !== 'administrator')
{
$this->report->addError($file, JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_ATTRIBUTE_VALUE', $xml->getName(), 'client', $client));
}
}
$data = json_decode(file_get_contents($json_filename), true);
$this->DTDNodeRules = $data['nodes'];
$this->DTDAttrRules = $data['attributes'];