mirror of
https://github.com/joomla-extensions/jedchecker.git
synced 2024-12-31 21:51:46 +00:00
Apply naming rules to the main manifest file(s?) only (others are checked for URLs, ASCII, length, and menu name only)
This commit is contained in:
parent
907bbd1d75
commit
c50e39e357
@ -74,13 +74,20 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule
|
||||
|
||||
$manifestFound = false;
|
||||
|
||||
// Iterate through all the xml files
|
||||
foreach ($files as $file)
|
||||
if (count($files))
|
||||
{
|
||||
// Try to find the license
|
||||
if ($this->find($file))
|
||||
$topLevelDepth = substr_count($files[0], '/');
|
||||
|
||||
// Iterate through all the xml files
|
||||
foreach ($files as $file)
|
||||
{
|
||||
$manifestFound = true;
|
||||
$isTopLevel = substr_count($file, '/') === $topLevelDepth;
|
||||
|
||||
// Try to find the license
|
||||
if ($this->find($file, $isTopLevel))
|
||||
{
|
||||
$manifestFound = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,11 +100,12 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule
|
||||
/**
|
||||
* Reads a file and searches for the license
|
||||
*
|
||||
* @param string $file - The path to the file
|
||||
* @param string $file - The path to the file
|
||||
* @param bool $isTopLevel - Is the file located in the top-level manifests directory?
|
||||
*
|
||||
* @return boolean True if the manifest file was found, otherwise False.
|
||||
*/
|
||||
protected function find($file)
|
||||
protected function find($file, $isTopLevel)
|
||||
{
|
||||
$xml = JFactory::getXml($file);
|
||||
|
||||
@ -136,60 +144,63 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule
|
||||
|
||||
$this->report->addInfo($file, implode('<br />', $info));
|
||||
|
||||
// NM3 - Listing name contains “module” or “plugin”
|
||||
// (and other reserved words)
|
||||
if (preg_match('/\b(?:module|plugin|component|template|extension|free)\b/i', $extensionName, $match))
|
||||
if ($isTopLevel)
|
||||
{
|
||||
$this->report->addError($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_RESERVED_KEYWORDS', $extensionName, strtolower($match[0])));
|
||||
}
|
||||
|
||||
// Extension name shouldn't start with extension type prefix
|
||||
if (preg_match('/^\s*(?:mod|com|plg|tpl|pkg)_/i', $extensionName))
|
||||
{
|
||||
$this->report->addError($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_PREFIXED', $extensionName));
|
||||
}
|
||||
|
||||
// NM5 - Version in name/title
|
||||
if (preg_match('/(?:\bversion\b|\d\.\d)/i', $extensionName))
|
||||
{
|
||||
$this->report->addError($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_VERSION', $extensionName));
|
||||
}
|
||||
|
||||
// Check for "Joomla" in the name
|
||||
if (stripos($extensionName, 'joomla') === 0)
|
||||
{
|
||||
// An extension name can't start with the word "Joomla"
|
||||
$this->report->addError($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_JOOMLA', $extensionName));
|
||||
}
|
||||
else
|
||||
{
|
||||
$cleanName = preg_replace('/\s+for\s+Joomla!?$/', '', $extensionName);
|
||||
|
||||
if (stripos($cleanName, 'joom') !== false)
|
||||
// NM3 - Listing name contains “module” or “plugin”
|
||||
// (and other reserved words)
|
||||
if (preg_match('/\b(?:module|plugin|component|template|extension|free)\b/i', $extensionName, $match))
|
||||
{
|
||||
// Extensions that use "Joomla" or a derivative of Joomla in the extension name need to be licensed by OSM
|
||||
$this->report->addWarning($file,
|
||||
JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_JOOMLA_DERIVATIVE', $extensionName, 'https://tm.joomla.org/approved-domains.html')
|
||||
);
|
||||
$this->report->addError($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_RESERVED_KEYWORDS', $extensionName, strtolower($match[0])));
|
||||
}
|
||||
}
|
||||
|
||||
// Check extension name consists of ASCII characters only
|
||||
if (preg_match('/[^\x20-\x7E]/', $extensionName))
|
||||
{
|
||||
$this->report->addError($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_NON_ASCII', $extensionName));
|
||||
}
|
||||
// Extension name shouldn't start with extension type prefix
|
||||
if (preg_match('/^\s*(?:mod|com|plg|tpl|pkg)_/i', $extensionName))
|
||||
{
|
||||
$this->report->addError($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_PREFIXED', $extensionName));
|
||||
}
|
||||
|
||||
// Extension name shouldn't be too long
|
||||
$nameLen = strlen($extensionName);
|
||||
// NM5 - Version in name/title
|
||||
if (preg_match('/(?:\bversion\b|\d\.\d)/i', $extensionName))
|
||||
{
|
||||
$this->report->addError($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_VERSION', $extensionName));
|
||||
}
|
||||
|
||||
if ($nameLen > 80)
|
||||
{
|
||||
$this->report->addError($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_TOO_LONG', $extensionName));
|
||||
}
|
||||
elseif ($nameLen > 40)
|
||||
{
|
||||
$this->report->addWarning($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_TOO_LONG', $extensionName));
|
||||
// Check for "Joomla" in the name
|
||||
if (stripos($extensionName, 'joomla') === 0)
|
||||
{
|
||||
// An extension name can't start with the word "Joomla"
|
||||
$this->report->addError($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_JOOMLA', $extensionName));
|
||||
}
|
||||
else
|
||||
{
|
||||
$cleanName = preg_replace('/\s+for\s+Joomla!?$/', '', $extensionName);
|
||||
|
||||
if (stripos($cleanName, 'joom') !== false)
|
||||
{
|
||||
// Extensions that use "Joomla" or a derivative of Joomla in the extension name need to be licensed by OSM
|
||||
$this->report->addWarning($file,
|
||||
JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_JOOMLA_DERIVATIVE', $extensionName, 'https://tm.joomla.org/approved-domains.html')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Check extension name consists of ASCII characters only
|
||||
if (preg_match('/[^\x20-\x7E]/', $extensionName))
|
||||
{
|
||||
$this->report->addError($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_NON_ASCII', $extensionName));
|
||||
}
|
||||
|
||||
// Extension name shouldn't be too long
|
||||
$nameLen = strlen($extensionName);
|
||||
|
||||
if ($nameLen > 80)
|
||||
{
|
||||
$this->report->addError($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_TOO_LONG', $extensionName));
|
||||
}
|
||||
elseif ($nameLen > 40)
|
||||
{
|
||||
$this->report->addWarning($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_TOO_LONG', $extensionName));
|
||||
}
|
||||
}
|
||||
|
||||
// Validate URLs
|
||||
@ -210,7 +221,7 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule
|
||||
}
|
||||
}
|
||||
|
||||
if ($type === 'plugin')
|
||||
if ($isTopLevel && $type === 'plugin')
|
||||
{
|
||||
// The name of your plugin must comply with the JED naming conventions - plugins in the form “{Type} - {Extension Name}”.
|
||||
$parts = explode(' - ', $extensionName, 2);
|
||||
|
Loading…
Reference in New Issue
Block a user