first commit

This commit is contained in:
alazhar
2020-01-02 22:20:31 +07:00
commit 10eb3340ad
5753 changed files with 631345 additions and 0 deletions

View File

@ -0,0 +1,19 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_cache
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
if (!JFactory::getUser()->authorise('core.manage', 'com_cache'))
{
return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
}
$controller = JControllerLegacy::getInstance('Cache');
$controller->execute(JFactory::getApplication()->input->get('task'));
$controller->redirect();

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.1" method="upgrade">
<name>com_cache</name>
<author>Joomla! Project</author>
<creationDate>April 2006</creationDate>
<copyright>(C) 2005 - 2013 Open Source Matters. All rights reserved. </copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>COM_CACHE_XML_DESCRIPTION</description>
<administration>
<files folder="admin">
<filename>cache.php</filename>
<filename>config.xml</filename>
<filename>controller.php</filename>
<filename>index.html</filename>
<folder>models</folder>
<folder>views</folder>
</files>
<languages folder="admin">
<language tag="en-GB">language/en-GB.com_cache.ini</language>
<language tag="en-GB">language/en-GB.com_cache.sys.ini</language>
</languages>
</administration>
</extension>

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<config>
<fieldset
name="permissions"
label="JConfig_Permissions_Label"
description="JConfig_Permissions_Desc"
>
<field
name="rules"
type="rules"
label="JConfig_Permissions_Label"
filter="rules"
validate="rules"
component="com_config"
section="component">
<action
name="core.admin"
title="JAction_Admin"
description="JAction_Manage_Component_Desc" />
<action
name="core.manage"
title="JAction_Manage"
description="JAction_Manage_Component_Desc" />
</field>
</fieldset>
</config>

View File

@ -0,0 +1,106 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_cache
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Cache Controller
*
* @package Joomla.Administrator
* @subpackage com_cache
* @since 1.6
*/
class CacheController extends JControllerLegacy
{
/**
* @param boolean If true, the view output will be cached
* @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
*
* @return JController This object to support chaining.
* @since 1.5
*/
public function display($cachable = false, $urlparams = false)
{
require_once JPATH_COMPONENT.'/helpers/cache.php';
// Get the document object.
$document = JFactory::getDocument();
// Set the default view name and format from the Request.
$vName = $this->input->get('view', 'cache');
$vFormat = $document->getType();
$lName = $this->input->get('layout', 'default');
// Get and render the view.
if ($view = $this->getView($vName, $vFormat))
{
switch ($vName)
{
case 'purge':
break;
case 'cache':
default:
$model = $this->getModel($vName);
$view->setModel($model, true);
break;
}
$view->setLayout($lName);
// Push document object into the view.
$view->document = $document;
// Load the submenu.
CacheHelper::addSubmenu($this->input->get('view', 'cache'));
$view->display();
}
}
public function delete()
{
// Check for request forgeries
JSession::checkToken() or jexit(JText::_('JInvalid_Token'));
$cid = $this->input->post->get('cid', array(), 'array');
$model = $this->getModel('cache');
if (empty($cid))
{
JError::raiseWarning(500, JText::_('JERROR_NO_ITEMS_SELECTED'));
}
else
{
$model->cleanlist($cid);
}
$this->setRedirect('index.php?option=com_cache&client='.$model->getClient()->id);
}
public function purge()
{
// Check for request forgeries
JSession::checkToken() or jexit(JText::_('JInvalid_Token'));
$model = $this->getModel('cache');
$ret = $model->purge();
$msg = JText::_('COM_CACHE_EXPIRED_ITEMS_HAVE_BEEN_PURGED');
$msgType = 'message';
if ($ret === false)
{
$msg = JText::_('COM_CACHE_EXPIRED_ITEMS_PURGING_ERROR');
$msgType = 'error';
}
$this->setRedirect('index.php?option=com_cache&view=purge', $msg, $msgType);
}
}

View File

