You are here

function print_preprocess_print_page in Printer, email and PDF versions 6

Same name and namespace in other branches
  1. 5.x print.module \print_preprocess_print_page()

Implementation of hook_preprocess_HOOK().

File

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

Code

function print_preprocess_print_page(&$variables) {
  static $hooks = NULL;
  if (!isset($hooks)) {
    init_theme();
    $hooks = theme_get_registry();
  }
  $variables['show_blocks'] = FALSE;
  $variables['show_messages'] = FALSE;

  // Stolen from theme() so that ALL preprocess functions are called
  $info = $hooks['page'];
  if (isset($info['preprocess functions']) && is_array($info['preprocess functions'])) {

    // This construct ensures that we can keep a reference through
    // call_user_func_array.
    $args = array(
      &$variables,
      'page',
    );
    foreach ($info['preprocess functions'] as $preprocess_function) {
      if (function_exists($preprocess_function)) {
        call_user_func_array($preprocess_function, $args);
      }
    }
  }
  $variables += $args[0];
  $format = $variables['type'];
  $type = isset($variables['node']->type) ? $variables['node']->type : '';
  $nid = isset($variables['node']->nid) ? $variables['node']->nid : '';
  $variables['template_files'][] = "print";
  $variables['template_files'][] = "print.node-{$type}";
  $variables['template_files'][] = "print.node-{$type}-{$nid}";
  $variables['template_files'][] = "print_{$format}";
  $variables['template_files'][] = "print_{$format}.node-{$type}";
  $variables['template_files'][] = "print_{$format}.node-{$type}-{$nid}";
}