Example #1
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);
 }
Example #2
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);
     }
 }
Example #3
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;
 }
	/**
	 * Testing Gc().
	 *
	 * @return void
	 */
	public function testGc()
	{
		$this->object = JCache::getInstance('output', array('lifetime' => 2, 'defaultgroup' => ''));
		$this->object->store(
			'Now is the time for all good people to throw a party.',
			42,
			''
		);
		$this->object->store(
			'And this is the cache that tries men\'s souls',
			42,
			''
		);
		sleep(5);
		$this->object->gc();
		$this->assertThat(
			$this->object->get(42, ''),
			$this->isFalse(),
			'Should not retrieve the data properly'
		);
		$this->assertThat(
			$this->object->get(42, ''),
			$this->isFalse(),
			'Should not retrieve the data properly'
		);
	}
 /**
  * Testing Gc().
  *
  * @medium
  *
  * @return void
  */
 public function testGc()
 {
     $this->object = JCache::getInstance('output', array('lifetime' => 2, 'defaultgroup' => ''));
     $this->object->store($this->testData_A, 42, '');
     $this->object->store($this->testData_B, 43, '');
     sleep(5);
     $this->object->gc();
     $this->assertFalse($this->object->get(42, ''));
     $this->assertFalse($this->object->get(43, ''));
 }
Example #6
0
 function save($content, $id)
 {
     // Store the cache string
     for ($i = 0; $i < 5; $i++) {
         if (parent::store(serialize($content), $id)) {
             return;
         }
     }
     parent::remove($id);
 }
Example #7
0
 /**
  * Store data to cache by ID and group
  *
  * @param   mixed    $data        The data to store
  * @param   string   $id          The cache data ID
  * @param   string   $group       The cache data group
  * @param   boolean  $wrkarounds  True to use wrkarounds
  *
  * @return  boolean  True if cache stored
  *
  * @since   11.1
  */
 public function store($data, $id, $group = null, $wrkarounds = true)
 {
     $locktest = $this->cache->lock($id, $group);
     if ($locktest->locked == false && $locktest->locklooped == true) {
         $locktest = $this->cache->lock($id, $group);
     }
     $success = $this->cache->store(serialize($data), $id, $group);
     if ($locktest->locked == true) {
         $this->cache->unlock($id, $group);
     }
     return $success;
 }
Example #8
0
 /**
  * Parse the template
  * 
  * This function implements a caching mechanism when reading the template. If
  * the tempplate 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.
  *
  * @return string	The filtered data
  */
 public function parse()
 {
     if (isset($this->_cache)) {
         $identifier = md5($this->_path);
         if (!($template = $this->_cache->get($identifier))) {
             $template = parent::parse();
             //Store the object in the cache
             $this->_cache->store($template, $identifier);
         }
         return $template;
     }
     return parent::parse();
 }
Example #9
0
 /**
  * Stop the cache buffer and store the cached data
  *
  * @access	public
  * @return	boolean	True if cache stored
  * @since	1.5
  */
 function store()
 {
     // Get page data from JResponse body
     $data = JResponse::getBody();
     // Get id and group and reset them placeholders
     $id = $this->_id;
     $group = $this->_group;
     $this->_id = null;
     $this->_group = null;
     // Only attempt to store if page data exists
     if ($data) {
         return parent::store($data, $id, $group);
     }
     return false;
 }
 /**
  * Store data to cache by id and group
  *
  * @param   mixed   $data   The data to store
  * @param   string  $id     The cache data id
  * @param   string  $group  The cache data group
  *
  * @return  boolean  True if cache was stored
  *
  * @since   11.1
  */
 public function store($data, $id, $group = null)
 {
     $locktest = new stdClass();
     $locktest->locked = null;
     $locktest->locklooped = null;
     $locktest = $this->cache->lock($id, $group);
     if ($locktest->locked == false && $locktest->locklooped == true) {
         $locktest = $this->cache->lock($id, $group);
     }
     $sucess = $this->cache->store(serialize($data), $id, $group);
     if ($locktest->locked == true) {
         $this->cache->unlock($id, $group);
     }
     return $sucess;
 }
