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

66 lines
1.8 KiB
PHP
Raw Normal View History

<?php
/**
* @author Daniel Dimitrov - 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');
2012-12-13 10:08:35 +00:00
class jedcheckerViewUploads extends JViewLegacy
{
public function display($tpl = null)
{
$this->setToolbar();
$this->jsOptions['url'] = JURI::base();
$this->jsOptions['rules'] = $this->getRules();
parent::display($tpl);
}
public function getRules()
{
$rules = array();
$files = JFolder::files(JPATH_COMPONENT_ADMINISTRATOR . '/libraries/rules', '.php$', false, false);
JLoader::discover('jedcheckerRules',JPATH_COMPONENT_ADMINISTRATOR . '/libraries/rules/');
foreach ($files as $file)
{
$rules[] = substr($file, 0, -4);
}
return $rules;
}
public function setToolbar()
{
if($this->filesExist('archives')) {
JToolBarHelper::custom('uploads.unzip', 'unzip', 'unzip', 'unzip', false);
}
if($this->filesExist('unzipped')) {
JToolBarHelper::custom('police.check', 'police-check', 'police-check', 'check', false);
}
JToolBarHelper::title('JED checker');
}
/**
* Checks if folder + files exist in the jed_checker tmp path
* @param $type
* @return bool
*/
private function filesExist($type) {
$path = JFactory::getConfig()->get('tmp_path') . '/jed_checker/'.$type;
2012-12-13 10:08:35 +00:00
jimport('joomla.filesystem.folder');
if(JFolder::exists($path)) {
if(JFolder::folders($path, '.', false) || JFolder::files($path, '.', false)) {
return true;
}
}
return false;
}
}