You are here

function print_preprocess_print in Printer, email and PDF versions 7

Same name and namespace in other branches
  1. 7.2 print.pages.inc \print_preprocess_print()

Implements hook_preprocess_HOOK().

File

./print.module, line 140
Displays Printer-friendly versions of Drupal pages.

Code

function print_preprocess_print(&$variables) {
  static $hooks = NULL;
  if (!isset($hooks)) {
    drupal_theme_initialize();
    $hooks = theme_get_registry();
  }
  $variables['page']['#show_messages'] = FALSE;

  // Stolen from theme() so that ALL preprocess functions are called
  $hook = 'page';
  $info = $hooks[$hook];
  if (isset($info['preprocess functions']) || isset($info['process functions'])) {
    foreach (array(
      'preprocess functions',
      'process functions',
    ) as $phase) {
      if (!empty($info[$phase])) {
        foreach ($info[$phase] as $processor_function) {
          if (function_exists($processor_function)) {

            // We don't want a poorly behaved process function changing $hook.
            $hook_clone = $hook;
            $processor_function($variables, $hook_clone);
          }
        }
      }
    }
  }
  $format = $variables['type'];
  $type = isset($variables['node']->type) ? $variables['node']->type : '';
  $nid = isset($variables['node']->nid) ? $variables['node']->nid : '';
  $variables['theme_hook_suggestions'] = array();
  $variables['theme_hook_suggestions'][] = "print__node__{$type}";
  $variables['theme_hook_suggestions'][] = "print__node__{$type}__{$nid}";
  $variables['theme_hook_suggestions'][] = "print__{$format}";
  $variables['theme_hook_suggestions'][] = "print__{$format}__node__{$type}";
  $variables['theme_hook_suggestions'][] = "print__{$format}__node__{$type}__{$nid}";
}