first commit
This commit is contained in:
7
administrator/components/com_cache/access.xml
Normal file
7
administrator/components/com_cache/access.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<access component="com_cache">
|
||||
<section name="component">
|
||||
<action name="core.admin" title="JACTION_ADMIN" />
|
||||
<action name="core.manage" title="JACTION_MANAGE" />
|
||||
</section>
|
||||
</access>
|
||||
32
administrator/components/com_cache/cache.xml
Normal file
32
administrator/components/com_cache/cache.xml
Normal file
@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="component" method="upgrade">
|
||||
<name>com_cache</name>
|
||||
<author>Joomla! Project</author>
|
||||
<creationDate>2006-04</creationDate>
|
||||
<copyright>(C) 2006 Open Source Matters, Inc.</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>4.0.0</version>
|
||||
<description>COM_CACHE_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Component\Cache</namespace>
|
||||
<media destination="com_cache" folder="media">
|
||||
<folder>js</folder>
|
||||
</media>
|
||||
<administration>
|
||||
<files folder="admin">
|
||||
<filename>access.xml</filename>
|
||||
<filename>cache.xml</filename>
|
||||
<filename>config.xml</filename>
|
||||
<folder>forms</folder>
|
||||
<folder>services</folder>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</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>
|
||||
|
||||
18
administrator/components/com_cache/config.xml
Normal file
18
administrator/components/com_cache/config.xml
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<config>
|
||||
<help key="Cache:_Options"/>
|
||||
<fieldset
|
||||
name="permissions"
|
||||
label="JCONFIG_PERMISSIONS_LABEL"
|
||||
>
|
||||
<field
|
||||
name="rules"
|
||||
type="rules"
|
||||
label="JCONFIG_PERMISSIONS_LABEL"
|
||||
filter="rules"
|
||||
validate="rules"
|
||||
component="com_cache"
|
||||
section="component"
|
||||
/>
|
||||
</fieldset>
|
||||
</config>
|
||||
39
administrator/components/com_cache/forms/filter_cache.xml
Normal file
39
administrator/components/com_cache/forms/filter_cache.xml
Normal file
@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<fields name="filter">
|
||||
<field
|
||||
name="search"
|
||||
type="text"
|
||||
inputmode="search"
|
||||
label="COM_CACHE_FILTER_SEARCH_LABEL"
|
||||
description="COM_CACHE_FILTER_SEARCH_DESC"
|
||||
hint="JSEARCH_FILTER"
|
||||
noresults="JGLOBAL_NO_MATCHING_RESULTS"
|
||||
/>
|
||||
</fields>
|
||||
<fields name="list">
|
||||
<field
|
||||
name="fullordering"
|
||||
type="list"
|
||||
label="JGLOBAL_SORT_BY"
|
||||
class="js-select-submit-on-change"
|
||||
default="group ASC"
|
||||
validate="options"
|
||||
>
|
||||
<option value="">JGLOBAL_SORT_BY</option>
|
||||
<option value="group ASC">COM_CACHE_HEADING_GROUP_ASC</option>
|
||||
<option value="group DESC">COM_CACHE_HEADING_GROUP_DESC</option>
|
||||
<option value="count ASC">COM_CACHE_HEADING_COUNT_ASC</option>
|
||||
<option value="count DESC">COM_CACHE_HEADING_COUNT_DESC</option>
|
||||
<option value="size ASC">COM_CACHE_HEADING_SIZE_ASC</option>
|
||||
<option value="size DESC">COM_CACHE_HEADING_SIZE_DESC</option>
|
||||
</field>
|
||||
<field
|
||||
name="limit"
|
||||
type="limitbox"
|
||||
label="JGLOBAL_LIST_LIMIT"
|
||||
default="25"
|
||||
class="js-select-submit-on-change"
|
||||
/>
|
||||
</fields>
|
||||
</form>
|
||||
53
administrator/components/com_cache/services/provider.php
Normal file
53
administrator/components/com_cache/services/provider.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_cache
|
||||
*
|
||||
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Dispatcher\ComponentDispatcherFactoryInterface;
|
||||
use Joomla\CMS\Extension\ComponentInterface;
|
||||
use Joomla\CMS\Extension\MVCComponent;
|
||||
use Joomla\CMS\Extension\Service\Provider\ComponentDispatcherFactory;
|
||||
use Joomla\CMS\Extension\Service\Provider\MVCFactory;
|
||||
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* The cache service provider.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
return new class () implements ServiceProviderInterface {
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->registerServiceProvider(new MVCFactory('\\Joomla\\Component\\Cache'));
|
||||
$container->registerServiceProvider(new ComponentDispatcherFactory('\\Joomla\\Component\\Cache'));
|
||||
|
||||
$container->set(
|
||||
ComponentInterface::class,
|
||||
function (Container $container) {
|
||||
$component = new MVCComponent($container->get(ComponentDispatcherFactoryInterface::class));
|
||||
|
||||
$component->setMVCFactory($container->get(MVCFactoryInterface::class));
|
||||
|
||||
return $component;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,157 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_cache
|
||||
*
|
||||
* @copyright (C) 2008 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Cache\Administrator\Controller;
|
||||
|
||||
use Joomla\CMS\Event\Cache\AfterPurgeEvent;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\Controller\BaseController;
|
||||
use Joomla\CMS\Response\JsonResponse;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Cache Controller
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class DisplayController extends BaseController
|
||||
{
|
||||
/**
|
||||
* The default view for the display method.
|
||||
*
|
||||
* @var string
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $default_view = 'cache';
|
||||
|
||||
/**
|
||||
* Method to get The Cache Size
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function getQuickiconContent()
|
||||
{
|
||||
$model = $this->getModel('Cache');
|
||||
|
||||
$data = $model->getData();
|
||||
|
||||
$size = 0;
|
||||
|
||||
if (!empty($data)) {
|
||||
foreach ($data as $d) {
|
||||
$size += $d->size;
|
||||
}
|
||||
}
|
||||
|
||||
// Number bytes are returned in format xxx.xx MB
|
||||
$bytes = HTMLHelper::_('number.bytes', $size, 'MB', 1);
|
||||
|
||||
if (!empty($bytes)) {
|
||||
$result['amount'] = $bytes;
|
||||
$result['sronly'] = Text::sprintf('COM_CACHE_QUICKICON_SRONLY', $bytes);
|
||||
} else {
|
||||
$result['amount'] = 0;
|
||||
$result['sronly'] = Text::sprintf('COM_CACHE_QUICKICON_SRONLY_NOCACHE');
|
||||
}
|
||||
|
||||
echo new JsonResponse($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to delete a list of cache groups.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
// Check for request forgeries
|
||||
$this->checkToken();
|
||||
|
||||
$cid = (array) $this->input->post->get('cid', [], 'string');
|
||||
|
||||
if (empty($cid)) {
|
||||
$this->app->enqueueMessage(Text::_('JERROR_NO_ITEMS_SELECTED'), 'warning');
|
||||
} else {
|
||||
$result = $this->getModel('cache')->cleanlist($cid);
|
||||
|
||||
if ($result !== []) {
|
||||
$this->app->enqueueMessage(Text::sprintf('COM_CACHE_EXPIRED_ITEMS_DELETE_ERROR', implode(', ', $result)), 'error');
|
||||
} else {
|
||||
$this->app->enqueueMessage(Text::_('COM_CACHE_EXPIRED_ITEMS_HAVE_BEEN_DELETED'), 'message');
|
||||
}
|
||||
}
|
||||
|
||||
$this->setRedirect('index.php?option=com_cache');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to delete all cache groups.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.6.0
|
||||
*/
|
||||
public function deleteAll()
|
||||
{
|
||||
// Check for request forgeries
|
||||
$this->checkToken();
|
||||
|
||||
/** @var \Joomla\Component\Cache\Administrator\Model\CacheModel $model */
|
||||
$model = $this->getModel('cache');
|
||||
$allCleared = true;
|
||||
|
||||
$mCache = $model->getCache();
|
||||
|
||||
foreach ($mCache->getAll() as $cache) {
|
||||
if ($mCache->clean($cache->group) === false) {
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf(
|
||||
'COM_CACHE_EXPIRED_ITEMS_DELETE_ERROR',
|
||||
Text::_('JADMINISTRATOR') . ' > ' . $cache->group
|
||||
),
|
||||
'error'
|
||||
);
|
||||
$allCleared = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($allCleared) {
|
||||
$this->app->enqueueMessage(Text::_('COM_CACHE_MSG_ALL_CACHE_GROUPS_CLEARED'), 'message');
|
||||
} else {
|
||||
$this->app->enqueueMessage(Text::_('COM_CACHE_MSG_SOME_CACHE_GROUPS_CLEARED'), 'warning');
|
||||
}
|
||||
|
||||
$this->getDispatcher()->dispatch('onAfterPurge', new AfterPurgeEvent('onAfterPurge'));
|
||||
$this->setRedirect('index.php?option=com_cache&view=cache');
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge the cache.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function purge()
|
||||
{
|
||||
// Check for request forgeries
|
||||
$this->checkToken();
|
||||
|
||||
if (!$this->getModel('cache')->purge()) {
|
||||
$this->app->enqueueMessage(Text::_('COM_CACHE_EXPIRED_ITEMS_PURGING_ERROR'), 'error');
|
||||
} else {
|
||||
$this->app->enqueueMessage(Text::_('COM_CACHE_EXPIRED_ITEMS_HAVE_BEEN_PURGED'), 'message');
|
||||
}
|
||||
|
||||
$this->setRedirect('index.php?option=com_cache&view=cache');
|
||||
}
|
||||
}
|
||||
278
administrator/components/com_cache/src/Model/CacheModel.php
Normal file
278
administrator/components/com_cache/src/Model/CacheModel.php
Normal file
@ -0,0 +1,278 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_cache
|
||||
*
|
||||
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Cache\Administrator\Model;
|
||||
|
||||
use Joomla\CMS\Cache\Cache;
|
||||
use Joomla\CMS\Cache\CacheController;
|
||||
use Joomla\CMS\Cache\Exception\CacheConnectingException;
|
||||
use Joomla\CMS\Cache\Exception\UnsupportedCacheException;
|
||||
use Joomla\CMS\Event\Cache\AfterPurgeEvent;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\Model\ListModel;
|
||||
use Joomla\CMS\Pagination\Pagination;
|
||||
use Joomla\Utilities\ArrayHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Cache Model
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class CacheModel extends ListModel
|
||||
{
|
||||
/**
|
||||
* An Array of CacheItems indexed by cache group ID
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_data = [];
|
||||
|
||||
/**
|
||||
* Group total
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $_total = null;
|
||||
|
||||
/**
|
||||
* Pagination object
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $_pagination = null;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $config An optional associative array of configuration settings.
|
||||
*
|
||||
* @since 3.5
|
||||
*/
|
||||
public function __construct($config = [])
|
||||
{
|
||||
if (empty($config['filter_fields'])) {
|
||||
$config['filter_fields'] = [
|
||||
'group',
|
||||
'count',
|
||||
'size',
|
||||
'client_id',
|
||||
];
|
||||
}
|
||||
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
* Note. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @param string $ordering Field for ordering.
|
||||
* @param string $direction Direction of ordering.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function populateState($ordering = 'group', $direction = 'asc')
|
||||
{
|
||||
// Load the filter state.
|
||||
$this->setState('filter.search', $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '', 'string'));
|
||||
|
||||
parent::populateState($ordering, $direction);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a store id based on model configuration state.
|
||||
*
|
||||
* This is necessary because the model is used by the component and
|
||||
* different modules that might need different sets of data or different
|
||||
* ordering requirements.
|
||||
*
|
||||
* @param string $id A prefix for the store id.
|
||||
*
|
||||
* @return string A store id.
|
||||
*
|
||||
* @since 3.5
|
||||
*/
|
||||
protected function getStoreId($id = '')
|
||||
{
|
||||
// Compile the store id.
|
||||
$id .= ':' . $this->getState('filter.search');
|
||||
|
||||
return parent::getStoreId($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get cache data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
if (empty($this->_data)) {
|
||||
try {
|
||||
$cache = $this->getCache();
|
||||
$data = $cache->getAll();
|
||||
|
||||
if ($data && \count($data) > 0) {
|
||||
// Process filter by search term.
|
||||
if ($search = $this->getState('filter.search')) {
|
||||
foreach ($data as $key => $cacheItem) {
|
||||
if (stripos($cacheItem->group, $search) === false) {
|
||||
unset($data[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Process ordering.
|
||||
$listOrder = $this->getState('list.ordering', 'group');
|
||||
$listDirn = $this->getState('list.direction', 'ASC');
|
||||
|
||||
$this->_data = ArrayHelper::sortObjects($data, $listOrder, strtolower($listDirn) === 'desc' ? -1 : 1, true, true);
|
||||
|
||||
// Process pagination.
|
||||
$limit = (int) $this->getState('list.limit', 25);
|
||||
|
||||
if ($limit !== 0) {
|
||||
$start = (int) $this->getState('list.start', 0);
|
||||
|
||||
return \array_slice($this->_data, $start, $limit);
|
||||
}
|
||||
} else {
|
||||
$this->_data = [];
|
||||
}
|
||||
} catch (CacheConnectingException $exception) {
|
||||
$this->setError(Text::_('COM_CACHE_ERROR_CACHE_CONNECTION_FAILED'));
|
||||
$this->_data = [];
|
||||
} catch (UnsupportedCacheException $exception) {
|
||||
$this->setError(Text::_('COM_CACHE_ERROR_CACHE_DRIVER_UNSUPPORTED'));
|
||||
$this->_data = [];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get cache instance.
|
||||
*
|
||||
* @return CacheController
|
||||
*/
|
||||
public function getCache()
|
||||
{
|
||||
$app = Factory::getApplication();
|
||||
|
||||
$options = [
|
||||
'defaultgroup' => '',
|
||||
'storage' => $app->get('cache_handler', ''),
|
||||
'caching' => true,
|
||||
'cachebase' => $app->get('cache_path', JPATH_CACHE),
|
||||
];
|
||||
|
||||
return Cache::getInstance('', $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of current Cache Groups.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
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 Pagination
|
||||
*/
|
||||
public function getPagination()
|
||||
{
|
||||
if (empty($this->_pagination)) {
|
||||
$this->_pagination = new Pagination($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 Cache group name.
|
||||
*
|
||||
* @return boolean True on success, false otherwise
|
||||
*/
|
||||
public function clean($group = '')
|
||||
{
|
||||
try {
|
||||
$this->getCache()->clean($group);
|
||||
} catch (CacheConnectingException $exception) {
|
||||
return false;
|
||||
} catch (UnsupportedCacheException $exception) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->getDispatcher()->dispatch('onAfterPurge', new AfterPurgeEvent('onAfterPurge', ['subject' => $group]));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge an array of cache groups.
|
||||
*
|
||||
* @param array $array Array of cache group names.
|
||||
*
|
||||
* @return array Array with errors, if they exist.
|
||||
*/
|
||||
public function cleanlist($array)
|
||||
{
|
||||
$errors = [];
|
||||
|
||||
foreach ($array as $group) {
|
||||
if (!$this->clean($group)) {
|
||||
$errors[] = $group;
|
||||
}
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge all cache items.
|
||||
*
|
||||
* @return boolean True if successful; false otherwise.
|
||||
*/
|
||||
public function purge()
|
||||
{
|
||||
try {
|
||||
Factory::getCache('')->gc();
|
||||
} catch (CacheConnectingException $exception) {
|
||||
return false;
|
||||
} catch (UnsupportedCacheException $exception) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->getDispatcher()->dispatch('onAfterPurge', new AfterPurgeEvent('onAfterPurge'));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
154
administrator/components/com_cache/src/View/Cache/HtmlView.php
Normal file
154
administrator/components/com_cache/src/View/Cache/HtmlView.php
Normal file
@ -0,0 +1,154 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_cache
|
||||
*
|
||||
* @copyright (C) 2008 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Cache\Administrator\View\Cache;
|
||||
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\View\GenericDataException;
|
||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||||
use Joomla\CMS\Pagination\Pagination;
|
||||
use Joomla\CMS\Toolbar\Toolbar;
|
||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
||||
use Joomla\Component\Cache\Administrator\Model\CacheModel;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* HTML View class for the Cache component
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class HtmlView extends BaseHtmlView
|
||||
{
|
||||
/**
|
||||
* The search tools form
|
||||
*
|
||||
* @var Form
|
||||
* @since 1.6
|
||||
*/
|
||||
public $filterForm;
|
||||
|
||||
/**
|
||||
* The active search filters
|
||||
*
|
||||
* @var array
|
||||
* @since 1.6
|
||||
*/
|
||||
public $activeFilters = [];
|
||||
|
||||
/**
|
||||
* The cache data
|
||||
*
|
||||
* @var array
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $data = [];
|
||||
|
||||
/**
|
||||
* The pagination object
|
||||
*
|
||||
* @var Pagination
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $pagination;
|
||||
|
||||
/**
|
||||
* Total number of cache groups
|
||||
*
|
||||
* @var integer
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $total = 0;
|
||||
|
||||
/**
|
||||
* The model state
|
||||
*
|
||||
* @var \Joomla\Registry\Registry
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* Display a view.
|
||||
*
|
||||
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*
|
||||
* @throws GenericDataException
|
||||
*/
|
||||
public function display($tpl = null): void
|
||||
{
|
||||
/** @var CacheModel $model */
|
||||
$model = $this->getModel();
|
||||
$this->data = $model->getData();
|
||||
$this->pagination = $model->getPagination();
|
||||
$this->total = $model->getTotal();
|
||||
$this->state = $model->getState();
|
||||
$this->filterForm = $model->getFilterForm();
|
||||
$this->activeFilters = $model->getActiveFilters();
|
||||
|
||||
// Check for errors.
|
||||
if (\count($errors = $this->get('Errors'))) {
|
||||
throw new GenericDataException(implode("\n", $errors), 500);
|
||||
}
|
||||
|
||||
if (!\count($this->data) && $this->state->get('filter.search') === '') {
|
||||
$this->setLayout('emptystate');
|
||||
}
|
||||
|
||||
$this->addToolbar();
|
||||
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the page title and toolbar.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function addToolbar(): void
|
||||
{
|
||||
ToolbarHelper::title(Text::_('COM_CACHE_CLEAR_CACHE'), 'bolt clear');
|
||||
|
||||
// Get the toolbar object instance
|
||||
$toolbar = Toolbar::getInstance('toolbar');
|
||||
|
||||
if (\count($this->data)) {
|
||||
$toolbar->delete('delete')
|
||||
->listCheck(true);
|
||||
|
||||
$toolbar->confirmButton('delete', 'JTOOLBAR_DELETE_ALL', 'deleteAll')
|
||||
->icon('icon-remove')
|
||||
->listCheck(false)
|
||||
->buttonClass('button-remove btn btn-primary');
|
||||
|
||||
$toolbar->confirmButton('delete', 'COM_CACHE_PURGE_EXPIRED', 'purge')
|
||||
->name('delete')
|
||||
->message('COM_CACHE_RESOURCE_INTENSIVE_WARNING');
|
||||
|
||||
$toolbar->divider();
|
||||
}
|
||||
|
||||
if ($this->getCurrentUser()->authorise('core.admin', 'com_cache')) {
|
||||
$toolbar->preferences('com_cache');
|
||||
$toolbar->divider();
|
||||
}
|
||||
|
||||
$toolbar->help('Maintenance:_Clear_Cache');
|
||||
}
|
||||
}
|
||||
101
administrator/components/com_cache/tmpl/cache/default.php
vendored
Normal file
101
administrator/components/com_cache/tmpl/cache/default.php
vendored
Normal file
@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_cache
|
||||
*
|
||||
* @copyright (C) 2008 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use Joomla\CMS\Router\Route;
|
||||
|
||||
/** @var \Joomla\Component\Cache\Administrator\View\Cache\HtmlView $this */
|
||||
|
||||
$listOrder = $this->escape($this->state->get('list.ordering'));
|
||||
$listDirn = $this->escape($this->state->get('list.direction'));
|
||||
|
||||
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
|
||||
$wa = $this->document->getWebAssetManager();
|
||||
$wa->useScript('keepalive')
|
||||
->useScript('table.columns')
|
||||
->useScript('multiselect')
|
||||
->useScript('com_cache.admin-cache');
|
||||
|
||||
?>
|
||||
<form action="<?php echo Route::_('index.php?option=com_cache'); ?>" method="post" name="adminForm" id="adminForm">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div id="j-main-container" class="j-main-container">
|
||||
<div class="alert alert-info">
|
||||
<span class="icon-info-circle" aria-hidden="true"></span>
|
||||
<span class="visually-hidden"><?php echo Text::_('INFO'); ?></span>
|
||||
<?php echo Text::_('COM_CACHE_PURGE_INSTRUCTIONS'); ?>
|
||||
</div>
|
||||
<?php echo LayoutHelper::render('joomla.searchtools.default', ['view' => $this]); ?>
|
||||
<?php if (!$this->data) : ?>
|
||||
<div class="alert alert-info">
|
||||
<span class="icon-info-circle" aria-hidden="true"></span><span class="visually-hidden"><?php echo Text::_('INFO'); ?></span>
|
||||
<?php echo Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<table class="table">
|
||||
<caption class="visually-hidden">
|
||||
<?php echo Text::_('COM_CACHE_TABLE_CAPTION'); ?>,
|
||||
<span id="orderedBy"><?php echo Text::_('JGLOBAL_SORTED_BY'); ?> </span>,
|
||||
<span id="filteredBy"><?php echo Text::_('JGLOBAL_FILTERED_BY'); ?></span>
|
||||
</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="w-1 text-center">
|
||||
<?php echo HTMLHelper::_('grid.checkall'); ?>
|
||||
</td>
|
||||
<th scope="col" class="title">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'COM_CACHE_GROUP', 'group', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th scope="col" class="w-10 text-center">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'COM_CACHE_NUMBER_OF_FILES', 'count', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th scope="col" class="w-10 text-end">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'COM_CACHE_SIZE', 'size', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php $i = 0; ?>
|
||||
<?php foreach ($this->data as $folder => $item) : ?>
|
||||
<tr class="row<?php echo $i % 2; ?>">
|
||||
<td>
|
||||
<?php echo HTMLHelper::_('grid.id', $i, $item->group, false, 'cid', 'cb', $item->group); ?>
|
||||
</td>
|
||||
<th scope="row">
|
||||
<?php echo $this->escape($item->group); ?>
|
||||
</th>
|
||||
<td class="text-center">
|
||||
<?php echo $item->count; ?>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<?php echo '‎' . HTMLHelper::_('number.bytes', $item->size); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php $i++; ?>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php // Load the pagination. ?>
|
||||
<?php echo $this->pagination->getListFooter(); ?>
|
||||
|
||||
<?php endif; ?>
|
||||
<input type="hidden" name="task" value="">
|
||||
<input type="hidden" name="boxchecked" value="0">
|
||||
<?php echo HTMLHelper::_('form.token'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
8
administrator/components/com_cache/tmpl/cache/default.xml
vendored
Normal file
8
administrator/components/com_cache/tmpl/cache/default.xml
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata>
|
||||
<layout title="COM_CACHE_CACHE_VIEW_DEFAULT_TITLE">
|
||||
<message>
|
||||
<![CDATA[COM_CACHE_CACHE_VIEW_DEFAULT_DESC]]>
|
||||
</message>
|
||||
</layout>
|
||||
</metadata>
|
||||
21
administrator/components/com_cache/tmpl/cache/emptystate.php
vendored
Normal file
21
administrator/components/com_cache/tmpl/cache/emptystate.php
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_cache
|
||||
*
|
||||
* @copyright (C) 2021 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
|
||||
$displayData = [
|
||||
'textPrefix' => 'COM_CACHE',
|
||||
'helpURL' => 'https://docs.joomla.org/Special:MyLanguage/Cache',
|
||||
'icon' => 'icon-bolt clear',
|
||||
];
|
||||
|
||||
echo LayoutHelper::render('joomla.content.emptystate', $displayData);
|
||||
Reference in New Issue
Block a user