@ -0,0 +1,62 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_cache
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Cache component helper.
*
* @package Joomla.Administrator
* @subpackage com_cache
* @since 1.6
*/
class CacheHelper
{
/**
* Get a list of filter options for the application clients.
*
* @return array An array of JHtmlOption elements.
*/
public static function getClientOptions()
{
// Build the filter options.
$options = array();
$options[] = JHtml::_('select.option', '0', JText::_('JSITE'));
$options[] = JHtml::_('select.option', '1', JText::_('JADMINISTRATOR'));
return $options;
}
/**
* Configure the Linkbar.
*
* @param string The name of the active view.
*
* @return void
* @since 1.6
*/
public static function addSubmenu($vName)
{
JHtmlSidebar::addEntry(
JText::_('JGLOBAL_SUBMENU_CHECKIN'),
'index.php?option=com_checkin',
$vName == 'com_checkin'
);
JHtmlSidebar::addEntry(
JText::_('JGLOBAL_SUBMENU_CLEAR_CACHE'),
'index.php?option=com_cache',
$vName == 'cache'
);
JHtmlSidebar::addEntry(
JText::_('JGLOBAL_SUBMENU_PURGE_EXPIRED_CACHE'),
'index.php?option=com_cache&view=purge',
$vName == 'purge'
);
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,185 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_cache
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Cache Model
*
* @package Joomla.Administrator
* @subpackage com_cache
* @since 1.6
*/
class CacheModelCache extends JModelList
{
/**
* An Array of CacheItems indexed by cache group ID
*
* @var Array
*/
protected $_data = array();
/**
* Group total
*
* @var integer
*/
protected $_total = null;
/**
* Pagination object
*
* @var object
*/
protected $_pagination = null;
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
{
$clientId = $this->getUserStateFromRequest($this->context.'.filter.client_id', 'filter_client_id', 0, 'int');
$this->setState('clientId', $clientId == 1 ? 1 : 0);
$client = JApplicationHelper::getClientInfo($clientId);
$this->setState('client', $client);
parent::populateState('group', 'asc');
}
/**
* Method to get cache data
*
* @return array
*/
public function getData()
{
if (empty($this->_data))
{
$cache = $this->getCache();
$data = $cache->getAll();
if ($data != false)
{
$this->_data = $data;
$this->_total = count($data);
if ($this->_total)
{
// Apply custom ordering
$ordering = $this->getState('list.ordering');
$direction = ($this->getState('list.direction') == 'asc') ? 1 : -1;
jimport('joomla.utilities.arrayhelper');
$this->_data = JArrayHelper::sortObjects($data, $ordering, $direction);
// Apply custom pagination
if ($this->_total > $this->getState('list.limit') && $this->getState('list.limit'))
{
$this->_data = array_slice($this->_data, $this->getState('list.start'), $this->getState('list.limit'));
}
}
} else {
$this->_data = array();
}
}
return $this->_data;
}
/**
* Method to get cache instance
*
* @return object
*/
public function getCache()
{
$conf = JFactory::getConfig();
$options = array(
'defaultgroup' => '',
'storage' => $conf->get('cache_handler', ''),
'caching' => true,
'cachebase' => ($this->getState('clientId') == 1) ? JPATH_ADMINISTRATOR . '/cache' : $conf->get('cache_path', JPATH_SITE . '/cache')
);
$cache = JCache::getInstance('', $options);
return $cache;
}
/**
* Method to get client data
*
* @return array
*/
public function getClient()
{
return $this->getState('client');
}
/**
* Get the number of current Cache Groups
*
* @return int
*/
public function getTotal()
{
if (empty($this->_total))
{
$this->_total = count($this->getData());
}
return $this->_total;
}
/**
* Method to get a pagination object for the cache
*
* @return integer
*/
public function getPagination()
{
if (empty($this->_pagination))
{
$this->_pagination = new JPagination($this->getTotal(), $this->getState('list.start'), $this->getState('list.limit'));
}
return $this->_pagination;
}
/**
* Clean out a cache group as named by param.
* If no param is passed clean all cache groups.
*
* @param String $group
*/
public function clean($group = '')
{
$cache = $this->getCache();
$cache->clean($group);
}
public function cleanlist($array)
{
foreach ($array as $group)
{
$this->clean($group);
}
}
public function purge()
{
$cache = JFactory::getCache('');
return $cache->gc();
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,80 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_cache
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::_('formbehavior.chosen', 'select');
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
?>
<form action="<?php echo JRoute::_('index.php?option=com_cache'); ?>" method="post" name="adminForm" id="adminForm">
<?php if (!empty( $this->sidebar)) : ?>
<div id="j-sidebar-container" class="span2">
<?php echo $this->sidebar; ?>
</div>
<div id="j-main-container" class="span10">
<?php else : ?>
<div id="j-main-container">
<?php endif;?>
<table class="table table-striped">
<thead>
<tr>
<th width="20">
<?php echo JHtml::_('grid.checkall'); ?>
</th>
<th class="title nowrap">
<?php echo JHtml::_('grid.sort', 'COM_CACHE_GROUP', 'group', $listDirn, $listOrder); ?>
</th>
<th width="5%" class="center nowrap">
<?php echo JHtml::_('grid.sort', 'COM_CACHE_NUMBER_OF_FILES', 'count', $listDirn, $listOrder); ?>
</th>
<th width="10%" class="center">
<?php echo JHtml::_('grid.sort', 'COM_CACHE_SIZE', 'size', $listDirn, $listOrder); ?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="4">
<?php echo $this->pagination->getListFooter(); ?>
</td>
</tr>
</tfoot>
<tbody>
<?php
$i = 0;
foreach ($this->data as $folder => $item) : ?>
<tr class="row<?php echo $i % 2; ?>">
<td>
<input type="checkbox" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $item->group; ?>" onclick="Joomla.isChecked(this.checked);" />
</td>
<td>
<strong><?php echo $item->group; ?></strong>
</td>
<td class="center">
<?php echo $item->count; ?>
</td>
<td class="center">
<?php echo JHtml::_('number.bytes', $item->size*1024); ?>
</td>
</tr>
<?php $i++; endforeach; ?>
</tbody>
</table>
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="client" value="<?php echo $this->client->id;?>" />
<input type="hidden" name="filter_order" value="<?php echo $listOrder; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>" />
<?php echo JHtml::_('form.token'); ?>
</div>
</form>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,71 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_cache
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* HTML View class for the Cache component
*
* @package Joomla.Administrator
* @subpackage com_cache
* @since 1.6
*/
class CacheViewCache extends JViewLegacy
{
protected $client;
protected $data;
protected $pagination;
protected $state;
public function display($tpl = null)
{
$this->data = $this->get('Data');
$this->client = $this->get('Client');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
JError::raiseError(500, implode("\n", $errors));
return false;
}
$this->addToolbar();
$this->sidebar = JHtmlSidebar::render();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @since 1.6
*/
protected function addToolbar()
{
JToolbarHelper::title(JText::_('COM_CACHE_CLEAR_CACHE'), 'clear.png');
JToolbarHelper::custom('delete', 'delete.png', 'delete_f2.png', 'JTOOLBAR_DELETE', true);
JToolbarHelper::divider();
if (JFactory::getUser()->authorise('core.admin', 'com_cache'))
{
JToolbarHelper::preferences('com_cache');
}
JToolbarHelper::divider();
JToolbarHelper::help('JHELP_SITE_MAINTENANCE_CLEAR_CACHE');
JHtmlSidebar::setAction('index.php?option=com_cache');
JHtmlSidebar::addFilter(
// @todo We need an actual label here
'',
'filter_client_id',
JHtml::_('select.options', CacheHelper::getClientOptions(), 'value', 'text', $this->state->get('clientId'))
);
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,32 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_cache
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
?>
<form action="<?php echo JRoute::_('index.php?option=com_cache'); ?>" method="post" name="adminForm" id="adminForm">
<?php if (!empty( $this->sidebar)) : ?>
<div id="j-sidebar-container" class="span2">
<?php echo $this->sidebar; ?>
</div>
<div id="j-main-container" class="span10">
<?php else : ?>
<div id="j-main-container">
<?php endif;?>
<fieldset>
<legend><?php echo JText::_('COM_CACHE_PURGE_EXPIRED_ITEMS'); ?></legend>
<p><?php echo JText::_('COM_CACHE_PURGE_INSTRUCTIONS'); ?></p>
</fieldset>
<div class="alert">
<p><?php echo JText::_('COM_CACHE_RESOURCE_INTENSIVE_WARNING'); ?></p>
</div>
<input type="hidden" name="task" value="" />
<?php echo JHtml::_('form.token'); ?>
</div>
</form>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,47 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_cache
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* HTML View class for the Cache component
*
* @package Joomla.Administrator
* @subpackage com_cache
* @since 1.6
*/
class CacheViewPurge extends JViewLegacy
{
public function display($tpl = null)
{
$this->addToolbar();
$this->sidebar = JHtmlSidebar::render();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @since 1.6
*/
protected function addToolbar()
{
//JHtmlSidebar::addEntry(JText::_('COM_CACHE_BACK_CACHE_MANAGER'), 'index.php?option=com_cache', false);
JToolbarHelper::title(JText::_('COM_CACHE_PURGE_EXPIRED_CACHE'), 'purge.png');
JToolbarHelper::custom('purge', 'delete.png', 'delete_f2.png', 'COM_CACHE_PURGE_EXPIRED', false);
JToolbarHelper::divider();
if (JFactory::getUser()->authorise('core.admin', 'com_cache'))
{
JToolbarHelper::preferences('com_cache');
JToolbarHelper::divider();
}
JToolbarHelper::help('JHELP_SITE_MAINTENANCE_PURGE_EXPIRED_CACHE');
}
}