You are here

function panels_panel_context_edit_preview in Panels 7.3

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

Form to show a nice preview.

1 string reference to 'panels_panel_context_edit_preview'
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 865
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_edit_preview($form, &$form_state) {
  ctools_include('context');
  ctools_include('context-task-handler');
  $contexts = ctools_context_handler_get_all_contexts($form_state['task'], $form_state['subtask'], $form_state['handler']);
  $form['preview'] = array();
  ctools_context_replace_form($form['preview'], $contexts);

  // Automatically preview if there are no argument placeholders.
  if (empty($form['preview'])) {
    $display = panels_panel_context_get_display($form_state['handler']);
    $display->context = $contexts;
    $display->skip_cache = TRUE;
    $output = panels_render_display($display);
    if (isset($form['buttons'])) {
      unset($form['buttons']);
    }
  }
  else {
    $form['preview']['#tree'] = TRUE;
    $form_state['contexts'] = $contexts;
  }
  if (!empty($output)) {
    $form['output'] = array(
      '#markup' => $output,
    );
  }
  $form_state['do not cache'] = TRUE;
  return $form;
}