33
2
mirror of https://github.com/joomla-extensions/jedchecker.git synced 2025-02-02 18:28:23 +00:00

Merge pull request #17 from cppl/CleanOldRules

Clean old rules
This commit is contained in:
Daniel Dimitrov 2013-11-11 01:16:42 -08:00
commit 0d8590e092
3 changed files with 61 additions and 2 deletions

View File

@ -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.

View File

@ -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 "<p>$msg</p>";
}
// 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 "<p>$msg</p>";
}
}
}
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);

View File

@ -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"
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."