33
2
mirror of https://github.com/joomla-extensions/jedchecker.git synced 2025-04-10 14:41:50 +00:00
This commit is contained in:
Daniel Dimitrov 2013-11-05 20:23:12 +01:00
parent 6792e66b07
commit c49de3eeed

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* @author Daniel Dimitrov - compojoom.com * @author Daniel Dimitrov <daniel@compojoom.com>
* @date: 02.06.12 * @date 02.06.12
* *
* @copyright Copyright (C) 2008 - 2012 compojoom.com . All rights reserved. * @copyright Copyright (C) 2008 - 2012 compojoom.com . All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE * @license GNU General Public License version 2 or later; see LICENSE
@ -11,9 +11,20 @@ defined('_JEXEC') or die('Restricted access');
jimport('joomla.application.component.viewlegacy'); jimport('joomla.application.component.viewlegacy');
class jedcheckerViewUploads extends JViewLegacy /**
* Class JedcheckerViewUploads
*
* @since 1.0
*/
class JedcheckerViewUploads extends JViewLegacy
{ {
/**
* Display method
*
* @param string $tpl - the template
*
* @return mixed|void
*/
public function display($tpl = null) public function display($tpl = null)
{ {
$this->setToolbar(); $this->setToolbar();
@ -22,11 +33,16 @@ class jedcheckerViewUploads extends JViewLegacy
parent::display($tpl); parent::display($tpl);
} }
/**
* Get the component rules
*
* @return array
*/
public function getRules() public function getRules()
{ {
$rules = array(); $rules = array();
$files = JFolder::files(JPATH_COMPONENT_ADMINISTRATOR . '/libraries/rules', '.php$', false, false); $files = JFolder::files(JPATH_COMPONENT_ADMINISTRATOR . '/libraries/rules', '.php$', false, false);
JLoader::discover('jedcheckerRules',JPATH_COMPONENT_ADMINISTRATOR . '/libraries/rules/'); JLoader::discover('jedcheckerRules', JPATH_COMPONENT_ADMINISTRATOR . '/libraries/rules/');
foreach ($files as $file) foreach ($files as $file)
{ {
@ -36,12 +52,20 @@ class jedcheckerViewUploads extends JViewLegacy
return $rules; return $rules;
} }
/**
* Creates the toolbar options
*
* @return void
*/
public function setToolbar() public function setToolbar()
{ {
if($this->filesExist('archives')) { if ($this->filesExist('archives'))
{
JToolBarHelper::custom('uploads.unzip', 'unzip', 'unzip', 'unzip', false); JToolBarHelper::custom('uploads.unzip', 'unzip', 'unzip', 'unzip', false);
} }
if($this->filesExist('unzipped')) {
if ($this->filesExist('unzipped'))
{
JToolBarHelper::custom('police.check', 'police-check', 'police-check', 'Check', false); JToolBarHelper::custom('police.check', 'police-check', 'police-check', 'Check', false);
} }
@ -50,26 +74,32 @@ class jedcheckerViewUploads extends JViewLegacy
/** /**
* Checks if folder + files exist in the jed_checker tmp path * Checks if folder + files exist in the jed_checker tmp path
* @param $type *
* @param string $type - action
*
* @return bool * @return bool
*/ */
private function filesExist($type) private function filesExist($type)
{ {
$path = JFactory::getConfig()->get('tmp_path') . '/jed_checker/'.$type; $path = JFactory::getConfig()->get('tmp_path') . '/jed_checker/' . $type;
// Check for the existence of files if (JFolder::exists($path))
jimport('joomla.filesystem.folder'); {
if(JFolder::exists($path)) { if (JFolder::folders($path, '.', false) || JFolder::files($path, '.', false))
if(JFolder::folders($path, '.', false) || JFolder::files($path, '.', false)) { {
return true; return true;
} }
}
} else { else
{
$local = JFactory::getConfig()->get('tmp_path') . '/jed_checker/local.txt'; $local = JFactory::getConfig()->get('tmp_path') . '/jed_checker/local.txt';
if ($type == 'unzipped' && JFile::exists($local)) {
if ($type == 'unzipped' && JFile::exists($local))
{
return true; return true;
} }
} }
return false; return false;
} }
} }