Beispiel #1
0
 /**
  * Recupera una lista de los items de menu publicados en Joomla!
  *
  * @return array Lista de menùes recuperados
  */
 function getJoomlaMenuItems()
 {
     $dbo =& JFactory::getDBO();
     $query = 'SELECT ' . $dbo->nameQuote('m.id') . ', ' . $dbo->nameQuote('m.name') . ' FROM ' . $dbo->nameQuote('#__menu') . ' m' . ' WHERE ' . $dbo->nameQuote('published') . ' = 1';
     $dbo->setQuery($query);
     return $this->_cache->get(array($dbo, 'loadObjectList'), array());
 }
Beispiel #2
0
 /**
  * A convenience event handler to obtain the text related to an option's 
  * value.
  * 
  * The event cache's the options for quicker lookup and to reduce load on 
  * the database. Therefore, there may be some delay between new items 
  * being added to JReviews and what is retrieved by this event. 
  * 
  * @param string $value The option's value.
  * @return string The text related to the option's value.
  */
 public function onJSolrSearchOptionLookup($value)
 {
     $conf = JFactory::getConfig();
     $options = array('defaultgroup' => 'plg_jsolrsearch_jreviews', 'cachebase' => $conf->getValue('config.cache_path'), 'lifetime' => $conf->getValue('config.cachetime') * 60, 'language' => $conf->getValue('config.language'), 'storage' => $conf->getValue('config.storage', 'file'));
     $cache = new JCache($options);
     $cache->setCaching(true);
     if (!($list = json_decode($cache->get('options', $options['defaultgroup'])))) {
         $database = JFactory::getDbo();
         $query = $database->getQuery(true);
         $query->select(array('text', 'value'))->from('#__jreviews_fieldoptions');
         $database->setQuery($query);
         $list = $database->loadObjectList();
         // cache these options so we don't need to keep loading from db.
         $cache->store(json_encode($list), $options['defaultgroup']);
     }
     $found = false;
     $text = "";
     while (!$found && ($item = current($list))) {
         if ($item->value == $value) {
             $found = true;
             $text = $item->text;
         }
         next($list);
     }
     return $text;
 }
Beispiel #3
0
 /**
  * Recupera una lista de los values asociados a un tag menu.
  *
  * @return array Lista de values recuperados
  */
 function getCpMenuValues($field_id)
 {
     $tipo = $this->getTipo('menu');
     $dbo =& JFactory::getDBO();
     $query = 'SELECT ' . $dbo->nameQuote('v.id') . ', ' . $dbo->nameQuote('v.name') . ', ' . $dbo->nameQuote('v.label') . ' FROM ' . $dbo->nameQuote('#__custom_properties_values') . ' v' . ' INNER JOIN ' . $dbo->nameQuote('#__zonales_cp2tipotag') . ' tt' . ' ON ' . $dbo->nameQuote('tt.field_id') . ' = ' . $dbo->nameQuote('v.field_id') . ' AND ' . $dbo->nameQuote('tt.tipo_id') . ' = ' . $tipo->id . ' AND ' . $dbo->nameQuote('tt.field_id') . ' = ' . $field_id;
     $dbo->setQuery($query);
     return $this->_cache->get(array($dbo, 'loadObjectList'), array());
 }
Beispiel #4
0
 /**
  * @return string
  */
 protected function getInput()
 {
     $file_cache = new JCache(array('defaultgroup' => 'rokbooster', 'caching' => true, 'checkTime' => true, 'storage' => 'file', 'cachebase' => JPATH_SITE . '/cache'));
     $files = $file_cache->getAll();
     $filecount = 0;
     if (is_array($files) && array_key_exists('rokbooster', $files)) {
         $filecount = $files['rokbooster']->count;
     }
     return '<div class="clearcache btn btn-primary" data-action="clearCache"><i>' . JText::_('ROKBOOSTER_BUTTON_CLEAR_CACHE') . '<span class="count">' . $filecount . '</span></i></div>';
 }
 /**
  * Recupera los datos desde el modelo (un solo registro)
  *
  * @param boolean $reload recargar datos desde bd o utilizar copia de la instancia
  * @return Object registro especificado en la bd
  */
 function &getData($reload = false, $customQuery = false)
 {
     if (empty($this->_data) || $reload) {
         $query = $this->_buildQuery($customQuery);
         $this->_db->setQuery($query);
         //$this->_data = $this->_db->loadObject();
         $this->_data = $this->_cache->get(array($this->_db, 'loadObject'), array());
     }
     if (!$this->_data) {
         $this->_data =& $this->getTable();
     }
     return $this->_data;
 }
