You are here

function ctools_preprocess_page in Chaos Tool Suite (ctools) 6

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_preprocess_page'
ctools_theme_registry_alter in includes/utility.inc
Implementation of hook_theme_registry_alter()

File

./ctools.module, line 565
CTools primary module file.

Code

function ctools_preprocess_page(&$variables) {
  $tokens = ctools_set_page_token();
  if (!empty($tokens)) {
    $temp_tokens = array();
    foreach ($tokens as $token => $key) {
      list($type, $argument) = $key;
      switch ($type) {
        case 'variable':
          $temp_tokens[$token] = isset($variables[$argument]) ? $variables[$argument] : '';
          break;
        case 'callback':
          if (is_string($argument) && function_exists($argument)) {
            $temp_tokens[$token] = $argument($variables);
          }
          if (is_array($argument) && function_exists($argument[0])) {
            $function = array_shift($argument);
            $argument = array_merge(array(
              &$variables,
            ), $argument);
            $temp_tokens[$token] = call_user_func_array($function, $argument);
          }
          break;
      }
    }
    $tokens = $temp_tokens;
    unset($temp_tokens);
    $variables['content'] = strtr($variables['content'], $tokens);
  }
  if (defined('CTOOLS_AJAX_INCLUDED')) {
    ctools_ajax_page_preprocess($variables);
  }
}