public function __construct($index_name = null) { if (is_null($index_name)) { $this->_index_name = $GLOBALS['midcom_config']['indexer_index_name']; if ($this->_index_name == 'auto') { $this->_index_name = midcom_connection::get_unique_host_name(); } } else { $this->_index_name = $index_name; } $this->xml = new DomDocument('1.0', 'UTF-8'); }
/** * Generate a valid cache identifier for a context of the current request */ function generate_request_identifier($context, $customdata = null) { $module_name = $GLOBALS['midcom_config']['cache_module_content_name']; if ($module_name == 'auto') { $module_name = midcom_connection::get_unique_host_name(); } $identifier_source = 'CACHE:' . $module_name; // Cache the request identifier so that it doesn't change between start and end of request static $identifier_cache = array(); if (isset($identifier_cache[$context])) { // FIXME: Use customdata here too return $identifier_cache[$context]; } if (!isset($customdata['cache_module_content_caching_strategy'])) { $cache_strategy = $GLOBALS['midcom_config']['cache_module_content_caching_strategy']; } else { $cache_strategy = $customdata['cache_module_content_caching_strategy']; } switch ($cache_strategy) { case 'memberships': if (!midcom_connection::get_user()) { $identifier_source .= ';USER=ANONYMOUS'; break; } $mc = new midgard_collector('midgard_member', 'uid', midcom_connection::get_user()); $mc->set_key_property('gid'); $mc->execute(); $gids = $mc->list_keys(); unset($mc); $identifier_source .= ';GROUPS=' . implode(',', array_keys($gids)); unset($gids); break; case 'public': $identifier_source .= ';USER=EVERYONE'; break; case 'user': default: $identifier_source .= ';USER='******';URL=' . midcom_core_context::get()->get_key(MIDCOM_CONTEXT_URI); } else { $identifier_source .= ';URL=' . $_SERVER['REQUEST_URI']; } // check_dl_hit needs to take config changes into account... if (!is_null($customdata)) { $identifier_source .= ';' . serialize($customdata); } // TODO: Add browser capability data (mobile, desktop browser etc) from WURFL here debug_add("Generating context {$context} request-identifier from: {$identifier_source}"); debug_print_r('$customdata was: ', $customdata); $identifier_cache[$context] = 'R-' . md5($identifier_source); return $identifier_cache[$context]; }