You are here

function panels_ajax_tab_ajax in Panels Ajax Tabs 7

AJAX callback for rendering tab.

1 string reference to 'panels_ajax_tab_ajax'
panels_ajax_tab_menu in ./panels_ajax_tab.module
Implements hook_menu().

File

./panels_ajax_tab.module, line 185
Allows users to create and manage Panels Ajax Tabs.

Code

function panels_ajax_tab_ajax($panel_name, $context_string, $url_enabled) {

  // Modify the request so downstream modules properly process the URL
  // and menu object.
  $headers = getallheaders();
  if (!empty($headers['X-Request-Path'])) {
    $_GET['original_q'] = $_GET['q'];
    $_GET['q'] = ltrim($headers['X-Request-Path'], '/');
    panels_ajax_tab_boot();
    $_GET['q'] = drupal_get_normal_path($_GET['q']);
  }

  // Load the mini panel.
  $mini = panels_ajax_tab_prepare_mini($panel_name, $context_string);

  // Render the output.
  $output = theme('panels_ajax_tab_ajax', array(
    'minipanel' => $mini,
    'url_enabled' => $url_enabled,
  ));
  $response = array();
  $response['markup'] = $output;

  // Allow other modules to alter the response.
  $trigger = !empty($_GET['panels_ajax_tab_trigger']) ? $_GET['panels_ajax_tab_trigger'] : '';
  drupal_alter('panels_ajax_tab_response', $response, $panel_name, $context_string, $trigger);
  drupal_json_output($response);
  exit;
}