page_manager_context.inc in Chaos Tool Suite (ctools) 7
File
page_manager/plugins/cache/page_manager_context.inc
View source
<?php
$plugin = array(
'title' => t('Page manager context'),
'cache get' => 'page_manager_cache_page_manager_context_cache_get',
'cache set' => 'page_manager_cache_page_manager_context_cache_set',
'cache finalize' => 'page_manager_cache_page_manager_context_cache_finalize',
);
function page_manager_cache_page_manager_context_cache_get($data, $key) {
$page = page_manager_get_page_cache($data);
if ($page) {
if (!empty($page->context_cache[$key])) {
return $page->context_cache[$key];
}
else {
ctools_include('context-task-handler');
if ($key == 'temp') {
$handler = $page->new_handler;
}
else {
$handler = $page->handlers[$key];
}
return ctools_context_handler_get_task_object($page->task, $page->subtask, $handler);
}
}
}
function page_manager_cache_page_manager_context_cache_set($data, $key, $object) {
$page = page_manager_get_page_cache($data);
if ($page) {
$page->context_cache[$key] = $object;
return page_manager_set_page_cache($page);
}
}
function page_manager_cache_page_manager_context_cache_finalize($data, $key, $object) {
$page = page_manager_get_page_cache($data);
if ($page) {
if ($key == 'temp') {
$handler = $page->new_handler;
}
else {
$handler = $page->handlers[$key];
}
$handler->conf['contexts'] = $object->contexts;
$handler->conf['relationships'] = $object->relationships;
if (isset($page->context_cache[$key])) {
unset($page->context_cache[$key]);
}
return page_manager_set_page_cache($page);
}
}