function esi_panels__esi_pane_prepare in ESI: Edge Side Includes 7.3
Prepare an ESI panels pane for rendering. Defined in hook_esi_component_info().
See also
esi_panels_esi_component_info().
1 string reference to 'esi_panels__esi_pane_prepare'
- esi_panels_esi_component_info in modules/
esi_panels/ esi_panels.module - Implements hook_esi_component().
File
- modules/
esi_panels/ esi_panels.esi.inc, line 13
Code
function esi_panels__esi_pane_prepare($component_key) {
// The URL pattern approximately corresponds to the function arguments:
// 1. A component key, which is a colon-separated set of pieces of
// information: the theme name, the display ID and the pane ID.
// 2. An optional task name.
// 3. A variable number of arguments to the display.
// 4. The original URL.
// Use the parameters to reconstruct:
// - Display
// - Pane
// - Contexts
list($theme, $did, $pid) = explode(':', $component_key);
// Check for optional args.
$args = array_slice(func_get_args(), 1);
// Cache mode is the last argument, and url is second-to-last.
$cache_mode = array_pop($args);
$url = array_pop($args);
if ($did) {
// Task-name and context identifier are next in the URL, if context is used
// by the pane.
$display = panels_load_display($did);
$pane = $display->content[$pid];
}
else {
// If no did, try to look for panels_display from exported code.
ctools_include('export');
$panelizer_defaults = ctools_export_load_object('panelizer_defaults');
foreach ($panelizer_defaults as $name => $panelizer_default) {
if (!empty($panelizer_default->display->content)) {
$panes = array_keys($panelizer_default->display->content);
if (in_array($pid, $panes)) {
$display = $panelizer_default->display;
$pane = $panelizer_default->display->content[$pid];
break;
}
}
}
}
$pane->esi_meta = array(
'display_contexts' => array(),
);
// If the pane has context, attempt to load the context from the display
// data.
if (!empty($pane->configuration['context'])) {
// The task name is always the first of the optional arguments.
$task_name = array_shift($args);
list($task, $subtask) = _esi_panels__get_task_identifier($task_name);
$pane->esi_meta['task'] = $task;
$pane->esi_meta['subtask'] = $subtask;
}
$pane->esi_meta += array(
'display' => $display,
'theme' => $theme,
'display_args' => $args,
'url' => base64_decode($url),
);
esi_panels__restore_context($pane);
return $pane;
}