31
2
mirror of https://github.com/joomla-extensions/jedchecker.git synced 2024-06-12 09:52:21 +00:00

Merge pull request #13 from yireo/master

Implemented tmp/jed_checker/local.txt file & updated docs
This commit is contained in:
Daniel Dimitrov 2013-04-11 04:02:10 -07:00
commit 02610e52c7
5 changed files with 109 additions and 22 deletions

16
README
View File

@ -1,16 +0,0 @@
JEDchecker
This extension is able to check your components, modules or plugins for common errors that will prevent you
from publishing your extension on the JED.
If you want to write a rule have a look a the library/rules folder.
You just need to add a new file with your rule. Example:
yourrule.php
"yourrule.php" needs to have a class jedcheckerRulesYourrule and that class needs to have a
function that accepts the basedir as parameter. This is all - the component will automatically call
your rule check function.
ZIP packages for installation in joomla can be found here:
https://compojoom.com/downloads/official-releases-stable/jedchecker

42
README.md Normal file
View File

@ -0,0 +1,42 @@
JEDchecker
==========
This extension is able to check your components, modules or plugins for common errors that will prevent you
from publishing your extension on the JED (Joomla! Extensions Directory).
Installing this extension
-------------------------
ZIP packages for installation in joomla can be found here:
https://compojoom.com/downloads/official-releases-stable/jedchecker
Alternatively, download the sources of this repository and use Phing to build the packages.
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.
Adding rules
------------
If you want to write a rule have a look a the `administrator/components/com_jedchecker/library/rules` folder.
You just need to add a new file with your rule, for example `yourrule.php`.
The file `yourrule.php` needs to have a class `jedcheckerRulesYourrule` and that class needs to have a
function that accepts the basedir as parameter. This is all - the component will automatically call
your rule check function.
Checking on existing files and folders
--------------------------------------
The extension also supports a scan of a pre-defined set of existing files and folders.
For this to work, add a list of folders to a textfile `tmp/jed_checker/local.txt`.
There should be a folder on each line.
Once the file exists, a "Check" button becomes visible in the jedchecker-toolbar. Just hit it.
Example `tmp/jed_checker/local.txt` file:
components/com_weblinks
administrator/components/com_weblinks
plugins/system

View File

@ -31,9 +31,19 @@ class jedcheckerControllerPolice extends JControllerlegacy
return false;
}
// Loop through each folder and police it
$folders = $this->getFolders();
foreach ($folders as $folder) {
$this->police($class, $folder);
}
return true;
}
protected function police($class, $folder)
{
// Prepare rule properties
$folders = JFolder::folders($path);
$properties = array('basedir' => $path.'/'.$folders[0]);
$properties = array('basedir' => $folder);
// Create instance of the rule
$police = new $class($properties);
@ -49,5 +59,45 @@ class jedcheckerControllerPolice extends JControllerlegacy
. ' - '. JText::_($police->get('title'))
. '</span><br/>'
. $report->getHTML();
flush();
ob_flush();
}
protected function getFolders()
{
$folders = array();
// Add the folders in the "jed_checked/unzipped" folder
$path = JFactory::getConfig()->get('tmp_path') . '/jed_checker/unzipped';
$tmp_folders = JFolder::folders($path);
if (!empty($tmp_folders)) {
foreach ($tmp_folders as $tmp_folder) {
$folders[] = $path.'/'.$tmp_folder;
}
}
// Parse the local.txt file and parse it
$local = JFactory::getConfig()->get('tmp_path') . '/jed_checker/local.txt';
if (JFile::exists($local)) {
$content = JFile::read($local);
if (!empty($content)) {
$lines = explode("\n", $content);
if (!empty($lines)) {
foreach ($lines as $line) {
$line = trim($line);
if (!empty($line)) {
if (JFolder::exists(JPATH_ROOT.'/'.$line)) {
$folders[] = JPATH_ROOT.'/'.$line;
} elseif (JFolder::exists($line)) {
$folders[] = $line;
}
}
}
}
}
}
return $folders;
}
}

View File

@ -88,6 +88,8 @@ class jedcheckerRulesHtmlindexes extends JEDcheckerRule
$path = $start;
} else if ($file->isDot()) {
continue;
} else if ($file->getFileName() == '.svn') {
continue;
}
$this->folders[$path] = true;
@ -106,4 +108,4 @@ class jedcheckerRulesHtmlindexes extends JEDcheckerRule
}
}
}
}
}

View File

@ -42,7 +42,7 @@ class jedcheckerViewUploads extends JViewLegacy
JToolBarHelper::custom('uploads.unzip', 'unzip', 'unzip', 'unzip', false);
}
if($this->filesExist('unzipped')) {
JToolBarHelper::custom('police.check', 'police-check', 'police-check', 'check', false);
JToolBarHelper::custom('police.check', 'police-check', 'police-check', 'Check', false);
}
JToolBarHelper::title('JED checker');
@ -53,14 +53,23 @@ class jedcheckerViewUploads extends JViewLegacy
* @param $type
* @return bool
*/
private function filesExist($type) {
private function filesExist($type)
{
$path = JFactory::getConfig()->get('tmp_path') . '/jed_checker/'.$type;
// Check for the existence of files
jimport('joomla.filesystem.folder');
if(JFolder::exists($path)) {
if(JFolder::folders($path, '.', false) || JFolder::files($path, '.', false)) {
return true;
}
} else {
$local = JFactory::getConfig()->get('tmp_path') . '/jed_checker/local.txt';
if ($type == 'unzipped' && JFile::exists($local)) {
return true;
}
}
return false;
}
}
}