You are here

function print_generate_path in Printer, email and PDF versions 5.2

Outputs a printer-friendly page. Used for drupal core pages.

1 call to print_generate_path()
print_controller in ./print.module
Print module path catcher

File

./print.module, line 714
Display printer-friendly versions of Drupal pages

Code

function print_generate_path($path) {
  global $base_url;
  $path = drupal_get_normal_path($path);
  menu_set_active_item($path);

  // Adapted from index.php.
  $node = new stdClass();
  $node->body = menu_execute_active_handler();

  // It may happen that a drupal_not_found is called in the above call
  if (preg_match('/404 Not Found/', drupal_get_headers()) == 1) {
    return;
  }
  switch ($node->body) {
    case MENU_NOT_FOUND:
      return drupal_not_found();
      break;
    case MENU_ACCESS_DENIED:
      return drupal_access_denied();
      break;
  }

  // Delete any links area
  $node->body = preg_replace("/\\s*<div class=\"links\">.*?<\\/div>/sim", "", $node->body);

  // Convert the a href elements
  $pattern = "@<(a\\s[^>]*?)>(.*?)</a>@is";
  $node->body = preg_replace_callback($pattern, "print_rewrite_urls", $node->body);
  init_theme();
  $print = _print_var_generator($node);
  include_once print_get_template();
}