本文整理汇总了PHP中midcom_connection::get_unique_host_name方法的典型用法代码示例。如果您正苦于以下问题:PHP midcom_connection::get_unique_host_name方法的具体用法?PHP midcom_connection::get_unique_host_name怎么用?PHP midcom_connection::get_unique_host_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类midcom_connection
的用法示例。
在下文中一共展示了midcom_connection::get_unique_host_name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
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');
}
示例2: generate_request_identifier
/**
* 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=' . midcom_connection::get_user();
break;
}
if (midcom::get()) {
$identifier_source .= ';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];
}