function _print_generate_path in Printer, email and PDF versions 6
Same name and namespace in other branches
- 5.4 print.pages.inc \_print_generate_path()
- 5.3 print.pages.inc \_print_generate_path()
- 7.2 print.pages.inc \_print_generate_path()
- 7 print.pages.inc \_print_generate_path()
- 5.x print.pages.inc \_print_generate_path()
Prepare a Printer-friendly-ready node body for non-content pages
Parameters
$path: path 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 email module)
Return value
filled array ready to be used in the template
1 call to _print_generate_path()
- print_controller in ./
print.pages.inc - Select the print generator function based on the page type
File
- ./
print.pages.inc, line 620
Code
function _print_generate_path($path, $format = PRINT_HTML_FORMAT, $teaser = FALSE, $message = NULL) {
global $_print_urls;
// Handle node tabs
$parts = explode('/', $path);
if (ctype_digit($parts[0]) && count($parts) > 1) {
$path = 'node/' . $path;
}
$path = drupal_get_normal_path($path);
menu_set_active_item($path);
// Adapted from index.php.
$node = new stdClass();
$node->body = menu_execute_active_handler($path);
// 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 FALSE;
}
if (is_int($node->body)) {
switch ($node->body) {
case MENU_NOT_FOUND:
drupal_not_found();
return FALSE;
break;
case MENU_ACCESS_DENIED:
drupal_access_denied();
return FALSE;
break;
}
}
$node->title = drupal_get_title();
$node->path = $path;
// Delete any links area
$node->body = preg_replace('!\\s*<div class="links">.*?</div>!sim', '', $node->body);
// 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;
return $print;
}