Example #11
0
 /**
  * After render.
  *
  * @return   void
  *
  * @since   1.5
  */
 public function onAfterRender()
 {
     $app = JFactory::getApplication();
     if ($app->isAdmin()) {
         return;
     }
     if (count($app->getMessageQueue())) {
         return;
     }
     if ($this->isDisabled()) {
         return;
     }
     $user = JFactory::getUser();
     if ($user->get('guest') && $app->input->getMethod() == 'GET') {
         $this->_cache->store($this->optimize($app->getBody()), $this->_cache_key);
     }
 }
Example #12
0
 static function fetchXML($params, $force = 0)
 {
     $rssurl = $params->get('rss_url', '');
     $items_limit = intval($params->get('items_limit', 10));
     $doCache = intval($params->get('scr_cache', 1));
     $CacheTime = intval($params->get('cache_time', 3600));
     $twitter_timeline = $params->get('twitter_timeline', 'user');
     $username = $params->get('twitter_username', '');
     $password = $params->get('twitter_password', '');
     $list = $params->get('twitter_list', '');
     if ($twitter_timeline == 'friends') {
         $rssurl = 'http://api.twitter.com/1/statuses/friends_timeline.xml';
     } else {
         if ($twitter_timeline == 'mentions') {
             $rssurl = 'http://api.twitter.com/1/statuses/mentions.xml';
         } else {
             if ($twitter_timeline == 'list') {
                 $rssurl = 'http://api.twitter.com/1/' . urlencode($username) . '/lists/' . urlencode($list) . '/statuses.xml';
             } else {
                 if ($twitter_timeline == 'user_rt' && $username != '') {
                     $rssurl = 'http://api.twitter.com/1/statuses/user_timeline.xml?screen_name=' . urlencode($username) . '&include_rts=true';
                 } else {
                     if ($username != '') {
                         $rssurl = 'http://api.twitter.com/1/statuses/user_timeline/' . urlencode($username) . '.xml';
                     } else {
                         $rssurl = str_replace('.rss', '.xml', $rssurl);
                     }
                 }
             }
         }
     }
     $feed_desc = 1;
     $item_desc = 1;
     $feed_array = array();
     $xmlDoc =& JFactory::getXMLParser('Simple');
     if ($doCache) {
         if (!class_exists('JCache')) {
             require_once JPATH_SITE . DS . 'libraries' . DS . 'joomla' . DS . 'cache' . DS . 'cache.php';
         }
         $options = array('defaultgroup' => 'mod_ajaxscroller', 'lifetime' => $CacheTime, 'checkTime' => true, 'caching' => true);
         $cache = new JCache($options);
         $cache->setLifeTime($CacheTime);
         if ($force) {
             // delete the cache, force the new fetch
             $cache->remove(md5($rssurl), 'mod_ajaxscroller');
         }
         if ($string = $cache->get(md5($rssurl), 'mod_ajaxscroller')) {
             $xmlDoc->loadString($string);
         } else {
             $xml = simplexml_load_file($rssurl);
             $string = $xml->asXML();
             $string = str_replace('georss:', 'georss_', $string);
             // simplexml doesn't like ':'
             $xmlDoc->loadString($string);
             $cache->store($xmlDoc->document->toString(), md5($rssurl));
         }
     } else {
         $xml = simplexml_load_file($rssurl);
         $string = $xml->asXML();
         $string = str_replace('georss:', 'georss_', $string);
         // simplexml doesn't like ':'
         $xmlDoc->loadString($string);
     }
     $root =& $xmlDoc->document;
     $statuses =& $root->children();
     $length = count($statuses);
     $total = $items_limit && $items_limit < $length ? $items_limit : $length;
     if ($total == 0) {
         $feed_array = $xmlDoc->loadString($string);
     }
     for ($i = 0; $i < $total; $i++) {
         $status =& $statuses[$i];
         $id =& $status->getElementByPath('id')->data();
         $created_at =& $status->getElementByPath('created_at')->data();
         $text =& $status->getElementByPath('text')->data();
         $source =& $status->getElementByPath('source')->data();
         $in_reply_to_status_id =& $status->getElementByPath('in_reply_to_status_id')->data();
         $in_reply_to_user_id =& $status->getElementByPath('in_reply_to_user_id')->data();
         $in_reply_to_screen_name =& $status->getElementByPath('in_reply_to_screen_name')->data();
         $user_id =& $status->getElementByPath('user')->getElementByPath('id')->data();
         $user_screen_name =& $status->getElementByPath('user')->getElementByPath('screen_name')->data();
         $user_profile_image_url =& $status->getElementByPath('user')->getElementByPath('profile_image_url')->data();
         $feed_array[$i]['item_href'] = 'http://twitter.com/' . $user_screen_name . '/statuses/' . $id;
         $feed_array[$i]['item_date'] = $created_at;
         $feed_array[$i]['item_title'] = $user_screen_name;
         //$text = htmlentities($text);
         $feed_array[$i]['item_desc'] = modAjaxScrollerCommonHelper::ajax_scroller_format_twitter($text, $params, $user_profile_image_url, $user_screen_name, $created_at, $source, $in_reply_to_user_id, $in_reply_to_screen_name, $in_reply_to_status_id);
     }
     return $feed_array;
 }
