diff --git a/README.md b/README.md index d2a156f..53eaba2 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,13 @@ You will also need the following path structure on your system - com_jedchecker - This repository - buildtools - Compojoom build tools (https://github.com/compojoom/buildtools) +To execute the build, copy `com_jedchecker/builds/build.properties.txt` renaming it without the `.txt` suffix. + +Then in your command line navigate to the `builds` directory and run `phing` + + cd com_jedchecker/builds/ + phing + ## Uploading your package After installing this extension in your Joomla! backend, you can use it by uploading a Joomla! extension-package using the upload-button. Once uploaded, the contents of the package (your files) will be checked against JED-rules. diff --git a/source/administrator/components/com_jedchecker/script.php b/source/administrator/components/com_jedchecker/script.php index 68833ec..bfbd73c 100644 --- a/source/administrator/components/com_jedchecker/script.php +++ b/source/administrator/components/com_jedchecker/script.php @@ -23,11 +23,59 @@ class com_jedcheckerInstallerScript } } + /** + * Update cleans out any old rules. + * + * @param JInstallerComponent $parent Is the class calling this method. + * + * @return bool|null If this returns false, Joomla will abort the update and undo everything already done. + */ + public function update($parent) + { + $this->loadLanguage(); + + // Doing it this way in case there are other old rules to be deleted + $oldRules = array('htmlindexes'); + + foreach ($oldRules as $rule) + { + $rulePhpFile = JPATH_ADMINISTRATOR . '/components/' . $this->extension . '/libraries/rules/' . $rule . '.php'; + $ruleIniFile = JPATH_ADMINISTRATOR . '/components/' . $this->extension . '/libraries/rules/' . $rule . '.ini'; + + // Remove the rule's php file + if(file_exists($rulePhpFile)) + { + if(JFile::delete($rulePhpFile)) + { + $msg = JText::sprintf('COM_JEDCHECKER_OLD_RULE_X_PHP_FILE_REMOVED', $rule); + } + else + { + $msg = JText::sprintf('COM_JEDCHECKER_OLD_RULE_X_PHP_FILE_NOT_REMOVED', $rule); + } + echo "
$msg
"; + } + + // Remove the rule's ini file + if(file_exists($ruleIniFile)) + { + if(JFile::delete($ruleIniFile)) + { + $msg = JText::sprintf('COM_JEDCHECKER_OLD_RULE_X_INI_FILE_REMOVED', $rule); + } + else + { + $msg = JText::sprintf('COM_JEDCHECKER_OLD_RULE_X_INI_FILE_NOT_REMOVED', $rule); + } + echo "$msg
"; + } + } + } public function loadLanguage() { $extension = $this->extension; - $jlang =& JFactory::getLanguage(); + $jlang = JFactory::getLanguage(); $path = $this->parent->getParent()->getPath('source') . '/administrator'; $jlang->load($extension, $path, 'en-GB', true); $jlang->load($extension, $path, $jlang->getDefault(), true); 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 66d3c65..ba58e3e 100644 --- a/source/administrator/language/en-GB/en-GB.com_jedchecker.ini +++ b/source/administrator/language/en-GB/en-GB.com_jedchecker.ini @@ -44,4 +44,8 @@ COM_JEDCHECKER_RULE_PH1_DESC="A notice is required on each PHP file stating that COM_JEDCHECKER_ERROR_GPL_NOT_FOUND="GPL or compatible license was not found" COM_JEDCHECKER_PH1_LICENSE_FOUND="GPL license was found" COM_JEDCHECKER_GPL_COMPATIBLE_LICENSE_WAS_FOUND="GPL compatible license was found" -COM_JEDCHECKER_WARNING="Warning" \ No newline at end of file +COM_JEDCHECKER_WARNING="Warning" +COM_JEDCHECKER_OLD_RULE_X_INI_FILE_NOT_REMOVED="'ini' file for '%s' rule could not be removed, manual removal recommended." +COM_JEDCHECKER_OLD_RULE_X_PHP_FILE_NOT_REMOVED="PHP file for '%s' rule could not be removed, manual removal recommended." +COM_JEDCHECKER_OLD_RULE_X_PHP_FILE_REMOVED="Removed PHP file for '%s' rule." +COM_JEDCHECKER_OLD_RULE_X_INI_FILE_REMOVED="Removed 'ini' file for '%s' rule." \ No newline at end of file