Beispiel #6
0
 /**
  * Retrieves the table schema information about the given table
  *
  * This function try to get the table schema from the cache. If it cannot be found the table schema will be
  * retrieved from the database and stored in the cache.
  *
  * @param   string  $table A table name or a list of table names
  * @return  KDatabaseSchemaTable
  */
 public function getTableSchema($table)
 {
     if (!isset($this->_table_schema[$table]) && isset($this->_cache)) {
         $identifier = md5($this->getDatabase() . $table);
         if (!($schema = $this->_cache->get($identifier))) {
             $schema = parent::getTableSchema($table);
             //Store the object in the cache
             $this->_cache->store(serialize($schema), $identifier);
         } else {
             $schema = unserialize($schema);
         }
         $this->_table_schema[$table] = $schema;
     }
     return parent::getTableSchema($table);
 }
Beispiel #7
0
 /**
  * Parse the template
  *
  * This function implements a caching mechanism when reading the template. If the template cannot be found in the
  * cache it will be filtered and stored in the cache. Otherwise it will be loaded from the cache and returned
  * directly.
  *
  * @param string The template content to parse
  * @return void
  */
 protected function _parse(&$content)
 {
     if (isset($this->_cache)) {
         $identifier = md5($this->getPath());
         if (!$this->_cache->get($identifier)) {
             parent::_parse($content);
             //Store the object in the cache
             $this->_cache->store($content, $identifier);
         } else {
             $content = $this->_cache->get($identifier);
         }
     } else {
         parent::_parse($content);
     }
 }
Beispiel #8
0
	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;
	}
 /**
  * @return string
  */
 protected function getInput()
 {
     if (!self::$assets_loaded) {
         $doc = JFactory::getDocument();
         $doc->addStyleSheet(JURI::root(true) . '/plugins/system/rokbooster/fields/assets/clearcache/css/clearcache.css');
         $doc->addScript(JURI::root(true) . '/plugins/system/rokbooster/fields/assets/clearcache/js/RokBooster.js');
         self::$assets_loaded = true;
     }
     $file_cache = new JCache(array('defaultgroup' => 'rokbooster', 'caching' => true, 'checkTime' => true, 'storage' => 'file', 'cachebase' => JPATH_SITE . '/cache'));
     $files = $file_cache->getAll();
     $filecount = 0;
     if (is_array($files) && array_key_exists('rokbooster', $files)) {
         $filecount = $files['rokbooster']->count;
     }
     return '<div class="clearcache btn btn-primary" data-action="clearCache"><i>' . JText::_('ROKBOOSTER_BUTTON_CLEAR_CACHE') . '<span class="count">' . $filecount . '</span></i></div>';
 }
Beispiel #10
0
 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;
 }
