33
2
mirror of https://github.com/joomla-extensions/jedchecker.git synced 2024-11-24 13:47:35 +00:00
jedchecker/source/administrator/components/com_jedchecker/views/uploads/view.html.php

111 lines
2.2 KiB
PHP
Raw Normal View History

<?php
/**
2013-11-05 19:23:12 +00:00
* @author Daniel Dimitrov <daniel@compojoom.com>
* @date 02.06.12
*
* @copyright Copyright (C) 2008 - 2012 compojoom.com . All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
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
{
2013-11-05 19:23:12 +00:00
/**
* Display method
*
* @param string $tpl - the template
*
* @return mixed|void
*/
public function display($tpl = null)
{
$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);
JLoader::discover('jedcheckerRules', JPATH_COMPONENT_ADMINISTRATOR . '/libraries/rules/');
2013-11-05 19:23:12 +00:00
foreach ($files as $file)
{
$rules[] = substr($file, 0, -4);
}
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()
{
if ($this->filesExist('archives'))
{
2016-05-25 16:19:19 +00:00
JToolbarHelper::custom('uploads.unzip', 'folder', 'folder', 'unzip', false);
2013-11-05 19:23:12 +00:00
}
2013-11-05 19:23:12 +00:00
if ($this->filesExist('unzipped'))
{
2016-05-25 16:19:19 +00:00
JToolbarHelper::custom('police.check', 'search', 'search', 'Check', false);
2013-11-05 19:23:12 +00:00
}
2016-05-25 16:19:19 +00:00
JToolbarHelper::title('JED checker');
2016-02-15 23:20:06 +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 bool
*/
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))
{
if (JFolder::folders($path, '.', false) || JFolder::files($path, '.', false))
{
return true;
}
}
else
{
$local = JFactory::getConfig()->get('tmp_path') . '/jed_checker/local.txt';
2013-11-05 19:23:12 +00:00
if ($type == 'unzipped' && JFile::exists($local))
{
return true;
}
}
2013-11-05 19:23:12 +00:00
return false;
}
}