diff --git a/source/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php b/source/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php new file mode 100644 index 0000000..54fcb91 --- /dev/null +++ b/source/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php @@ -0,0 +1,93 @@ +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('
',$info)); + + + // All checks passed. Return true + return true; + } +} diff --git a/source/administrator/components/com_jedchecker/models/report.php b/source/administrator/components/com_jedchecker/models/report.php index ccd9dbd..5ff8231 100644 --- a/source/administrator/components/com_jedchecker/models/report.php +++ b/source/administrator/components/com_jedchecker/models/report.php @@ -32,13 +32,13 @@ class JEDcheckerReport extends JObject protected $basedir; - /** - * Constructor. Initialises variables. - * - * @param mixed $properties See JObject::__construct - * - * @return void - */ + /** + * Constructor. Initialises variables. + * + * @param mixed $properties See JObject::__construct + * + * @return \JEDcheckerReport + */ public function __construct($properties = null) { // Construct JObject @@ -60,11 +60,13 @@ class JEDcheckerReport extends JObject $this->data['errors'] = array(); $this->data['compat'] = array(); + $this->data['info'] = array(); $this->data['count'] = new stdClass(); $this->data['count']->total = 0; $this->data['count']->errors = 0; $this->data['count']->compat = 0; + $this->data['count']->info = 0; } @@ -74,7 +76,7 @@ class JEDcheckerReport extends JObject * @param string $location The location of the error. Can be a path to a file or dir. * @param string $text An optional description of the error. * @param integer $line If $location is a file, you may specify the line where the - * error occured. + * error occurred. * * @return void */ @@ -88,6 +90,26 @@ class JEDcheckerReport extends JObject $this->addItem($item, 'errors'); } + /** + * Adds an error to the report. + * + * @param string $location The location of the error. Can be a path to a file or dir. + * @param string $text An optional description of the error. + * @param integer $line If $location is a file, you may specify the line where the + * error occurred. + * + * @return void + */ + public function addInfo($location, $text = NULL, $line = 0) + { + $item = new stdClass(); + $item->location = $location; + $item->line = $line; + $item->text = (empty($text) ? '' : JText::_($text)); + + $this->addItem($item, 'info'); + } + /** * Adds a compatibility issue to the report. @@ -95,7 +117,7 @@ class JEDcheckerReport extends JObject * @param string $location The location of the issue. Can be a path to a file or dir. * @param string $text An optional description of the issue * @param integer $line If $location is a file, you may specify the line where the - * issue occured. + * issue occurred. * * @return void */ @@ -128,6 +150,7 @@ class JEDcheckerReport extends JObject else { $error_count = $this->data['count']->errors; $compat_count = $this->data['count']->compat; + $info_count = $this->data['count']->info; // Go through the error list if($error_count > 0) { @@ -188,6 +211,37 @@ class JEDcheckerReport extends JObject $html[] = ''; } + + // Go through the compat list + if($info_count > 0) { + $html[] = ''.$info_count. ' '.JText::_('COM_JEDCHECKER_INFO').''; + $html[] = ''; + } } diff --git a/source/administrator/language/en-GB/en-GB.com_jedchecker.ini b/source/administrator/language/en-GB/en-GB.com_jedchecker.ini index 2e31c39..3fb40d9 100644 --- a/source/administrator/language/en-GB/en-GB.com_jedchecker.ini +++ b/source/administrator/language/en-GB/en-GB.com_jedchecker.ini @@ -31,4 +31,10 @@ COM_JEDCHECKER_IN_LINE="in line" COM_JEDCHECKER_ERROR_ENCODING="You've used encoding in this file? This is not an error, but an editor will have to review this file!" COM_JEDCHECKER_RULE_ENCODING="Base64 or other type of encoding in the files" COM_JEDCHECKER_RULE_ENCODING_DESC="As developers we are fully aware that the base64 and similar functions have a valid place in each extensions(like URL redirects or data storage). However if you use those to make it harder for users to read your code or to mask backlinks the JED might not accept your listing submission (this is not in the spirit of GPL anyway!). An editor will review your code and determine if the way you use the base64 matches the rules of the JED. This might slow your listing review time. So the rule of thumb is - don't do fishy stuff and avoid encoding your code if possible!" -COM_JEDCHECKER_LEAVE_A_REVIEW_JED="If you use this component, please post a rating and a review at the Joomla! Extensions Directory." \ No newline at end of file +COM_JEDCHECKER_LEAVE_A_REVIEW_JED="If you use this component, please post a rating and a review at the Joomla! Extensions Directory." +COM_JEDCHECKER_INFO="Info" +COM_JEDCHECKER_INFO_XML="Just some info about the extension xml files" +COM_JEDCHECKER_INFO_XML_DESC="This is not a rule, just a convenience check. We go through the xml files and grab the value for the name tag. Useful information for the "filename and install as" fields in the jed submission form" +COM_JEDCHECKER_INFO_XML_NAME_XML="The name tag in this file is: %s" +COM_JEDCHECKER_INFO_XML_VERSION_XML="Version tag has the value: %s" +COM_JEDCHECKER_INFO_XML_CREATIONDATE_XML="The creationDate tag has the value: %s" \ No newline at end of file diff --git a/source/media/com_jedchecker/css/css.css b/source/media/com_jedchecker/css/css.css index 3d44544..a04d371 100644 --- a/source/media/com_jedchecker/css/css.css +++ b/source/media/com_jedchecker/css/css.css @@ -45,4 +45,13 @@ .success { color: green; font-weight: bold; +} + +.jedchecker-info-message { + background-color: #D9EDF7; + border: 1px solid #BCE8F1; + color: #3A87AD; + margin: 5px; + padding: 5px; + list-style:none; } \ No newline at end of file