- md5
- 93a0693d3845e0bd6e3c7c3830cc31d0
- sha1
- 968306bdf4baf96236dbb736ef4d8fe345ac499f
- sha256
- dc6abd402e95e2994fe196e53497e8828e2a80bdc33ae9c015984268bad64f83
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
<?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();
}
}
The same content is in 9 releases, Joomla 3.0.3 to 3.2.1. See them all, or every version of this file.