- md5
- 73994c3212d0d035c4af2958977cc098
- sha1
- c830d8461b7781379ad2eaabfb45c8a6834cddf3
- sha256
- e57f3133b026af22aec6f874014a210857ead88283d8a4fc08b21001ddcd32d1
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
<?php
/**
* @version $Id: cache.php 21097 2011-04-07 15:38:03Z dextercowley $
* @package Joomla.Administrator
* @subpackage com_cache
* @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.modellist');
/**
* 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)
{
$app = JFactory::getApplication();
$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.DS.'cache' : $conf->get('cache_path', JPATH_SITE.DS.'cache')
);
jimport('joomla.cache.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)) {
jimport('joomla.html.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();
}
}
The same content is in 5 releases, Joomla 1.6.2 to 1.6.6. See them all, or every version of this file.