english/libraries/joomla/application/module/helper.php
/**
	* Module cache helper
	*
	* Caching modes:
	* To be set in XML:
	*    'static'      One cache file for all pages with the same module parameters
	*    'oldstatic'   1.5 definition of module caching, one cache file for all pages
	*                  with the same module id and user aid,
	*    'itemid'      Changes on itemid change, to be called from inside the module:
	*    'safeuri'     Id created from $cacheparams->modeparams array,
	*    'id'          Module sets own cache id's
	*
	* @param   object  $module        Module object
	* @param   object  $moduleparams  Module parameters
	* @param   object  $cacheparams   Module cache parameters - id or url parameters, depending on the module cache mode
	* @param   array   $params        Parameters for given mode - calculated id or an array of safe url parameters and their
	*                                 variable types, for valid values see {@link JFilterInput::clean()}.
	*
	* @return  string
	*
	* @since   11.1
	*
	* @link JFilterInput::clean()
	*/


@param   object  $module        Module object
@param   object  $moduleparams  Module parameters
@param   object  $cacheparams   Module cache parameters - id or url parameters, depending on the module cache mode
@param   array   $params        Parameters for given mode - calculated id or an array of safe url parameters and their
variable types, for valid values see  JFilterInput::clean().

@return  string




@param object $module Module object @param object $moduleparams Module parameters @param object $cacheparams Module cache parameters - id or url parameters depending on the module cache mode @param array $params Parameters for given mode - calculated id or an array of safe url parameters and their variable types for valid values see JFilterInput :: clean () . @return string
public static function moduleCache($module, $moduleparams, $cacheparams)
	{
		if (!isset ($cacheparams->modeparams)) {
			$cacheparams->modeparams = null;
		}
		if (!isset ($cacheparams->cachegroup)) {
			$cacheparams->cachegroup = $module->module;
		}
		$user	= JFactory::getUser();
		$cache	= JFactory::getCache($cacheparams->cachegroup, 'callback');
		$conf	= JFactory::getConfig();
		if ($moduleparams->get('owncache', null) === 0  || $conf->get('caching') == 0 || $user->get('id')) {
			$cache->setCaching(false);
		}
		$cache->setLifeTime($moduleparams->get('cache_time', $conf->get('cachetime') * 60));
		$wrkaroundoptions = array (
			'nopathway' 	=> 1,
			'nohead' 		=> 0,
			'nomodules' 	=> 1,
			'modulemode' 	=> 1,
			'mergehead' 	=> 1
		);
		$wrkarounds = true;
		$view_levels = md5(serialize ($user->getAuthorisedViewLevels()));
		switch ($cacheparams->cachemode) {
			case 'id':
				$ret = $cache->get(array($cacheparams->class, $cacheparams->method), $cacheparams->methodparams, $cacheparams->modeparams, $wrkarounds, $wrkaroundoptions);
				break;
			case 'safeuri':
				$secureid=null;
				if (is_array($cacheparams->modeparams)) {
					$uri = JRequest::get();
					$safeuri = new stdClass();
					foreach ($cacheparams->modeparams AS $key => $value) {
						if (isset($uri[$key])) {
							$safeuri->$key = JRequest::_cleanVar($uri[$key], 0,$value);
						}
					} }
				$secureid = md5(serialize(array($safeuri, $cacheparams->method, $moduleparams)));
				$ret = $cache->get(array($cacheparams->class, $cacheparams->method), $cacheparams->methodparams, $module->id. $view_levels.$secureid, $wrkarounds, $wrkaroundoptions);
				break;
			case 'static':
				$ret = $cache->get(array($cacheparams->class, $cacheparams->method), $cacheparams->methodparams, $module->module.md5(serialize($cacheparams->methodparams)), $wrkarounds, $wrkaroundoptions);
				break;
			case 'oldstatic':  
				$ret = $cache->get(array($cacheparams->class, $cacheparams->method), $cacheparams->methodparams, $module->id. $view_levels, $wrkarounds, $wrkaroundoptions);
				break;
			case 'itemid':
			default:
				$ret = $cache->get(array($cacheparams->class, $cacheparams->method), $cacheparams->methodparams, $module->id. $view_levels.JRequest::getVar('Itemid',null,'default','INT'), $wrkarounds, $wrkaroundoptions);
				break;
		}
		return $ret;
	}
