function _print_generate_path in Printer, email and PDF versions 7
Same name and namespace in other branches
- 5.4 print.pages.inc \_print_generate_path()
- 5.3 print.pages.inc \_print_generate_path()
- 6 print.pages.inc \_print_generate_path()
- 7.2 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
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_path()
- print_controller in ./
print.pages.inc - Select the print generator function based on the page type
File
- ./
print.pages.inc, line 638
Code
function _print_generate_path($path, $query = NULL, $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, FALSE);
if (is_array($node->body)) {
$node->body = drupal_render($node->body);
}
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;
$node->changed = 0;
// Delete any links area
$node->body = preg_replace('!\\s*<div class="links">.*?</div>!sim', '', $node->body);
// Delete the contextual links also
$node->body = preg_replace('!\\s*<div class="contextual-links-wrapper">.*?</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, $query, $message);
$print['content'] = $node->body;
return $print;
}