function _print_generate_book in Printer, email and PDF versions 5.x
Same name and namespace in other branches
- 5.4 print.pages.inc \_print_generate_book()
- 5.3 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()
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
$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 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 656
Code
function _print_generate_book($nid, $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, $message);
$print['content'] = $node->body;
// The title is already displayed by the book_recurse, so avoid duplication
$print['title'] = '';
return $print;
}