Beispiel #11
0
 /**
  * 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);
 }
Beispiel #12
0
 /**
  *  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();
         }
     }
 }
 /**
  * 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());
 }
Beispiel #14
0
 /**
  * Recupera los valores del tag indicado
  *
  * @param int id identificador del tag
  * @return array Arreglo de objetos value
  */
 function getMenuValues($id, $eq = false)
 {
     if (is_null($id)) {
         return null;
     }
     $dbo =& JFactory::getDBO();
     $query = 'SELECT ' . $dbo->nameQuote('v.id') . ', ' . $dbo->nameQuote('v.name') . ', ' . $dbo->nameQuote('v.label') . ', ' . $dbo->nameQuote('jm.link') . ', ' . $dbo->nameQuote('zm.menu_id') . ($eq ? ', b.peso' : '') . ' FROM ' . $dbo->nameQuote('#__custom_properties_values') . ' v' . ' INNER JOIN ' . $dbo->nameQuote('#__zonales_menu') . ' zm' . ' ON ' . $dbo->nameQuote('zm.value_id') . ' = ' . $dbo->nameQuote('v.id') . ' INNER JOIN ' . $dbo->nameQuote('#__menu') . ' jm' . ' ON ' . $dbo->nameQuote('jm.id') . ' = ' . $dbo->nameQuote('zm.menu_id');
     // ecualiza
     if ($eq) {
         require_once JPATH_BASE . DS . 'components' . DS . 'com_eqzonales' . DS . 'controllers' . DS . 'eq.php';
         JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_eqzonales' . DS . 'tables');
         $ctrlEq = new EqZonalesControllerEq();
         $ctrlEq->addModelPath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_eqzonales' . DS . 'models');
         // recupera ecualizador del usuario
         $user =& JFactory::getUser();
         $result = $ctrlEq->retrieveUserEqImpl($user->id);
         if (!is_null($result) && !empty($result)) {
             $eq = $result[0];
             $query .= ' LEFT JOIN ' . $dbo->nameQuote('#__eqzonales_banda') . ' b' . ' ON ' . $dbo->nameQuote('v.id') . ' = ' . $dbo->nameQuote('b.cp_value_id') . ' AND ' . $dbo->nameQuote('b.eq_id') . ' = ' . $eq->eq->id;
         }
     }
     // where
     $query .= ' WHERE ' . $dbo->nameQuote('v.field_id') . ' = ' . $id;
     // ordena según ecualización
     if ($eq) {
         $query .= ' ORDER BY b.peso DESC';
     }
     $dbo->setQuery($query);
     return $this->_cache->get(array($dbo, 'loadObjectList'), array());
 }
 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
  * @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());
 }
Beispiel #17
0
 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;
 }
