2012-06-02 21:18:29 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2019-03-09 19:44:14 +00:00
|
|
|
* @package Joomla.JEDChecker
|
2012-06-02 21:18:29 +00:00
|
|
|
*
|
2019-03-10 16:09:42 +00:00
|
|
|
* @copyright Copyright (C) 2017 - 2019 Open Source Matters, Inc. All rights reserved.
|
|
|
|
* Copyright (C) 2008 - 2016 compojoom.com . All rights reserved.
|
2019-03-10 08:49:52 +00:00
|
|
|
* @author Daniel Dimitrov <daniel@compojoom.com>
|
|
|
|
*
|
2019-03-09 19:44:14 +00:00
|
|
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
2012-06-02 21:18:29 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
defined('_JEXEC') or die('Restricted access');
|
|
|
|
|
2023-08-13 09:22:27 +00:00
|
|
|
use Joomla\CMS\Factory;
|
|
|
|
use Joomla\CMS\Filesystem\File;
|
|
|
|
use Joomla\CMS\Filesystem\Folder;
|
|
|
|
use Joomla\CMS\Language\Text;
|
|
|
|
use Joomla\CMS\MVC\View\HtmlView;
|
|
|
|
use Joomla\CMS\Toolbar\ToolbarHelper;
|
|
|
|
use Joomla\CMS\Uri\Uri;
|
2012-06-02 21:18:29 +00:00
|
|
|
|
2013-11-05 19:23:12 +00:00
|
|
|
/**
|
|
|
|
* Class JedcheckerViewUploads
|
|
|
|
*
|
|
|
|
* @since 1.0
|
|
|
|
*/
|
2023-08-13 09:22:27 +00:00
|
|
|
class JedcheckerViewUploads extends HtmlView
|
2012-06-09 13:34:32 +00:00
|
|
|
{
|
2021-04-04 10:25:35 +00:00
|
|
|
/** @var string */
|
|
|
|
protected $path;
|
|
|
|
|
2021-02-23 20:03:19 +00:00
|
|
|
/** @var array */
|
|
|
|
protected $jsOptions;
|
|
|
|
|
2013-11-05 19:23:12 +00:00
|
|
|
/**
|
|
|
|
* Display method
|
|
|
|
*
|
|
|
|
* @param string $tpl - the template
|
|
|
|
*
|
|
|
|
* @return mixed|void
|
|
|
|
*/
|
|
|
|
public function display($tpl = null)
|
|
|
|
{
|
2023-08-13 09:22:27 +00:00
|
|
|
$this->path = Factory::getConfig()->get('tmp_path') . '/jed_checker';
|
2019-03-09 19:44:14 +00:00
|
|
|
|
2021-04-04 10:06:57 +00:00
|
|
|
// Load translation for "JED Checker" title from sys.ini file
|
2023-08-13 09:22:27 +00:00
|
|
|
Factory::getLanguage()->load('com_jedchecker.sys', JPATH_ADMINISTRATOR);
|
2021-04-04 10:06:57 +00:00
|
|
|
|
2013-11-05 19:23:12 +00:00
|
|
|
$this->setToolbar();
|
2023-08-13 09:22:27 +00:00
|
|
|
$this->jsOptions['url'] = Uri::base();
|
2013-11-05 19:23:12 +00:00
|
|
|
$this->jsOptions['rules'] = $this->getRules();
|
|
|
|
parent::display($tpl);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the component rules
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getRules()
|
|
|
|
{
|
|
|
|
$rules = array();
|
2023-08-13 09:22:27 +00:00
|
|
|
$files = Folder::files(JPATH_COMPONENT_ADMINISTRATOR . '/libraries/rules', '\.php$', false, false);
|
2021-02-23 20:03:19 +00:00
|
|
|
|
2013-11-05 19:23:12 +00:00
|
|
|
JLoader::discover('jedcheckerRules', JPATH_COMPONENT_ADMINISTRATOR . '/libraries/rules/');
|
2012-06-02 21:18:29 +00:00
|
|
|
|
2013-11-05 19:23:12 +00:00
|
|
|
foreach ($files as $file)
|
|
|
|
{
|
2021-05-17 20:21:34 +00:00
|
|
|
$rule = substr($file, 0, -4);
|
2021-02-23 20:03:19 +00:00
|
|
|
$class = 'jedcheckerRules' . ucfirst($rule);
|
|
|
|
|
2021-05-17 20:21:34 +00:00
|
|
|
if (class_exists($class) && is_subclass_of($class, 'JEDcheckerRule'))
|
2021-02-23 20:03:19 +00:00
|
|
|
{
|
2021-05-17 20:21:34 +00:00
|
|
|
$rules[$rule] = $class::$ordering;
|
2021-02-23 20:03:19 +00:00
|
|
|
}
|
2013-11-05 19:23:12 +00:00
|
|
|
}
|
2012-06-02 21:18:29 +00:00
|
|
|
|
2021-05-17 20:21:34 +00:00
|
|
|
asort($rules, SORT_NUMERIC);
|
|
|
|
$rules = array_keys($rules);
|
|
|
|
|
2013-11-05 19:23:12 +00:00
|
|
|
return $rules;
|
|
|
|
}
|
2012-07-06 23:45:06 +00:00
|
|
|
|
2013-11-05 19:23:12 +00:00
|
|
|
/**
|
|
|
|
* Creates the toolbar options
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function setToolbar()
|
|
|
|
{
|
2019-03-09 19:44:14 +00:00
|
|
|
if ($this->filesExist('unzipped'))
|
2013-11-05 19:23:12 +00:00
|
|
|
{
|
2023-08-13 09:22:27 +00:00
|
|
|
ToolbarHelper::custom('check', 'search', 'search', Text::_('COM_JEDCHECKER_TOOLBAR_CHECK'), false);
|
2013-11-05 19:23:12 +00:00
|
|
|
}
|
2012-07-06 23:45:06 +00:00
|
|
|
|
2023-08-13 09:22:27 +00:00
|
|
|
ToolbarHelper::title(Text::_('COM_JEDCHECKER'));
|
2021-04-04 10:25:35 +00:00
|
|
|
|
|
|
|
if (file_exists($this->path))
|
2013-11-05 19:23:12 +00:00
|
|
|
{
|
2023-08-13 09:22:27 +00:00
|
|
|
ToolbarHelper::custom('uploads.clear', 'delete', 'delete', Text::_('COM_JEDCHECKER_TOOLBAR_CLEAR'), false);
|
2013-11-05 19:23:12 +00:00
|
|
|
}
|
2012-06-09 13:34:32 +00:00
|
|
|
|
2023-08-13 09:22:27 +00:00
|
|
|
if (Factory::getUser()->authorise('core.admin', 'com_jedchecker'))
|
2019-03-09 19:44:14 +00:00
|
|
|
{
|
2023-08-13 09:22:27 +00:00
|
|
|
ToolbarHelper::preferences('com_jedchecker');
|
2016-02-15 23:20:06 +00:00
|
|
|
}
|
2013-11-05 19:23:12 +00:00
|
|
|
}
|
2012-06-24 07:50:50 +00:00
|
|
|
|
2013-11-05 19:23:12 +00:00
|
|
|
/**
|
|
|
|
* Checks if folder + files exist in the jed_checker tmp path
|
|
|
|
*
|
|
|
|
* @param string $type - action
|
|
|
|
*
|
2021-04-04 10:25:35 +00:00
|
|
|
* @return boolean
|
2013-11-05 19:23:12 +00:00
|
|
|
*/
|
|
|
|
private function filesExist($type)
|
|
|
|
{
|
2023-08-13 09:22:27 +00:00
|
|
|
$path = Factory::getConfig()->get('tmp_path') . '/jed_checker/' . $type;
|
2012-06-24 07:50:50 +00:00
|
|
|
|
2023-08-13 09:22:27 +00:00
|
|
|
if (Folder::exists($path))
|
2013-11-05 19:23:12 +00:00
|
|
|
{
|
2023-08-13 09:22:27 +00:00
|
|
|
if (Folder::folders($path) || Folder::files($path))
|
2013-11-05 19:23:12 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-08-13 09:22:27 +00:00
|
|
|
$local = Factory::getConfig()->get('tmp_path') . '/jed_checker/local.txt';
|
2013-02-12 09:04:49 +00:00
|
|
|
|
2023-08-13 09:22:27 +00:00
|
|
|
if ($type === 'unzipped' && File::exists($local))
|
2013-11-05 19:23:12 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2013-02-12 09:04:49 +00:00
|
|
|
|
2013-11-05 19:23:12 +00:00
|
|
|
return false;
|
|
|
|
}
|
2013-02-12 09:04:49 +00:00
|
|
|
}
|