本文整理汇总了PHP中midcom_core_context::get_all方法的典型用法代码示例。如果您正苦于以下问题:PHP midcom_core_context::get_all方法的具体用法?PHP midcom_core_context::get_all怎么用?PHP midcom_core_context::get_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类midcom_core_context
的用法示例。
在下文中一共展示了midcom_core_context::get_all方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_all_contexts
/**
* Returns the complete context data array
*
* @return array The data of all contexts
*/
function get_all_contexts()
{
return midcom_core_context::get_all();
}
示例2: _complete_sent_headers
/**
* This little helper ensures that the headers Accept-Ranges, Content-Length
* and Last-Modified are present. The lastmod timestamp is taken out of the
* component context information if it is populated correctly there; if not, the
* system time is used instead.
*
* To force browsers to revalidate the page on every request (login changes would
* go unnoticed otherwise), the Cache-Control header max-age=0 is added automatically.
*
* @param Array &$cache_data The current cache data that will be written to the database.
*/
private function _complete_sent_headers(&$cache_data)
{
// Detected headers flags
$ranges = false;
$size = false;
$lastmod = false;
foreach ($this->_sent_headers as $header) {
if (strncasecmp($header, 'Accept-Ranges', 13) == 0) {
$ranges = true;
} else {
if (strncasecmp($header, 'Content-Length', 14) == 0) {
$size = true;
} else {
if (strncasecmp($header, 'Last-Modified', 13) == 0) {
$lastmod = true;
// Populate last modified timestamp (force GMT):
$tmp = substr($header, 15);
if (strpos($tmp, 'GMT') === false) {
$tmp .= ' GMT';
}
$this->_last_modified = strtotime($tmp);
if ($this->_last_modified == -1) {
debug_add("Failed to extract the timecode from the last modified header '{$header}', defaulting to the current time.", MIDCOM_LOG_WARN);
$this->_last_modified = time();
}
}
}
}
}
if (!$ranges) {
$header = "Accept-Ranges: none";
_midcom_header($header);
$this->_sent_headers[] = $header;
}
if (!$size) {
/* TODO: Doublecheck the way this is handled, it seems it's one byte too short
which causes issues with Squid for example (could be that we output extra
whitespace somewhere or something), now we just don't send it if headers_strategy
implies caching */
switch ($this->_headers_strategy) {
case 'public':
case 'private':
break;
default:
$header = "Content-Length: " . ob_get_length();
_midcom_header($header);
$this->_sent_headers[] = $header;
break;
}
}
if (!$lastmod) {
/* Determine Last-Modified using MidCOM's component context,
* Fallback to time() if this fails.
*/
$time = 0;
foreach (midcom_core_context::get_all() as $id => $context) {
$meta = midcom::get('metadata')->get_request_metadata($id);
if ($meta['lastmodified'] > $time) {
$time = $meta['lastmodified'];
}
}
if ($time == 0 || !is_numeric($time)) {
$time = time();
}
$header = "Last-Modified: " . gmdate('D, d M Y H:i:s', $time) . ' GMT';
_midcom_header($header);
$this->_sent_headers[] = $header;
$this->_last_modified = $time;
}
$this->cache_control_headers();
if (is_array($this->_force_headers) && !empty($this->_force_headers)) {
foreach ($this->_force_headers as $header => $value) {
$header_string = "{$header}: {$value}";
_midcom_header($header_string, true);
$this->_replace_sent_header($header, $header_string);
}
}
}