function esi__panel_pane_handler in ESI: Edge Side Includes 6.2
Menu handler to serve individual panel-panes via ESI.
If the pane uses context, the task_name, context_string and q variables will be set.
1 string reference to 'esi__panel_pane_handler'
- esi_menu in ./
esi.module - Implementation of hook_menu(). Define a menu-handler.
File
- ./
esi.module, line 535 - Adds support for ESI (Edge-Side-Include) integration, allowing blocks to be\ delivered by ESI, with support for per-block cache times.
Code
function esi__panel_pane_handler($bid, $page = NULL, $task_name = NULL, $context_string = NULL) {
// Expect the bid format to be theme:display_id:pane_id
if (substr_count($bid, ':') !== 2) {
return FALSE;
}
list($passed_theme, $display_id, $pane_id) = explode(':', $bid);
global $custom_theme, $theme_key, $user;
// Save this page's internal URL.
$last_arg = explode('/', $_GET['q']);
$last_arg = array_pop($last_arg);
// Set context.
if (isset($page) && strpos($page, 'CACHE=') !== 0) {
$q = base64_decode($page);
if ($q == "") {
$q = variable_get('site_frontpage', 'node');
}
$_GET['q'] = $q;
}
// theme set-up.
// we need to do this manually, because output is echo'd instead of returned.
$custom_theme = $passed_theme;
$theme_key = $passed_theme;
init_theme();
$display = panels_load_display($display_id);
if (!is_null($task_name)) {
// Get the context for this pane.
list($args, $contexts) = esi__panels_get_task_context($task_name);
$display->context = $contexts;
$display->args = $args;
}
// Switch ESI off so the contents of the pane are served.
$config = $display->content[$pane_id]->cache;
unset($display->content[$pane_id]->cache);
// Load in defaults if missing.
if (!isset($config['settings']['max_age'])) {
$config['settings']['max_age'] = (int) variable_get('esi_panel_default_max_age', ESI_PANEL_DEFAULT_MAX_AGE);
}
if (!isset($config['settings']['scope'])) {
$config['settings']['scope'] = (int) variable_get('esi_panel_default_scope', ESI_PANEL_DEFAULT_SCOPE);
}
$current_user = $user;
// Use user 0 if the scope is global or page.
if ($config['settings']['scope'] == 2 || $config['settings']['scope'] == 3) {
$user = user_load(0);
}
if (!function_exists('panels_get_renderer_handler')) {
require_once drupal_get_path('module', 'panels') . '/includes/plugins.inc';
}
// Use the standard renderer to render the pane.
$renderer = panels_get_renderer_handler('standard', $display);
if (!empty($renderer->display->content[$pane_id]->access['plugins'])) {
$renderer->display->content[$pane_id]->access['plugins'] = array_filter($renderer->display->content[$pane_id]->access['plugins'], "filter_out_path_visibility_access");
}
$renderer
->prepare_panes($renderer->display->content);
$output = '';
if (!empty($renderer->prepared['panes'][$pane_id])) {
$output .= $renderer
->render_pane($renderer->prepared['panes'][$pane_id]);
}
else {
$output .= esi_fast404('panel');
}
esi_add_cache_headers($config['settings']['scope'], $config['settings']['max_age']);
echo $output;
$user = $current_user;
// Cache the ESI output.
esi_set_page_cache($output, $config['settings']['scope'], $last_arg);
exit;
}