Beispiel #18
0
 /**
  * Show the configuration edit form
  * @param string The URL option
  */
 public static function showConfig()
 {
     // Initialize some variables
     $db =& JFactory::getDBO();
     $row = new JConfig();
     // compile list of the languages
     $langs = array();
     $menuitems = array();
     $lists = array();
     // PRE-PROCESS SOME LIST
     // -- Show/Hide --
     $show_hide = array(JHTML::_('select.option', 1, JText::_('Hide')), JHTML::_('select.option', 0, JText::_('Show')));
     $show_hide_r = array(JHTML::_('select.option', 0, JText::_('Hide')), JHTML::_('select.option', 1, JText::_('Show')));
     // DEBUG
     $lists['debug'] = JHTML::_('select.booleanlist', 'debug', 'class="inputbox"', $row->debug);
     $lists['debug_lang'] = JHTML::_('select.booleanlist', 'debug_lang', 'class="inputbox"', $row->debug_lang);
     // DATABASE SETTINGS
     // SERVER SETTINGS
     $errors = array(JHTML::_('select.option', -1, JText::_('System Default')), JHTML::_('select.option', 0, JText::_('None')), JHTML::_('select.option', E_ERROR | E_WARNING | E_PARSE, JText::_('Simple')), JHTML::_('select.option', E_ALL ^ E_STRICT, JText::_('Maximum')));
     $lists['error_reporting'] = JHTML::_('select.genericlist', $errors, 'error_reporting', 'class="inputbox" size="1"', 'value', 'text', $row->error_reporting);
     $lists['enable_ftp'] = JHTML::_('select.booleanlist', 'ftp_enable', 'class="inputbox"', intval($row->ftp_enable));
     // LOCALE SETTINGS
     $timeoffset = array(JHTML::_('select.option', -12, JText::_('(UTC -12:00) International Date Line West')), JHTML::_('select.option', -11, JText::_('(UTC -11:00) Midway Island, Samoa')), JHTML::_('select.option', -10, JText::_('(UTC -10:00) Hawaii')), JHTML::_('select.option', -9.5, JText::_('(UTC -09:30) Taiohae, Marquesas Islands')), JHTML::_('select.option', -9, JText::_('(UTC -09:00) Alaska')), JHTML::_('select.option', -8, JText::_('(UTC -08:00) Pacific Time (US &amp; Canada)')), JHTML::_('select.option', -7, JText::_('(UTC -07:00) Mountain Time (US &amp; Canada)')), JHTML::_('select.option', -6, JText::_('(UTC -06:00) Central Time (US &amp; Canada), Mexico City')), JHTML::_('select.option', -5, JText::_('(UTC -05:00) Eastern Time (US &amp; Canada), Bogota, Lima')), JHTML::_('select.option', -4.5, JText::_('(UTC -04:30) Venezuela')), JHTML::_('select.option', -4, JText::_('(UTC -04:00) Atlantic Time (Canada), Caracas, La Paz')), JHTML::_('select.option', -3.5, JText::_('(UTC -03:30) St. John\'s, Newfoundland, Labrador')), JHTML::_('select.option', -3, JText::_('(UTC -03:00) Brazil, Buenos Aires, Georgetown')), JHTML::_('select.option', -2, JText::_('(UTC -02:00) Mid-Atlantic')), JHTML::_('select.option', -1, JText::_('(UTC -01:00) Azores, Cape Verde Islands')), JHTML::_('select.option', 0, JText::_('(UTC 00:00) Western Europe Time, London, Lisbon, Casablanca')), JHTML::_('select.option', 1, JText::_('(UTC +01:00) Amsterdam, Berlin, Brussels, Copenhagen, Madrid, Paris')), JHTML::_('select.option', 2, JText::_('(UTC +02:00) Istanbul, Jerusalem, Kaliningrad, South Africa')), JHTML::_('select.option', 3, JText::_('(UTC +03:00) Baghdad, Riyadh, Moscow, St. Petersburg')), JHTML::_('select.option', 3.5, JText::_('(UTC +03:30) Tehran')), JHTML::_('select.option', 4, JText::_('(UTC +04:00) Abu Dhabi, Muscat, Baku, Tbilisi')), JHTML::_('select.option', 4.5, JText::_('(UTC +04:30) Kabul')), JHTML::_('select.option', 5, JText::_('(UTC +05:00) Ekaterinburg, Islamabad, Karachi, Tashkent')), JHTML::_('select.option', 5.5, JText::_('(UTC +05:30) Bombay, Calcutta, Madras, New Delhi, Colombo')), JHTML::_('select.option', 5.75, JText::_('(UTC +05:45) Kathmandu')), JHTML::_('select.option', 6, JText::_('(UTC +06:00) Almaty, Dhaka')), JHTML::_('select.option', 6.5, JText::_('(UTC +06:30) Yagoon')), JHTML::_('select.option', 7, JText::_('(UTC +07:00) Bangkok, Hanoi, Jakarta')), JHTML::_('select.option', 8, JText::_('(UTC +08:00) Beijing, Perth, Singapore, Hong Kong')), JHTML::_('select.option', 8.75, JText::_('(UTC +08:00) Ulaanbaatar, Western Australia')), JHTML::_('select.option', 9, JText::_('(UTC +09:00) Tokyo, Seoul, Osaka, Sapporo, Yakutsk')), JHTML::_('select.option', 9.5, JText::_('(UTC +09:30) Adelaide, Darwin, Yakutsk')), JHTML::_('select.option', 10, JText::_('(UTC +10:00) Eastern Australia, Guam, Vladivostok')), JHTML::_('select.option', 10.5, JText::_('(UTC +10:30) Lord Howe Island (Australia)')), JHTML::_('select.option', 11, JText::_('(UTC +11:00) Magadan, Solomon Islands, New Caledonia')), JHTML::_('select.option', 11.5, JText::_('(UTC +11:30) Norfolk Island')), JHTML::_('select.option', 12, JText::_('(UTC +12:00) Auckland, Wellington, Fiji, Kamchatka')), JHTML::_('select.option', 12.75, JText::_('(UTC +12:45) Chatham Island')), JHTML::_('select.option', 13, JText::_('(UTC +13:00) Tonga')), JHTML::_('select.option', 14, JText::_('(UTC +14:00) Kiribati')));
     $lists['offset'] = JHTML::_('select.genericlist', $timeoffset, 'offset', 'class="inputbox" size="1"', 'value', 'text', $row->offset);
     // MAIL SETTINGS
     $mailer = array(JHTML::_('select.option', 'mail', JText::_('PHP mail function')), JHTML::_('select.option', 'sendmail', JText::_('Sendmail')), JHTML::_('select.option', 'smtp', JText::_('SMTP Server')));
     $lists['mailer'] = JHTML::_('select.genericlist', $mailer, 'mailer', 'class="inputbox" size="1"', 'value', 'text', $row->mailer);
     $smtpsecure = array(JHTML::_('select.option', 'none', JText::_('None')), JHTML::_('select.option', 'ssl', 'SSL'), JHTML::_('select.option', 'tls', 'TLS'));
     $lists['smtpsecure'] = JHTML::_('select.genericlist', $smtpsecure, 'smtpsecure', 'class="inputbox" size="1"', 'value', 'text', isset($row->smtpsecure) ? $row->smtpsecure : '');
     $lists['smtpauth'] = JHTML::_('select.booleanlist', 'smtpauth', 'class="inputbox"', $row->smtpauth);
     // CACHE SETTINGS
     $lists['caching'] = JHTML::_('select.booleanlist', 'caching', 'class="inputbox"', $row->caching);
     jimport('joomla.cache.cache');
     $stores = JCache::getStores();
     $options = array();
     foreach ($stores as $store) {
         $options[] = JHTML::_('select.option', $store, JText::_(ucfirst($store)));
     }
     $lists['cache_handlers'] = JHTML::_('select.genericlist', $options, 'cache_handler', 'class="inputbox" size="1"', 'value', 'text', $row->cache_handler);
     // MEMCACHE SETTINGS
     if (!empty($row->memcache_settings) && !is_array($row->memcache_settings)) {
         $row->memcache_settings = unserialize(stripslashes($row->memcache_settings));
     }
     $lists['memcache_persist'] = JHTML::_('select.booleanlist', 'memcache_settings[persistent]', 'class="inputbox"', @$row->memcache_settings['persistent']);
     $lists['memcache_compress'] = JHTML::_('select.booleanlist', 'memcache_settings[compression]', 'class="inputbox"', @$row->memcache_settings['compression']);
     // SEO SETTINGS
     $lists['sef'] = JHTML::_('select.booleanlist', 'sef', 'class="inputbox"', $row->sef);
     $lists['sef_rewrite'] = JHTML::_('select.booleanlist', 'sef_rewrite', 'class="inputbox"', $row->sef_rewrite);
     $lists['sef_suffix'] = JHTML::_('select.booleanlist', 'sef_suffix', 'class="inputbox"', $row->sef_suffix);
     // SESSION SETTINGS
     $stores = JSession::getStores();
     $options = array();
     foreach ($stores as $store) {
         $options[] = JHTML::_('select.option', $store, JText::_(ucfirst($store)));
     }
     $lists['session_handlers'] = JHTML::_('select.genericlist', $options, 'session_handler', 'class="inputbox" size="1"', 'value', 'text', $row->session_handler);
     // SHOW EDIT FORM
     ConfigApplicationView::showConfig($row, $lists);
 }
