You are here

function ctools_ajax_page_preprocess in Chaos Tool Suite (ctools) 6

Implement hook_preprocess_page. Process variables for page.tpl.php

Parameters

$variables: The existing theme data structure.

1 call to ctools_ajax_page_preprocess()
ctools_preprocess_page in ./ctools.module
A theme preprocess function to allow content type plugins to use page template variables which are not yet available when the content type is rendered.
1 string reference to 'ctools_ajax_page_preprocess'
ctools_ajax_run_page_preprocess in includes/ajax.inc
Function that controls if ctools_ajax_page_preprocess() will run.

File

includes/ajax.inc, line 637
Utilize the CTools AJAX responder.

Code

function ctools_ajax_page_preprocess(&$variables) {

  // See if we will be running this hook.
  $run_hook =& ctools_static(__FUNCTION__, TRUE);
  if (!$run_hook) {
    return;
  }
  $js_files = $css_files = array();
  ctools_process_js_files($js_files, 'header');
  ctools_process_js_files($js_files, 'footer');
  ctools_process_css_files($css_files, $variables['css']);

  // Add loaded JS and CSS information to the footer, so that an AJAX
  // request knows if they are already loaded.
  // For inline Javascript to validate as XHTML, all Javascript containing
  // XHTML needs to be wrapped in CDATA. To make that backwards compatible
  // with HTML 4, we need to comment out the CDATA-tag.
  $loaded = array(
    'CToolsAJAX' => array(
      'scripts' => $js_files,
      'css' => $css_files,
    ),
  );
  $embed_prefix = "\n<!--//--><![CDATA[//><!--\n";
  $embed_suffix = "\n//--><!]]>\n";
  $variables['closure'] .= '<script type="text/javascript">' . $embed_prefix . 'jQuery.extend(Drupal.settings, ' . drupal_to_js($loaded) . ");" . $embed_suffix . "</script>\n";
}