/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @return void * @access protected */ protected function setUp() { include_once JPATH_PLATFORM . '/joomla/cache/cache.php'; include_once JPATH_PLATFORM . '/joomla/cache/controller.php'; include_once JPATH_PLATFORM . '/joomla/cache/controller/output.php'; $this->object = JCache::getInstance('output', array()); }
private function getCache() { $conf = JFactory::getConfig(); $options = array('defaultgroup' => '', 'storage' => $conf->get('cache_handler', ''), 'caching' => true, 'cachebase' => $conf->get('cache_path', JPATH_SITE . '/cache')); $cache = JCache::getInstance('', $options); return $cache; }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @return void * @access protected */ protected function setUp() { include_once JPATH_BASE . '/libraries/joomla/cache/cache.php'; include_once JPATH_BASE . '/libraries/joomla/cache/controller.php'; include_once JPATH_BASE . '/libraries/joomla/cache/controller/page.php'; $this->object = JCache::getInstance('page', array()); }
/** * constructor */ function __construct(&$subject, $config) { global $_PROFILER; $mainframe = JFactory::getApplication(); parent::__construct($subject, $config); // if page cache is enabled. if ($this->params->get('enable_cache', 0)) { //Set the language in the class $config =& JFactory::getConfig(); $options = array('cachebase' => JPATH_BASE . DS . 'cache', 'defaultgroup' => 'page', 'lifetime' => $this->params->get('cachetime', 15) * 60, 'enable_cache' => $this->params->get('enable_cache', 1) ? true : false, 'caching' => false, 'language' => $config->getValue('config.language', 'en-GB')); file_put_contents(JPATH_BASE . DS . 'cache' . DS . 'time.txt', $this->params->get('cachetime', 15) * 60); jimport('joomla.cache.cache'); $this->_cache = JCache::getInstance('page', $options); $menu = $this->params->get('menu', ''); if ($menu != '') { $this->_ItemidsCached = !is_array($menu) ? array($menu) : $menu; } } // process clear cache from client request if (JRequest::getVar('icespeed')) { $this->processClearCacheRequest(); } if ($mainframe->isAdmin()) { // load js and css for proccessing client action. PlgIceSpeedHelper::loadAdminMediaFiles('ice_speed'); // trigger clear cache: automatic clear cache after saved, applied. if (JRequest::getVar('task') == 'apply' || JRequest::getVar('task') == 'save') { $this->processClearCacheRequest(); } } }
/** * Clean the cache. * It also cleans the simplecustomrouter plugin cache, as the routes * configured by this component are used by that plugin. * * This method is called when needed from parent models. * * @param string $group The cache group * @param string $client_id The ID of the client */ protected function cleanCache($group = null, $client_id = 0) { $conf = JFactory::getConfig(); $options = array('defaultgroup' => 'simplecustomrouter', 'cachebase' => $conf->get('cache_path', JPATH_SITE . '/cache')); $cache = JCache::getInstance('', $options)->clean(); parent::cleanCache($group, $client_id); }
function update() { $currency = JRequest::getInt('hikashopcurrency', 0); if (!empty($currency)) { $app = JFactory::getApplication(); $app->setUserState(HIKASHOP_COMPONENT . '.currency_id', $currency); $app->setUserState(HIKASHOP_COMPONENT . '.shipping_method', null); $app->setUserState(HIKASHOP_COMPONENT . '.shipping_id', null); $app->setUserState(HIKASHOP_COMPONENT . '.shipping_data', null); $app->setUserState(HIKASHOP_COMPONENT . '.payment_method', null); $app->setUserState(HIKASHOP_COMPONENT . '.payment_id', null); $app->setUserState(HIKASHOP_COMPONENT . '.payment_data', null); $url = JRequest::getString('return_url', ''); if (HIKASHOP_J30) { $plugin = JPluginHelper::getPlugin('system', 'cache'); $params = new JRegistry(@$plugin->params); $options = array('defaultgroup' => 'page', 'browsercache' => $params->get('browsercache', false), 'caching' => false); $cache = JCache::getInstance('page', $options); $cache->clean(); } if (!empty($url)) { if (hikashop_disallowUrlRedirect($url)) { return false; } $app->redirect(urldecode($url)); } } return true; }
function getCss ($path) { $app = JFactory::getApplication(); // get vars last-modified $vars_lm = $app->getUserState('vars_last_modified', 0); // less file last-modified $filepath = JPATH_ROOT.'/'.$path; $less_lm = filemtime ($filepath); // cache key $key = md5 ($vars_lm.':'.$less_lm.':'.$path); $group = 't3'; $cache = JCache::getInstance ('output', array('lifetime'=>1440)); // get cache $data = $cache->get ($key, $group); if ($data) { return $data; } // not cached, build & store it $data = $this->compileCss ($path)."\n"; $cache->store ($data, $key, $group); return $data; }
public function __construct($groupName) { $this->cache = JFactory::getCache($groupName, 'output'); $handler = 'output'; $options = array('storage' => 'file', 'defaultgroup' => $groupName, 'locking' => true, 'locktime' => 15, 'checkTime' => false, 'caching' => true); $this->cache = JCache::getInstance($handler, $options); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @return void */ protected function setUp() { parent::setUp(); include_once JPATH_PLATFORM . '/joomla/cache/cache.php'; include_once JPATH_PLATFORM . '/joomla/cache/controller.php'; include_once JPATH_PLATFORM . '/joomla/cache/controller/callback.php'; $this->object = JCache::getInstance('callback', array()); }
/** * Constructor * * @access protected * @param object $subject The object to observe * @param array $config An array that holds the plugin configuration * @since 1.0 */ function __construct(&$subject, $config) { parent::__construct($subject, $config); //Set the language in the class $config = JFactory::getConfig(); $options = array('defaultgroup' => 'page', 'browsercache' => $this->params->get('browsercache', false), 'caching' => false); $this->_cache = JCache::getInstance('page', $options); }
/** * * @param type $type * @return type */ public static function getCacheObject($type = 'callback', $lifetime = 86400) { $aOptions = array('defaultgroup' => 'plg_jch_optimize', 'checkTime' => TRUE, 'application' => 'site', 'language' => 'en-GB', 'cachebase' => JPATH_SITE . '/cache', 'storage' => 'file'); $oCache = JCache::getInstance($type, $aOptions); $oCache->setCaching(TRUE); $oCache->setLifeTime($lifetime); return $oCache; }
/** * Test... * * @param string $type @todo * * @dataProvider provider * * @return void */ public function testConstruct($type) { $class = 'JCacheController' . ucfirst($type); $cache =& JCache::getInstance($type); $this->assertTrue($cache instanceof $class, 'Expecting= ' . $class . ' Returned= ' . get_class($cache)); $cache2 =& JCache::getInstance($type); $this->assertTrue($cache !== $cache2, 'Type: ' . $type . ' Recieved the same instance twice'); }
/** * Constructor. * * @param object &$subject The object to observe. * @param array $config An optional associative array of configuration settings. * * @since 1.5 */ public function __construct(&$subject, $config) { parent::__construct($subject, $config); // Set the language in the class. $options = array('defaultgroup' => 'page', 'browsercache' => $this->params->get('browsercache', false), 'caching' => false); $this->_cache = JCache::getInstance('page', $options); $this->_cache_key = JUri::getInstance()->toString(); }
/** * Constructor * * @access protected * @param object $subject The object to observe * @param array $config An array that holds the plugin configuration * @since 1.0 */ function __construct(&$subject, $config) { parent::__construct($subject, $config); //Set the language in the class $config =& JFactory::getConfig(); $options = array('cachebase' => JPATH_BASE . DS . 'cache', 'defaultgroup' => 'page', 'lifetime' => $this->params->get('cachetime', 15) * 60, 'browsercache' => $this->params->get('browsercache', false), 'caching' => false, 'language' => $config->getValue('config.language', 'en-GB')); jimport('joomla.cache.cache'); $this->_cache =& JCache::getInstance('page', $options); }
/** * * @param type $type * @return type */ private static function _getCacheObject($type, $lifetime) { if (static::${$type . 'Cache'} !== null) { return static::${$type . 'Cache'}; } $aOptions = array('defaultgroup' => 'plg_jch_optimize', 'checkTime' => TRUE, 'caching' => TRUE, 'application' => 'site', 'language' => 'en-GB', 'lifetime' => $lifetime); static::${$type . 'Cache'} = JCache::getInstance($type, $aOptions); return static::${$type . 'Cache'}; }
/** * Constructor * * @param bool $devmode Indicate development mode or not */ public function __construct($devmode = true) { $this->_devmode = $devmode; $conf = JFactory::getConfig(); $options = array('defaultgroup' => self::T3_CACHE_GROUP, 'caching' => true, 'cachebase' => $conf->get('cache_path', JPATH_SITE . '/cache'), 'lifetime' => (int) $conf->get('cachetime') * 60); //JFactory::getCache(); //$this->cache = new JCache($options); $this->cache = JCache::getInstance('', $options); }
private static function cleanByType($group) { $conf = \JFactory::getConfig(); $dispatcher = \JEventDispatcher::getInstance(); $options = array('defaultgroup' => $group, 'cachebase' => $conf->get('cache_path', JPATH_SITE . '/cache')); $cache = \JCache::getInstance('callback', $options); $cache->clean(); // Trigger the onContentCleanCache event. $dispatcher->trigger('onContentCleanCache', $options); }
/** * Create a JCache instance * * @param string $group * @param string $handler * @param null $storage * @return JCache */ protected function _getCache($group = '', $handler = 'callback', $storage = null) { if (!$this->_cache) { jimport('joomla.cache.cache'); $app = JFactory::getApplication(); $options = array('caching' => true, 'defaultgroup' => $this->_getGroup(), 'lifetime' => 60 * 24 * 180, 'cachebase' => JPATH_ADMINISTRATOR . '/cache', 'language' => $app->getCfg('language'), 'storage' => $app->getCfg('cache_handler', 'file')); $this->_cache = JCache::getInstance('output', $options); } return $this->_cache; }
/** * Method to get cache instance * * @return object */ public function getCache($path = '') { $conf = JFactory::getConfig(); $options = array('defaultgroup' => '', 'storage' => $conf->get('cache_handler', ''), 'caching' => true, 'cachebase' => $path); jimport('joomla.cache.cache'); // We need to clear the previously used cache handlers, otherwise backend cachebase can't be used JCache::$_handler = array(); $cache = JCache::getInstance('', $options); return $cache; }
/** * Clean the cache * * @param string $group * The cache group * @param integer $client_id * The ID of the client * @return void * @since 11.1 */ private function cleanComponentCache($group = null, $client_id = 0) { // Initialise variables; $conf = JFactory::getConfig(); $dispatcher = JDispatcher::getInstance(); $options = array('defaultgroup' => $group ? $group : $this->app->input->get('option'), 'cachebase' => $client_id ? JPATH_ADMINISTRATOR . '/cache' : $conf->get('cache_path', JPATH_SITE . '/cache')); $cache = JCache::getInstance('callback', $options); $cache->clean(); // Trigger the onContentCleanCache event. $dispatcher->trigger('onContentCleanCache', $options); }
/** * Constructor * * For php4 compatability we must not use the __constructor as a constructor for plugins * because func_get_args ( void ) returns a copy of all passed arguments NOT references. * This causes problems with cross-referencing necessary for the observer design pattern. * * @access protected * @param object $subject The object to observe * @param array $config An array that holds the plugin configuration * @since 1.0 */ function plgSystemCache(&$subject, $config) { parent::__construct($subject, $config); $user =& JFactory::getUser(); $options = array('cachebase' => JPATH_BASE . DS . 'cache', 'defaultgroup' => 'page', 'lifetime' => $this->params->get('cachetime', 15) * 60, 'browsercache' => $this->params->get('browsercache', false), 'caching' => false); jimport('joomla.cache.cache'); $this->_cache =& JCache::getInstance('page', $options); if (!$user->get('aid') && $_SERVER['REQUEST_METHOD'] == 'GET') { $this->_cache->setCaching(true); } }
/** * Get a cache object * * Returns a reference to the global {@link JCache} object * * @access public * @param string The cache group name * @param string The handler to use * @param string The storage method * @return object JCache */ function &getCache($group = '', $handler = 'callback', $storage = null) { $handler = $handler == 'function' ? 'callback' : $handler; $conf =& JFactory::getConfig(); if (!isset($storage)) { $storage = $conf->getValue('config.cache_handler', 'file'); } $options = array('defaultgroup' => $group, 'cachebase' => $conf->getValue('config.cache_path'), 'lifetime' => $conf->getValue('config.cachetime') * 60, 'language' => $conf->getValue('config.language'), 'storage' => $storage, 'site' => Nooku\Library\ObjectManager::getInstance()->getObject('application')->getSite()); jimport('joomla.cache.cache'); $cache =& JCache::getInstance($handler, $options); $cache->setCaching($conf->getValue('config.caching')); return $cache; }
public function testCallbackInstance() { $cache =& JCache::getInstance('callback', array('storage' => 'mock')); $arg1 = 'e1'; $arg2 = 'e2'; $this->expectOutputString('e1e1e1e1e1'); for ($i = 0; $i < 5; $i++) { $instance = new testCallbackController(); $result = $cache->get(array($instance, 'instanceCallback'), array($arg1, $arg2)); $this->assertTrue($arg2 === $result, 'Expected: ' . $arg2 . ' Actual: ' . $result); unset($instance); } }
/** * Create a JCache instance * * @return JCache */ protected function _getCache() { if (!$this->_cache) { jimport('joomla.cache.cache'); $options = array('caching' => true, 'defaultgroup' => $this->_getGroup(), 'lifetime' => 60 * 24 * 180, 'cachebase' => $this->_getConfig('cache_path'), 'language' => $this->_getConfig('language'), 'storage' => $this->_getConfig('cache_handler', 'file')); // 2.5 does this itself if (version_compare(JVERSION, '1.6', '<')) { $options['lifetime'] *= 60; } $this->_cache = JCache::getInstance('output', $options); } return $this->_cache; }
static function getInstance($group = '', $handler = 'callback', $storage = null) { static $instances = array(); $hash = md5($group . $handler . $storage); $handler = $handler == 'function' ? 'callback' : $handler; $options = array('defaultgroup' => $group, 'cachebase' => JPATH_CONFIGURATION . DS . 'cache', 'caching' => true); //caching has to be on if (isset($storage)) { $options['storage'] = $storage; } jimport('joomla.cache.cache'); $instances[$hash] = JCache::getInstance($handler, $options); return $instances[$hash]; }
function onAfterCartUpdate($parent, $cart, $product_id, $quantity, $add, $type, $resetCartWhenUpdate, $force, $updated) { if (!$updated) { return; } if (!HIKASHOP_J30) { return; } $plugin = JPluginHelper::getPlugin('system', 'cache'); $params = new JRegistry(@$plugin->params); $options = array('defaultgroup' => 'page', 'browsercache' => $params->get('browsercache', false), 'caching' => false); $cache = JCache::getInstance('page', $options); $cache->clean(); }
function __construct(&$subject, $config) { parent::__construct($subject, $config); $this->plugin =& JPluginHelper::getPlugin('system', 'plg_ztools'); $this->plgParams = new JParameter($this->plugin->params); //Get exclude categories $components = $this->plgParams->get('components', ''); $this->_components = is_array($components) ? $components : array($components); //Set the language in the class $config = JFactory::getConfig(); $options = array('cachebase' => JPATH_ROOT . DS . "cache", 'lifetime' => (int) ($this->plgParams->get('gzip_lifetime', 15) * 60), 'defaultgroup' => 'page', 'browsercache' => $this->plgParams->get('gzip_browsercache', 0) ? true : false, 'caching' => false); jimport('joomla.cache.cache'); $this->_cache = JCache::getInstance('page', $options); }
protected function saveSettings() { if (version_compare(JVERSION, '2.5.0', 'ge')) { $this->checkPermissions(); JRequest::checkToken() or jexit('Invalid Token'); $data = JRequest::getVar('jform', array(), 'post', 'array'); $id = JRequest::getInt('id'); $option = JRequest::getCmd('component'); // Joomla! 3.2 compatibility if (version_compare(JVERSION, '3.2', 'ge')) { require_once JPATH_SITE . '/components/com_config/model/cms.php'; require_once JPATH_SITE . '/components/com_config/model/form.php'; } // Validate the form JForm::addFormPath(JPATH_ADMINISTRATOR . '/components/' . $option); $form = JForm::getInstance('com_sigpro.settings', 'config', array('control' => 'jform', 'load_data' => $loadData), false, '/config'); JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_config/models'); $model = JModelLegacy::getInstance('Component', 'ConfigModel'); $params = $model->validate($form, $data); if ($params === false) { $errors = $model->getErrors(); $response = new stdClass(); $response->message = $errors[0] instanceof Exception ? $errors[0]->getMessage() : $errors[0]; $response->type = 'warning'; return $response; } $data = array('params' => $params, 'id' => $id, 'option' => $option); } else { JRequest::checkToken() or jexit('Invalid Token'); $data = JRequest::get('post'); } $model = SigProModel::getInstance('Settings', 'SigProModel'); $model->setState('option', 'com_sigpro'); $model->setState('data', $data); if (version_compare(JVERSION, '3.0', 'ge')) { $options = array('defaultgroup' => '_system', 'cachebase' => JPATH_ADMINISTRATOR . '/cache'); $cache = JCache::getInstance('callback', $options); $cache->clean(); } $response = new stdClass(); if ($model->save()) { $response->message = JText::_('COM_SIGPRO_SETTINGS_SAVED'); $response->type = 'message'; } else { $response->message = $model->getError(); $response->type = 'error'; } return $response; }
/** * Clears the specified cache groups. * * @param array $clearGroups Which cache groups to clear. Usually this is com_yourcomponent to clear your * component's cache. * @param array $cacheClients Which cache clients to clear. 0 is the back-end, 1 is the front-end. If you do not * specify anything, both cache clients will be cleared. * * @return void */ public static function clearCacheGroups(array $clearGroups, array $cacheClients = array(0, 1)) { $conf = JFactory::getConfig(); foreach ($clearGroups as $group) { foreach ($cacheClients as $client_id) { try { $options = array('defaultgroup' => $group, 'cachebase' => $client_id ? JPATH_ADMINISTRATOR . '/cache' : $conf->get('cache_path', JPATH_SITE . '/cache')); $cache = JCache::getInstance('callback', $options); $cache->clean(); } catch (Exception $e) { // suck it up } } } }
public function delete() { $result = parent::delete(); // Also delete related file if not attached to any other document. if ($result && $this->storage_type == 'file') { $state = array('storage_type' => 'file', 'storage_path' => $this->storage_path); if (!$this->getObject('com://admin/docman.model.documents')->setState($state)->count()) { $file = $this->storage; if (!$file->isNew()) { $file->delete(); // Clear com_files cache JCache::getInstance('output', array('defaultgroup' => 'com_docman.files'))->clean(); } } } return $result; }