| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @version $Id: cache.class.php 14401 2010-01-26 14:10:00Z louis $ 4 * @package Joomla 5 * @subpackage Cache 6 * @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. 7 * @license GNU/GPL, see LICENSE.php 8 * Joomla! is free software. This version may have been modified pursuant 9 * to the GNU General Public License, and as distributed it includes or 10 * is derivative of works licensed under the GNU General Public License or 11 * other free or open source software licenses. 12 * See COPYRIGHT.php for copyright notices and details. 13 */ 14 15 // no direct access 16 defined( '_JEXEC' ) or die( 'Restricted access' ); 17 18 /** 19 * Class used to hold Cache data 20 * 21 * @package Joomla 22 * @subpackage Cache 23 * @since 1.5 24 */ 25 class CacheData extends JObject 26 { 27 /** 28 * An Array of CacheItems indexed by cache group ID 29 * 30 * @access protected 31 * @var Array 32 */ 33 var $_items = null; 34 35 /** 36 * The cache path 37 * 38 * @access protected 39 * @var String 40 */ 41 var $_path = null; 42 43 /** 44 * Class constructor 45 * 46 * @access protected 47 */ 48 function __construct( $path ) 49 { 50 $this->_path = $path; 51 $this->_parse(); 52 } 53 54 /** 55 * Parse $path for cache file groups. Any files identifided as cache are logged 56 * in a group and stored in $this->items. 57 * 58 * @access private 59 * @param String $path 60 */ 61 function _parse() 62 { 63 jimport('joomla.filesystem.folder'); 64 jimport('joomla.filesystem.file'); 65 $folders = JFolder::folders($this->_path); 66 67 foreach ($folders as $folder) 68 { 69 $files = array(); 70 $files = JFolder::files($this->_path.DS.$folder); 71 $this->_items[$folder] = new CacheItem( $folder ); 72 73 foreach ($files as $file) 74 { 75 $this->_items[$folder]->updateSize( filesize( $this->_path.DS.$folder.DS.$file )/ 1024 ); 76 } 77 } 78 } 79 80 /** 81 * Get the number of current Cache Groups 82 * 83 * @access public 84 * @return int 85 */ 86 function getGroupCount() 87 { 88 return count($this->_items); 89 } 90 91 /** 92 * Retrun an Array containing a sub set of the total 93 * number of Cache Groups as defined by the params. 94 * 95 * @access public 96 * @param Int $start 97 * @param Int $limit 98 * @return Array 99 */ 100 function getRows( $start, $limit ) 101 { 102 $i = 0; 103 $rows = array(); 104 if (!is_array($this->_items)) { 105 return null; 106 } 107 108 foreach ($this->_items as $item) 109 { 110 if ( (($i >= $start) && ($i < $start+$limit)) || ($limit == 0) ) { 111 $rows[] = $item; 112 } 113 $i++; 114 } 115 return $rows; 116 } 117 118 /** 119 * Clean out a cache group as named by param. 120 * If no param is passed clean all cache groups. 121 * 122 * @param String $group 123 */ 124 function cleanCache( $group='' ) 125 { 126 $cache =& JFactory::getCache('', 'callback', 'file'); 127 $cache->clean( $group ); 128 } 129 130 function cleanCacheList( $array ) 131 { 132 foreach ($array as $group) { 133 $this->cleanCache( $group ); 134 } 135 } 136 } 137 138 /** 139 * This Class is used by CacheData to store group cache data. 140 * 141 * @package Joomla 142 * @subpackage Cache 143 * @since 1.5 144 */ 145 class CacheItem 146 { 147 var $group = ""; 148 var $size = 0; 149 var $count = 0; 150 151 function CacheItem ( $group ) 152 { 153 $this->group = $group; 154 } 155 156 function updateSize( $size ) 157 { 158 $this->size = number_format( $this->size + $size, 2 ); 159 $this->count++; 160 } 161 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Mar 28 15:54:07 2012 | Cross-referenced by PHPXref 0.7.1 |