You are here

function _print_generate_book in Printer, email and PDF versions 7.2

Same name and namespace in other branches
  1. 5.4 print.pages.inc \_print_generate_book()
  2. 5.3 print.pages.inc \_print_generate_book()
  3. 6 print.pages.inc \_print_generate_book()
  4. 7 print.pages.inc \_print_generate_book()
  5. 5.x print.pages.inc \_print_generate_book()

Prepare a Printer-friendly-ready node body for book pages.

Parameters

int $nid: Node ID of the node to be rendered into a printer-friendly page.

string $format: Format of the page being generated.

Return value

object|bool filled node-like object to be used in the print template

1 call to _print_generate_book()
print_controller in ./print.pages.inc
Select the print generator function based on the page type.

File

./print.pages.inc, line 775

Code

function _print_generate_book($nid, $format) {
  global $_print_urls;
  $node = node_load($nid);
  if (!$node) {

    // Node not found.
    drupal_not_found();
    drupal_exit();
  }
  elseif (!node_access('view', $node) || !user_access('access printer-friendly version')) {

    // Access is denied.
    drupal_access_denied();
    drupal_exit();
  }
  $tree = book_menu_subtree_data($node->book);
  $node->content = book_export_traverse($tree, 'book_node_export');

  // Check URL list settings.
  $_print_urls = _print_url_list_enabled($node, $format);

  // Convert the a href elements.
  $pattern = '!<(a\\s[^>]*?)>(.*?)(</a>)!is';
  $node->content = preg_replace_callback($pattern, '_print_rewrite_urls', $node->content);
  return $node;
}