You are here

function _print_generate_book in Printer, email and PDF versions 7

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.2 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

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

array $query: (optional) array of key/value pairs as used in the url() function for the query

$format: format of the page being generated

$teaser: if set to TRUE, outputs only the node's teaser

$message: optional sender's message (used by the send email module)

Return value

filled array ready to be used in the 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 711

Code

function _print_generate_book($nid, $query = NULL, $format = PRINT_HTML_FORMAT, $teaser = FALSE, $message = NULL) {
  global $_print_urls;
  $node = node_load($nid);
  if (!$node) {

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

    // Access is denied
    drupal_access_denied();
    return FALSE;
  }
  $tree = book_menu_subtree_data($node->book);
  $node->body = 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->body = preg_replace_callback($pattern, '_print_rewrite_urls', $node->body);
  $print = _print_var_generator($node, $query, $message);
  $print['content'] = $node->body;

  // The title is already displayed by the book_recurse, so avoid duplication
  $print['title'] = '';
  return $print;
}