function _print_generate_book in Printer, email and PDF versions 5.3
Same name and namespace in other branches
- 5.4 print.pages.inc \_print_generate_book()
- 6 print.pages.inc \_print_generate_book()
- 7.2 print.pages.inc \_print_generate_book()
- 7 print.pages.inc \_print_generate_book()
- 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
$teaser: if set to TRUE, outputs only the node's teaser
$message: optional sender's message (used by the send e-mail 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 636 - Contains the functions to generate Printer-friendly pages.
Code
function _print_generate_book($nid, $teaser = FALSE, $message = NULL) {
$node = node_load(array(
'nid' => $nid,
));
if (!$node) {
// Node not found
drupal_not_found();
return FALSE;
}
elseif (!node_access('view', $node) || !user_access('see printer-friendly version')) {
// Access is denied
drupal_access_denied();
return FALSE;
}
$depth = count(book_location($node)) + 1;
$node->body = book_recurse($nid, $depth, '_print_node_visitor_html_pre', 'book_node_visitor_html_post');
// 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, $message);
// The title is already displayed by the book_recurse, so avoid duplication
$print['title'] = '';
return $print;
}