Beispiel #19
0
 /**
  * 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('defaultgroup' => 'page', 'browsercache' => $this->params->get('browsercache', false), 'caching' => false);
     $this->_cache = JCache::getInstance('page', $options);
 }
 /**
  * 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');
 }
Beispiel #22
0
 /**
  * Display the application.
  */
 public function render()
 {
     $user = JFactory::getUser();
     $conf = JFactory::getConfig();
     if ($user->id != 0) {
         // generate and empty object
         $plgParams = new JRegistry();
         // get plugin details
         $plugin = JPluginHelper::getPlugin('system', 'rokbooster');
         // load params into our params object
         if ($plugin && isset($plugin->params)) {
             $plgParams->loadString($plugin->params);
         }
         if ($user->authorise('core.admin', 'com_cache')) {
             $file_cache = new JCache(array('defaultgroup' => 'rokbooster', 'caching' => true, 'checkTime' => true, 'storage' => 'file', 'cachebase' => JPATH_CACHE));
             $file_info_cache = new JCache(array('defaultgroup' => 'rokbooster', 'caching' => true, 'checkTime' => false));
             $generator_state_cache = new JCache(array('cachebase' => $conf->get('cache_path', JPATH_CACHE), 'lifetime' => 120, 'storage' => $conf->get('cache_handler', 'file'), 'defaultgroup' => 'rokbooster', 'locking' => true, 'locktime' => 15, 'checkTime' => true, 'caching' => true));
             $generator_state_cache->clean();
             $file_cache->clean();
             $file_info_cache->clean();
             $files = $file_cache->getAll();
             $filecount = 0;
             if (is_array($files) && array_key_exists('rokbooster', $files)) {
                 $filecount = $files['rokbooster']->count;
             }
             if ($plgParams->get('data_storage', 'default') == 'apc' && function_exists('apc_store')) {
                 $config = JFactory::getConfig();
                 $hash = preg_quote(md5($config->get('secret')));
                 if (class_exists('APCIterator')) {
                     $entries = new APCIterator('user', "/^{$hash}-rokbooster-dataentry-/");
                     apc_delete($entries);
                 } else {
                     $info = apc_cache_info('user');
                     foreach ($info['cache_list'] as $apc_cache_entry) {
                         if (strpos($apc_cache_entry['info'], "{$hash}-rokbooster-dataentry-") === 0) {
                             apc_delete($apc_cache_entry['info']);
                         }
                     }
                 }
             }
             echo sprintf('{"status":"success","message":"%d"}', $filecount);
         } else {
             echo '{"status": "error","message":"You do not have permissions to clear cache."}';
         }
     }
 }
 /**
  * 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());
 }
Beispiel #24
0
 /**
  * 
  * @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;
 }
 /**
  * Setup.
  *
  * @return void
  */
 protected function setUp()
 {
     parent::setUp();
     include_once JPATH_PLATFORM . '/joomla/cache/cache.php';
     include_once JPATH_PLATFORM . '/joomla/cache/storage.php';
     include_once JPATH_PLATFORM . '/joomla/cache/controller.php';
     // @todo remove: $this->object = JCache::getInstance('', array());
 }
