33
2
mirror of https://github.com/joomla-extensions/jedchecker.git synced 2024-11-15 09:44:20 +00:00
jedchecker/administrator/components/com_jedchecker/views/uploads/view.html.php

134 lines
2.9 KiB
PHP
Raw Normal View History

<?php
/**
2019-03-09 19:44:14 +00:00
* @package Joomla.JEDChecker
*
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
*/
defined('_JEXEC') or die('Restricted access');
2012-12-13 10:08:35 +00:00
jimport('joomla.application.component.viewlegacy');
2013-11-05 19:23:12 +00:00
/**
* Class JedcheckerViewUploads
*
* @since 1.0
*/
class JedcheckerViewUploads extends JViewLegacy
{
/** @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)
{
$this->path = JFactory::getConfig()->get('tmp_path') . '/jed_checker';
2019-03-09 19:44:14 +00:00
// Load translation for "JED Checker" title from sys.ini file
JFactory::getLanguage()->load('com_jedchecker.sys', JPATH_ADMINISTRATOR);
2013-11-05 19:23:12 +00:00
$this->setToolbar();
2016-05-25 16:19:19 +00:00
$this->jsOptions['url'] = JUri::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();
$files = JFolder::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/');
2013-11-05 19:23:12 +00:00
foreach ($files as $file)
{
$rule = substr($file, 0, -4);
2021-02-23 20:03:19 +00:00
$class = 'jedcheckerRules' . ucfirst($rule);
if (class_exists($class) && is_subclass_of($class, 'JEDcheckerRule'))
2021-02-23 20:03:19 +00:00
{
$rules[$rule] = $class::$ordering;
2021-02-23 20:03:19 +00:00
}
2013-11-05 19:23:12 +00:00
}
asort($rules, SORT_NUMERIC);
$rules = array_keys($rules);
2013-11-05 19:23:12 +00:00
return $rules;
}
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
{
2021-02-03 15:31:53 +00:00
JToolbarHelper::custom('check', 'search', 'search', JText::_('COM_JEDCHECKER_TOOLBAR_CHECK'), false);
2013-11-05 19:23:12 +00:00
}
JToolbarHelper::title(JText::_('COM_JEDCHECKER'));
if (file_exists($this->path))
2013-11-05 19:23:12 +00:00
{
2021-02-03 15:31:53 +00:00
JToolbarHelper::custom('uploads.clear', 'delete', 'delete', JText::_('COM_JEDCHECKER_TOOLBAR_CLEAR'), false);
2013-11-05 19:23:12 +00:00
}
2019-03-09 19:44:14 +00:00
if (JFactory::getUser()->authorise('core.admin', 'com_jedchecker'))
{
2016-05-25 16:19:19 +00:00
JToolbarHelper::preferences('com_jedchecker');
2016-02-15 23:20:06 +00:00
}
2013-11-05 19:23:12 +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
*
* @return boolean
2013-11-05 19:23:12 +00:00
*/
private function filesExist($type)
{
$path = JFactory::getConfig()->get('tmp_path') . '/jed_checker/' . $type;
2013-11-05 19:23:12 +00:00
if (JFolder::exists($path))
{
2021-02-13 20:13:27 +00:00
if (JFolder::folders($path) || JFolder::files($path))
2013-11-05 19:23:12 +00:00
{
return true;
}
}
else
{
$local = JFactory::getConfig()->get('tmp_path') . '/jed_checker/local.txt';
if ($type === 'unzipped' && JFile::exists($local))
2013-11-05 19:23:12 +00:00
{
return true;
}
}
2013-11-05 19:23:12 +00:00
return false;
}
}