public static function moduleCache ( $ module , $ moduleparams , $ cacheparams ) { if ( ! isset ( $ cacheparams -> modeparams ) ) { $ cacheparams -> modeparams = null ; } if ( ! isset ( $ cacheparams -> cachegroup ) ) { $ cacheparams -> cachegroup = $ module -> module ; } $ user = JFactory :: getUser ( ) ; $ cache = JFactory :: getCache ( $ cacheparams -> cachegroup , 'callback' ) ; $ conf = JFactory :: getConfig ( ) ; if ( $ moduleparams -> get ( 'owncache' , null ) === 0 || $ conf -> get ( 'caching' ) == 0 || $ user -> get ( 'id' ) ) { $ cache -> setCaching ( false ) ; } $ cache -> setLifeTime ( $ moduleparams -> get ( 'cache_time' , $ conf -> get ( 'cachetime' ) * 60 ) ) ; $ wrkaroundoptions = array ( 'nopathway' => 1 , 'nohead' => 0 , 'nomodules' => 1 , 'modulemode' => 1 , 'mergehead' => 1 ) ; $ wrkarounds = true ; $ view_levels = md5 ( serialize ( $ user -> getAuthorisedViewLevels ( ) ) ) ; switch ( $ cacheparams -> cachemode ) { case 'id' : $ ret = $ cache -> get ( array ( $ cacheparams -> class , $ cacheparams -> method ) , $ cacheparams -> methodparams , $ cacheparams -> modeparams , $ wrkarounds , $ wrkaroundoptions ) ; break ; case 'safeuri' : $ secureid = null ; if ( is_array ( $ cacheparams -> modeparams ) ) { $ uri = JRequest :: get ( ) ; $ safeuri = new stdClass ( ) ; foreach ( $ cacheparams -> modeparams AS $ key => $ value ) { if ( isset ( $ uri [ $ key ] ) ) { $ safeuri -> $ key = JRequest :: _cleanVar ( $ uri [ $ key ] , 0 , $ value ) ; } } } $ secureid = md5 ( serialize ( array ( $ safeuri , $ cacheparams -> method , $ moduleparams ) ) ) ; $ ret = $ cache -> get ( array ( $ cacheparams -> class , $ cacheparams -> method ) , $ cacheparams -> methodparams , $ module -> id . $ view_levels . $ secureid , $ wrkarounds , $ wrkaroundoptions ) ; break ; case 'static' : $ ret = $ cache -> get ( array ( $ cacheparams -> class , $ cacheparams -> method ) , $ cacheparams -> methodparams , $ module -> module . md5 ( serialize ( $ cacheparams -> methodparams ) ) , $ wrkarounds , $ wrkaroundoptions ) ; break ; case 'oldstatic' : $ ret = $ cache -> get ( array ( $ cacheparams -> class , $ cacheparams -> method ) , $ cacheparams -> methodparams , $ module -> id . $ view_levels , $ wrkarounds , $ wrkaroundoptions ) ; break ; case 'itemid' : default : $ ret = $ cache -> get ( array ( $ cacheparams -> class , $ cacheparams -> method ) , $ cacheparams -> methodparams , $ module -> id . $ view_levels . JRequest :: getVar ( 'Itemid' , null , 'default' , 'INT' ) , $ wrkarounds , $ wrkaroundoptions ) ; break ; } return $ ret ; }
Module cache helper
 Caching modes:
 To be set in XML:
    'static'      One cache file for all pages with the same module parameters
    'oldstatic'   1.5 definition of module caching, one cache file for all pages
                  with the same module id and user aid,
    'itemid'      Changes on itemid change, to be called from inside the module:
    'safeuri'     Id created from $cacheparams->modeparams array,
    'id'          Module sets own cache id's
Module cache helper Caching modes : To be set in XML : ' static ' One cache file for all pages with the same module parameters ' oldstatic ' 1 . 5 definition of module caching one cache file for all pages with the same module id and user aid ' itemid ' Changes on itemid change to be called from inside the module : ' safeuri ' Id created from $cacheparams - > modeparams array ' id ' Module sets own cache id ' s
// Turn cache off for internal callers if parameters are set to off and for all logged in users // Use int filter for id/catid to clean out spamy slugs // provided for backward compatibility, not really usefull