You are here

function panels_panel_context_render in Panels 6.3

Same name and namespace in other branches
  1. 7.3 plugins/task_handlers/panel_context.inc \panels_panel_context_render()

Check selection rules and, if passed, render the contexts.

1 string reference to 'panels_panel_context_render'
panel_context.inc in plugins/task_handlers/panel_context.inc
This is the task handler plugin to handle attaching a panel to any task that advertises itself as a 'context' type, which all of the basic page tasks provided by page_manager.module do by default.

File

plugins/task_handlers/panel_context.inc, line 240
This is the task handler plugin to handle attaching a panel to any task that advertises itself as a 'context' type, which all of the basic page tasks provided by page_manager.module do by default.

Code

function panels_panel_context_render($handler, $base_contexts, $args, $test = TRUE) {

  // Go through arguments and see if they match.
  ctools_include('context');
  ctools_include('context-task-handler');
  ctools_include('plugins', 'panels');

  // Add my contexts
  $contexts = ctools_context_handler_get_handler_contexts($base_contexts, $handler);

  // Test.
  if ($test && !ctools_context_handler_select($handler, $contexts)) {
    return;
  }
  if (isset($handler->handler)) {
    ctools_context_handler_pre_render($handler, $contexts, $args);
  }

  // Load the display
  $display = panels_panel_context_get_display($handler);
  $display->context = $contexts;
  $display->args = $args;
  $display->css_id = $handler->conf['css_id'];
  $task_name = page_manager_make_task_name($handler->task, $handler->subtask);
  $display->cache_key = 'panel_context:' . $task_name . ':' . $handler->name;

  // Check to see if there is any CSS.
  if (!empty($handler->conf['css'])) {
    ctools_include('css');
    $css_id = 'panel_context:' . $handler->name;
    $filename = ctools_css_retrieve($css_id);
    if (!$filename) {
      $filename = ctools_css_store($css_id, $handler->conf['css']);
    }
    ctools_css_add_css($filename);
  }

  // With an argument, this actually sets the display.
  panels_get_current_page_display($display);

  // Handle backward compatibility with the IPE checkbox.
  if (empty($handler->conf['pipeline'])) {
    $handler->conf['pipeline'] = !empty($handler->conf['use_ipe']) ? 'ipe' : 'standard';
  }
  $renderer = panels_get_renderer($handler->conf['pipeline'], $display);
  $info = array(
    'content' => panels_render_display($display, $renderer),
    'no_blocks' => !empty($handler->conf['no_blocks']),
  );
  $info['title'] = $display
    ->get_title();
  return $info;
}