Example #13
0
 private function checkSignupApiField($MC, $listId)
 {
     // create hidden signup date mergevar if it doesn't exist
     $cacheGroup = 'mod_mailchimpsignup';
     $cacheID = 'SIGNUPAPI_' . $listId;
     jimport('joomla.cache.cache');
     $cacheOptions = array();
     $cacheOptions['lifetime'] = 525949;
     $cacheOptions['defaultgroup'] = $cacheGroup;
     $cacheOptions['caching'] = true;
     $cache = new JCache($cacheOptions);
     if (!$cache->get($cacheID, $cacheGroup)) {
         $createSignupdateMerge = true;
         $listMergeVars = $MC->listMergeVars($listId);
         foreach ($listMergeVars as $lmv) {
             if ($lmv['tag'] == 'SIGNUPAPI') {
                 $createSignupdateMerge = false;
                 break;
             }
         }
         if ($createSignupdateMerge) {
             $MC->listMergeVarAdd($listId, 'SIGNUPAPI', 'date added (API)', array('field_type' => 'date', 'req' => false, 'public' => false, 'show' => true));
         }
         $cache->store(true, $cacheID, $cacheGroup);
     }
 }
 /**
  * Loads a single language file and appends the results to the existing strings
  *
  * @access	public
  * @param	string 	$extension 	The extension for which a language file should be loaded
  * @param	string 	$basePath  	The basepath to use
  * @param	string	$lang		The language to load, default null for the current language
  * @param	boolean $reload		Flag that will force a language to be reloaded if set to true
  * @return	boolean	True, if the file has successfully loaded.
  * @since	1.5
  */
 function load($extension = 'joomla', $basePath = JPATH_BASE, $lang = null, $reload = false)
 {
     if (!$lang) {
         $lang = $this->_lang;
     }
     if (!strlen($extension)) {
         $extension = 'joomla';
     }
     $path = JLanguage::getLanguagePath($basePath, $lang);
     $filename = $extension == 'joomla' ? $lang : $lang . '.' . $extension;
     $filename = $path . DS . $filename . '.ini';
     $result = true;
     if (!isset($this->_paths[$extension][$filename]) || $reload) {
         $identifier = md5($extension . $basePath . $lang);
         if (!isset($this->_cache)) {
             $this->_cache = JFactory::getCache('language', 'output');
         }
         if (!($data = $this->_cache->get($identifier))) {
             // Load the language file
             $strings = $this->_load($filename, $extension, true);
             // Check if there was a problem with loading the file
             if ($strings === false) {
                 // No strings, which probably means that the language file does not exist
                 $path = JLanguage::getLanguagePath($basePath, $this->_default);
                 $filename = $extension == 'joomla' ? $this->_default : $this->_default . '.' . $extension;
                 $filename = $path . DS . $filename . '.ini';
                 $strings = $this->_load($filename, $extension, false);
                 if ($strings !== false) {
                     $this->_strings = array_merge($strings, $this->_strings);
                 }
             } else {
                 $this->_strings = array_merge($this->_strings, (array) $strings);
             }
             //Store the strings in the cache
             if ($strings !== false) {
                 $this->_cache->store(serialize($strings), $identifier);
             }
         } else {
             $this->_strings = array_merge($this->_strings, array_reverse(unserialize($data)));
         }
     }
     return $result;
 }
 /**
  * @param RokBooster_Compressor_FileGroup $group
  */
 protected function storeFileInfo(RokBooster_Compressor_FileGroup $group)
 {
     $group->cleanup();
     $this->file_info_cache->store(serialize($group), $group->getChecksum() . '_fileinfo');
 }
 /**
  * Sets data to cache
  *
  * @param string $groupName  Name of group of cache
  * @param string $identifier Identifier of data
  * @param mixed  $data       Data
  *
  * @return boolean
  */
 public function set($groupName, $identifier, $data)
 {
     return $this->cache->store(serialize($data), $identifier);
 }