Beispiel #26
0
 /**
  * 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);
 }
Beispiel #27
0
 /**
  * 
  * @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'};
 }
Beispiel #28
0
 /**
  * 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);
 }
Beispiel #29
0
 /**
  * TuiyoInitiate::TuiyoInitiate()
  * Application Initiation metod
  * @return
  */
 public function TuiyoInitiate()
 {
     TuiyoInitiate::_setDefines();
     TuiyoInitiate::_loadErrorHandler();
     TuiyoInitiate::_localize();
     jimport('joomla.cache.cache');
     $conf =& JFactory::getConfig();
     $options = array('defaultgroup' => 'com_tuiyo', 'cachebase' => $conf->getValue('config.cache_path'), 'lifetime' => $conf->getValue('config.cachetime') * 60, 'language' => $conf->getValue('config.language'), 'storage' => 'file');
     $cache = new JCache($options);
     $cache->setCaching($conf->getValue('config.caching'));
     $GLOBALS['TUIYO_CACHE'] = $cache;
     //Load the parameters for the site!
     if (class_exists('JSite')) {
         TuiyoInitiate::_params();
     }
     //load all the plugins
     TuiyoInitiate::registerPlugins();
 }
 /**
  * Method to get the field options.
  *
  * @return  array  The field option objects.
  *
  * @since   11.1
  */
 protected function getOptions()
 {
     $options = array();
     // Convert to name => name array.
     foreach (JCache::getStores() as $store) {
         $options[] = JHtml::_('select.option', $store, JText::_('JLIB_FORM_VALUE_CACHE_' . $store), 'value', 'text');
     }
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }