Beispiel #1
1
 /**
  * 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());
 }
 function checkCache()
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     if ($this->_recache) {
         $this->_cache->remove($this->_cache_key);
         return;
     }
     if ($app->isAdmin() || $this->isDisabled() || count($app->getMessageQueue()) || $user->get('admin') || $app->input->getMethod() !== 'GET') {
         return;
     }
     $data = $this->_cache->get($this->_cache_key);
     if (false === strpos($data, sprintf('cached:%d', $this->_cache_version))) {
         // Logger::d('ERROR: Cache version mismatch');
         return;
     }
     if ($data !== false) {
         // Set cached body.
         $app->setBody($data);
         echo $app->toString($app->get('gzip'));
         // Logger::d(__METHOD__.' from cache');
         $app->close();
         exit;
     }
 }
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());
 }
 /**
  * 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 #5
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 #6
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);
     }
 }
 /**
  * Get stored cached data by id and group
  *
  * @param   string  $id     The cache data id
  * @param   string  $group  The cache data group
  *
  * @return  mixed   False on no result, cached object otherwise
  *
  * @since   11.1
  */
 public function get()
 {
     $numargs = func_num_args();
     if ($numargs <= 0) {
         return false;
     }
     $id = func_get_arg(0);
     $group = $numargs > 1 ? func_get_arg(1) : null;
     $data = $this->cache->get($id, $group);
     if ($data === false) {
         $locktest = new stdClass();
         $locktest->locked = null;
         $locktest->locklooped = null;
         $locktest = $this->cache->lock($id, $group);
         if ($locktest->locked == true && $locktest->locklooped == true) {
             $data = $this->cache->get($id, $group);
         }
         if ($locktest->locked == true) {
             $this->cache->unlock($id, $group);
         }
     }
     // Check again because we might get it from second attempt
     if ($data !== false) {
         $data = unserialize(trim($data));
         // trim to fix unserialize errors
     }
     return $data;
 }
Beispiel #8
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());
 }
 /**
  * @param $checksum
  *
  * @return bool|mixed
  */
 protected function isOutputExpired(RokBooster_Compressor_IGroup $group, $is_wrapped = true)
 {
     $oc = RokBooster_Compressor_OutputContainerFactory::create($group, $this->options);
     if (!$oc->doesExist($is_wrapped)) {
         return true;
     }
     if ($expired = $oc->isExpired($is_wrapped)) {
         $files_changed = false;
         if ($file_group = $this->file_info_cache->get($group->getChecksum() . '_fileinfo')) {
             $file_group = unserialize($file_group);
             /** @var $file RokBooster_Compressor_File */
             foreach ($file_group as $file) {
                 if (file_exists($file->getPath()) && is_readable($file->getPath())) {
                     if ($file->hasChanged()) {
                         $files_changed = true;
                         break;
                     }
                 } else {
                     $this->file_info_cache->remove($group->getChecksum() . '_fileinfo');
                     $files_changed = true;
                     break;
                 }
             }
         } else {
             $files_changed = true;
         }
         if (!$files_changed) {
             $oc->setAsValid();
             return false;
         }
     }
     return $expired;
 }
Beispiel #10
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 #11
0
 /**
  * Get the cached page data
  *
  * @access	public
  * @param	string	$id		The cache data id
  * @param	string	$group	The cache data group
  * @return	boolean	True if the cache is hit (false else)
  * @since	1.5
  */
 function get($id = false, $group = 'page')
 {
     // Initialize variables
     $data = false;
     // If an id is not given generate it from the request
     if ($id == false) {
         $id = $this->_makeId();
     }
     // If the etag matches the page id ... sent a no change header and exit : utilize browser cache
     if (!headers_sent() && isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
         $etag = stripslashes($_SERVER['HTTP_IF_NONE_MATCH']);
         if ($etag == $id) {
             $browserCache = isset($this->_options['browsercache']) ? $this->_options['browsercache'] : false;
             if ($browserCache) {
                 $this->_noChange();
             }
         }
     }
     // We got a cache hit... set the etag header and echo the page data
     $data = parent::get($id, $group);
     if ($data !== false) {
         $this->_setEtag($id);
         return $data;
     }
     // Set id and group placeholders
     $this->_id = $id;
     $this->_group = $group;
     return false;
 }
	/**
	 * Get stored cached data by id and group
	 *
	 * @param   string  $id     The cache data id
	 * @param   string  $group  The cache data group
	 *
	 * @return  mixed   False on no result, cached object otherwise
	 *
	 * @since   11.1
	 */
	public function get($id, $group = null)
	{
		$data = false;
		$data = $this->cache->get($id, $group);

		if ($data === false)
		{
			$locktest = new stdClass;
			$locktest->locked = null;
			$locktest->locklooped = null;
			$locktest = $this->cache->lock($id, $group);

			if ($locktest->locked == true && $locktest->locklooped == true)
			{
				$data = $this->cache->get($id, $group);
			}
			if ($locktest->locked == true)
			{
				$this->cache->unlock($id, $group);
			}
		}

		// Check again because we might get it from second attempt
		if ($data !== false)
		{
			// Trim to fix unserialize errors
			$data = unserialize(trim($data));
		}
		return $data;
	}
	/**
	 * 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'
		);
	}
 /**
  * @param $checksum
  *
  * @return bool|mixed
  */
 protected function isCacheExpired($checksum)
 {
     if (!$this->cache->doesCacheExist($checksum)) {
         return true;
     }
     if ($expired = $this->cache->isCacheExpired($checksum)) {
         $files_changed = false;
         if ($file_group = $this->file_info_cache->get($checksum . '_fileinfo')) {
             $file_group = unserialize($file_group);
             /** @var $file RokBooster_Compressor_File */
             foreach ($file_group as $file) {
                 if (file_exists($file->getPath()) && is_readable($file->getPath())) {
                     if ($file->hasChanged()) {
                         $files_changed = true;
                         break;
                     }
                 } else {
                     $this->file_info_cache->remove($checksum . '_fileinfo');
                     $files_changed = true;
                     break;
                 }
             }
         } else {
             $files_changed = true;
         }
         if (!$files_changed) {
             $this->cache->setCacheAsValid($checksum);
             return false;
         }
     }
     return $expired;
 }
 /**
  * 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, ''));
 }
Beispiel #16
0
 /**
  * Recupera los valores del tag indicado
  *
  * @param int id identificador del tag
  * @return array Arreglo de objetos value
  */
 function getMenuValues($id)
 {
     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') . ' 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') . ' WHERE ' . $dbo->nameQuote('v.field_id') . ' = ' . $id;
     $dbo->setQuery($query);
     return $this->_cache->get(array($dbo, 'loadObjectList'), array());
 }
Beispiel #17
0
 function load($id)
 {
     $content = parent::get($id);
     if ($content === false) {
         return false;
     }
     $cache = @unserialize($content);
     if ($cache === false || !is_array($cache)) {
         return false;
     }
     return $cache;
 }
Beispiel #18
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();
 }
Beispiel #19
0
 /**
  * Executes a cacheable callback if not found in cache else returns cached output and result
  *
  * @access	public
  * @param	mixed	Callback or string shorthand for a callback
  * @param	array	Callback arguments
  * @return	mixed	Result of the callback
  * @since	1.5
  */
 function get($callback, $args, $id = false)
 {
     // Normalize callback
     if (is_array($callback)) {
         // We have a standard php callback array -- do nothing
     } elseif (strstr($callback, '::')) {
         // This is shorthand for a static method callback classname::methodname
         list($class, $method) = explode('::', $callback);
         $callback = array(trim($class), trim($method));
     } elseif (strstr($callback, '->')) {
         /*
          * This is a really not so smart way of doing this... we provide this for backward compatability but this
          * WILL!!! disappear in a future version.  If you are using this syntax change your code to use the standard
          * PHP callback array syntax: <http://php.net/callback>
          *
          * We have to use some silly global notation to pull it off and this is very unreliable
          */
         list($object_123456789, $method) = explode('->', $callback);
         global ${$object_123456789};
         $callback = array(${$object_123456789}, $method);
     } else {
         // We have just a standard function -- do nothing
     }
     if (!$id) {
         // Generate an ID
         $id = $this->_makeId($callback, $args);
     }
     // Get the storage handler and get callback cache data by id and group
     $data = parent::get($id);
     if ($data !== false) {
         $cached = unserialize($data);
         $output = $cached['output'];
         $result = $cached['result'];
     } else {
         ob_start();
         ob_implicit_flush(false);
         $result = call_user_func_array($callback, $args);
         $output = ob_get_contents();
         ob_end_clean();
         $cached = array();
         $cached['output'] = $output;
         $cached['result'] = $result;
         // Store the cache data
         $this->store(serialize($cached), $id);
     }
     echo $output;
     return $result;
 }
Beispiel #20
0
 /**
  * Default method to proccess html export
  * 
  * @return Boolean TRUE if success
  */
 public function createPages()
 {
     $result = false;
     if (empty($this->items)) {
         return false;
     }
     $cache_id = md5(get_class($this) . '_requestPageItems_' . count($this->items));
     $this->_links['menu'] = $this->_cache->get(array($this, '_requestPageItems'), array($this->items), $cache_id);
     //items not necessary anymore
     unset($this->items);
     //register menu links in class
     StaticContentHelperMenu::setLinks(JArrayHelper::getColumn($this->_links['menu'], 'full'));
     $cache_id = md5(get_class($this) . '_discoverInteralLinks' . count($this->_links['menu']));
     $arrData = $this->_cache->get(array($this, '_discoverInteralLinks'), array(), $cache_id);
     $this->_links = array_merge($this->_links, $arrData);
     $return = $this->_writePages();
     echo $return ? JText::_('COM_STATICCONTENT_MSG_SUCCESS_CREATED_SITE') : JText::_('COM_STATICCONTENT_MSG_FAILURE_CREATED_SITE');
 }
Beispiel #21
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;
 }
Beispiel #22
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';
 }
 /**
  * Gets data from cache
  *
  * @param string $groupName  Name of group
  * @param string $identifier Identifier of data
  *
  * @return mixed
  */
 public function get($groupName, $identifier)
 {
     return unserialize($this->cache->get($identifier));
 }
 /**
  * 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;
 }
Beispiel #25
0
 /**
  * Get the cached view data
  *
  * @access	public
  * @param	object	$view	The view object to cache output for
  * @param	string	$method	The method name of the view method to cache output for
  * @param	string	$group	The cache data group
  * @param	string	$id		The cache data id
  * @return	boolean	True if the cache is hit (false else)
  * @since	1.5
  */
 function get(&$view, $method, $id = false)
 {
     global $mainframe;
     // Initialize variables
     $data = false;
     // If an id is not given generate it from the request
     if ($id == false) {
         $id = $this->_makeId($view, $method);
     }
     $data = parent::get($id);
     if ($data !== false) {
         $data = unserialize($data);
         $document =& JFactory::getDocument();
         // Get the document head out of the cache.
         $document->setHeadData(isset($data['head']) ? $data['head'] : array());
         // If the pathway buffer is set in the cache data, get it.
         if (isset($data['pathway']) && is_array($data['pathway'])) {
             // Push the pathway data into the pathway object.
             $pathway =& $mainframe->getPathWay();
             $pathway->setPathway($data['pathway']);
         }
         // If a module buffer is set in the cache data, get it.
         if (isset($data['module']) && is_array($data['module'])) {
             // Iterate through the module positions and push them into the document buffer.
             foreach ($data['module'] as $name => $contents) {
                 $document->setBuffer($contents, 'module', $name);
             }
         }
         // Get the document body out of the cache.
         echo isset($data['body']) ? $data['body'] : null;
         return true;
     }
     /*
      * No hit so we have to execute the view
      */
     if (method_exists($view, $method)) {
         $document =& JFactory::getDocument();
         // Get the modules buffer before component execution.
         $buffer1 = $document->getBuffer();
         // Make sure the module buffer is an array.
         if (!isset($buffer1['module']) || !is_array($buffer1['module'])) {
             $buffer1['module'] = array();
         }
         // Capture and echo output
         ob_start();
         ob_implicit_flush(false);
         $view->{$method}();
         $data = ob_get_contents();
         ob_end_clean();
         echo $data;
         /*
          * For a view we have a special case.  We need to cache not only the output from the view, but the state
          * of the document head after the view has been rendered.  This will allow us to properly cache any attached
          * scripts or stylesheets or links or any other modifications that the view has made to the document object
          */
         $cached = array();
         // View body data
         $cached['body'] = $data;
         // Document head data
         $cached['head'] = $document->getHeadData();
         // Pathway data
         $pathway =& $mainframe->getPathWay();
         $cached['pathway'] = $pathway->getPathway();
         // Get the module buffer after component execution.
         $buffer2 = $document->getBuffer();
         // Make sure the module buffer is an array.
         if (!isset($buffer2['module']) || !is_array($buffer2['module'])) {
             $buffer2['module'] = array();
         }
         // Compare the second module buffer against the first buffer.
         $cached['module'] = array_diff_assoc($buffer2['module'], $buffer1['module']);
         // Store the cache data
         $this->store(serialize($cached), $id);
     }
     return false;
 }
Beispiel #26
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);
     }
 }