Example #17
0
 public function display($tpl = null)
 {
     if (!JOOMLAMAILER_MANAGE_REPORTS) {
         $this->app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'), 'error');
         $this->app->redirect('index.php?option=com_joomailermailchimpintegration');
     }
     $this->setModel($this->getModelInstance('main'));
     $this->setModel($this->getModelInstance('campaignlist'));
     $option = JRequest::getCmd('option');
     $cacheGroup = 'joomlamailerReports';
     $cacheOptions = array();
     $cacheOptions['cachebase'] = JPATH_ADMINISTRATOR . '/cache';
     $cacheOptions['lifetime'] = 31556926;
     $cacheOptions['storage'] = 'file';
     $cacheOptions['defaultgroup'] = 'joomlamailerReports';
     $cacheOptions['locking'] = false;
     $cacheOptions['caching'] = true;
     $cache = new JCache($cacheOptions);
     require_once JPATH_COMPONENT . '/helpers/JoomlamailerCache.php';
     $mainframe = JFactory::getApplication();
     $layout = JRequest::getVar('layout', '', '', 'string');
     $limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int');
     $limitstart = $mainframe->getUserStateFromRequest($layout . '.limitstart', $layout . 'limitstart', 0, 'int');
     if ($layout == 'sharereport') {
         $document = JFactory::getDocument();
         $document->addStyleSheet(JURI::root() . 'media/com_joomailermailchimpintegration/backend/css/shareReport.css');
         $document->addScript(JURI::root() . 'media/com_joomailermailchimpintegration/backend/js/joomlamailer.shareReport.js');
         JToolBarHelper::title(JText::_('JM_NEWSLETTER_SHARE_REPORT'), $this->getPageTitleClass());
     } else {
         JToolBarHelper::title(JText::_('JM_NEWSLETTER_CAMPAIGN_STATS'), $this->getPageTitleClass());
     }
     if ($layout != '') {
         JToolBarHelper::custom('goToCampaigns', 'reports', 'reports', 'JM_REPORTS', false);
     }
     if ($layout == 'clickedlinks') {
         $cid = JRequest::getVar('cid', 0, '', 'string');
         $clicked = $this->getModel()->getClicks($cid);
         foreach ($clicked as $index => $data) {
             if (!$data['clicks']) {
                 unset($clicked[$index]);
             }
         }
         $this->assignRef('clicked', $clicked);
         $this->assignRef('limitstart', $limitstart);
         $this->assignRef('limit', $limit);
         jimport('joomla.html.pagination');
         $pagination = new JPagination(count($clicked), $limitstart, $limit, $layout);
         $this->assignRef('pagination', $pagination);
     } else {
         if ($layout == 'clickedlinkdetails') {
             $cid = JRequest::getVar('cid', 0, '', 'string');
             $url = urldecode(JRequest::getVar('url', '', '', 'string'));
             $clicks = $this->getModel()->getClicksAIM($cid, $url);
             $this->assignRef('clicks', $clicks);
             $this->assignRef('limitstart', $limitstart);
             $this->assignRef('limit', $limit);
             jimport('joomla.html.pagination');
             $pagination = new JPagination(count($clicks), $limitstart, $limit, $layout);
             $this->assignRef('pagination', $pagination);
         } else {
             if ($layout == 'clicked') {
                 $cid = JRequest::getVar('cid', 0, '', 'string');
                 $clicked = $this->getModel()->getCampaignEmailStatsAIMAll($cid, $limitstart, 1000);
                 $i = 0;
                 $click = array();
                 foreach ($clicked as $key => $value) {
                     $unset = true;
                     foreach ($value as $v) {
                         if ($v['action'] == 'click') {
                             $unset = false;
                         }
                     }
                     if (!$unset) {
                         $click[$key] = $clicked[$key];
                         $i++;
                     }
                     if ($i == $limit) {
                         break;
                     }
                 }
                 $this->assignRef('clicked', $click);
                 $this->assignRef('limitstart', $limitstart);
                 $this->assignRef('limit', $limit);
                 $total = $this->getModel()->getCampaignStats($cid);
                 jimport('joomla.html.pagination');
                 $pagination = new JPagination($total['unique_clicks'], $limitstart, $limit, $layout);
                 $this->assignRef('pagination', $pagination);
             } else {
                 if ($layout == 'recipients') {
                     $cid = JRequest::getVar('cid', 0, '', 'string');
                     $url = urldecode(JRequest::getVar('url', 0, '', 'string'));
                     $clicked = $this->getModel()->getCampaignEmailStatsAIMAll($cid, $limitstart, $limit);
                     $campaignStats = $this->getModel()->getCampaignStats($cid);
                     $this->assignRef('clicked', $clicked);
                     $this->assignRef('limitstart', $limitstart);
                     $this->assignRef('limit', $limit);
                     jimport('joomla.html.pagination');
                     $pagination = new JPagination($campaignStats['emails_sent'], $limitstart, $limit, $layout);
                     $this->assignRef('pagination', $pagination);
                 } else {
                     if ($layout == 'opened') {
                         $cid = JRequest::getVar('cid', 0, '', 'string');
                         $items = $this->getModel()->getOpens($cid);
                         $this->assignRef('limitstart', $limitstart);
                         $this->assignRef('limit', $limit);
                         jimport('joomla.html.pagination');
                         $pagination = new JPagination(count($items), $limitstart, $limit, $layout);
                         $this->assignRef('pagination', $pagination);
                     } else {
                         if ($layout == 'abuse') {
                             $cid = JRequest::getVar('cid', 0, '', 'string');
                             $items = $this->getModel()->getAbuse($cid);
                             $this->assignRef('limitstart', $limitstart);
                             $this->assignRef('limit', $limit);
                             jimport('joomla.html.pagination');
                             $pagination = new JPagination(count($items), $limitstart, $limit, $layout);
                             $this->assignRef('pagination', $pagination);
                         } else {
                             if ($layout == 'unsubscribes') {
                                 $cid = JRequest::getVar('cid', 0, '', 'string');
                                 $items = $this->getModel()->getUnsubscribes($cid);
                                 $this->assignRef('limitstart', $limitstart);
                                 $this->assignRef('limit', $limit);
                                 jimport('joomla.html.pagination');
                                 $pagination = new JPagination(count($items), $limitstart, $limit, $layout);
                                 $this->assignRef('pagination', $pagination);
                             } else {
                                 if ($layout == 'sharereport') {
                                     $cid = JRequest::getVar('cid', '', 'get', 'string');
                                     $this->setModel($this->getModelInstance('campaigns'));
                                     $cData = $this->getModel('campaigns')->getCampaignData($cid);
                                     $name = isset($cData[0]->name) ? $cData[0]->name : $cData[0]['title'];
                                     $this->assignRef('name', $name);
                                     $data = $this->getModel('campaigns')->getShareReport($cid, JText::_('JM_CAMPAIGN_REPORT') . ': ' . $name);
                                     $this->assignRef('data', $data);
                                     $this->setModel($this->getModelInstance('templates'));
                                     $palettes = $this->getModel('templates')->getPalettes();
                                     $this->assignRef('palettes', $palettes);
                                 } else {
                                     $document = JFactory::getDocument();
                                     $document->addStyleSheet(JURI::root() . 'media/com_joomailermailchimpintegration/backend/css/campaigns.css');
                                     $JoomlamailerMC = new JoomlamailerMC();
                                     if (!$JoomlamailerMC->pingMC()) {
                                         $user = JFactory::getUser();
                                         if ($user->authorise('core.admin', 'com_joomailermailchimpintegration')) {
                                             JToolBarHelper::preferences('com_joomailermailchimpintegration', '450');
                                             JToolBarHelper::spacer();
                                         }
                                     } else {
                                         JToolBarHelper::custom('shareReport', 'shareReport', 'shareReport', 'JM_SEND_REPORT', true, false);
                                         JToolBarHelper::spacer();
                                         JToolBarHelper::custom('analytics', 'reports', 'reports', 'Analytics360°', false, false);
                                         JToolBarHelper::spacer();
                                         $user = JFactory::getUser();
                                         if ($user->authorise('core.admin', 'com_joomailermailchimpintegration')) {
                                             JToolBarHelper::preferences('com_joomailermailchimpintegration', '450');
                                             JToolBarHelper::spacer();
                                         }
                                         //	JToolBarHelper::custom('delete', 'delete', 'delete', 'JM_DELETE_REPORT', true, false);
                                         $tmp = array(array('folder_id' => 0, 'name' => '- ' . JText::_('JM_SELECT_FOLDER') . ' -'));
                                         $folders = $this->getModel('campaignlist')->getFolders();
                                         $folders = array_merge($tmp, $folders);
                                         $folder_id = JRequest::getVar('folder_id', 0, '', 'int');
                                         $foldersDropDown = JHTML::_('select.genericlist', $folders, 'folder_id', 'onchange="document.adminForm.submit();"', 'folder_id', 'name', $folder_id);
                                         $this->assignRef('foldersDropDown', $foldersDropDown);
                                         $limit = JRequest::getVar('limit', 5, '', 'int');
                                         $cacheID = 'sent_campaigns';
                                         if (!$cache->get($cacheID, $cacheGroup)) {
                                             $campaigns = array();
                                             $res = 'not empty';
                                             $page = 0;
                                             while (!empty($res)) {
                                                 $res = $this->getModel()->getCampaigns(array('status' => 'sent'), $page, 1000);
                                                 if ($res) {
                                                     $campaigns = array_merge($campaigns, $res);
                                                     if (count($res) < 1000) {
                                                         break;
                                                     }
                                                     $page++;
                                                 }
                                             }
                                             if (count($campaigns)) {
                                                 foreach ($campaigns as $c) {
                                                     $stats = $this->getModel()->getCampaignStats($c['id']);
                                                     $advice = $this->getModel()->getAdvice($c['id']);
                                                     if ($stats) {
                                                         $items[$c['id']]['folder_id'] = $c['folder_id'];
                                                         $items[$c['id']]['title'] = $c['title'];
                                                         $items[$c['id']]['subject'] = $c['subject'];
                                                         $items[$c['id']]['send_time'] = $c['send_time'];
                                                         $items[$c['id']]['emails_sent'] = $c['emails_sent'];
                                                         $items[$c['id']]['stats'] = $stats;
                                                         $items[$c['id']]['advice'] = $advice;
                                                         $items[$c['id']]['archive_url'] = $c['archive_url'];
                                                         $items[$c['id']]['twitter'] = $this->getModel()->getTwitterStats($c['id']);
                                                         $items[$c['id']]['geo'] = $this->getModel()->getGeoStats($c['id']);
                                                     } else {
                                                         $items[$c['id']]['folder_id'] = $c['folder_id'];
                                                         $items[$c['id']]['title'] = $c['title'];
                                                         $items[$c['id']]['subject'] = $c['subject'];
                                                         $items[$c['id']]['send_time'] = $c['send_time'];
                                                         $items[$c['id']]['emails_sent'] = $c['emails_sent'];
                                                         $items[$c['id']]['stats'] = '';
                                                         $items[$c['id']]['advice'] = '';
                                                         $items[$c['id']]['archive_url'] = $c['archive_url'];
                                                         $items[$c['id']]['twitter'] = $this->getModel()->getTwitterStats($c['id']);
                                                         $items[$c['id']]['geo'] = $this->getModel()->getGeoStats($c['id']);
                                                     }
                                                 }
                                             }
                                             $cache->store(json_encode($items), $cacheID, $cacheGroup);
                                         }
                                         $campaigns = json_decode($cache->get($cacheID, $cacheGroup), true);
                                         // get timestamp of when the cache was modified
                                         $joomlamailerCache = new JoomlamailerCache('file');
                                         $cacheDate = $joomlamailerCache->getCreationTime($cacheID, $cacheGroup);
                                         $this->assignRef('cacheDate', $cacheDate);
                                         if ($folder_id) {
                                             foreach ($campaigns as $k => $v) {
                                                 if ($v['folder_id'] != $folder_id) {
                                                     unset($campaigns[$k]);
                                                 }
                                             }
                                         }
                                         $total = count($campaigns);
                                         $items = array();
                                         $x = 0;
                                         if ($total) {
                                             foreach ($campaigns as $k => $v) {
                                                 if ($x == $limitstart + $limit) {
                                                     break;
                                                 }
                                                 if ($x >= $limitstart) {
                                                     $items[$k] = $v;
                                                 }
                                                 $x++;
                                             }
                                         }
                                         jimport('joomla.html.pagination');
                                         $pagination = new JPagination($total, $limitstart, $limit, $layout);
                                         $this->assignRef('pagination', $pagination);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $this->assignRef('items', $items);
     parent::display($tpl);
     require_once JPATH_COMPONENT . '/helpers/jmFooter.php';
 }