function _print_generate_path in Printer, email and PDF versions 7.2
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 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
string $path: Path of the node to be rendered into a printer-friendly page.
string $format: Format of the page being generated.
Return value
object|bool filled node-like object to be used in the print 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 710
Code
function _print_generate_path($path, $format) {
global $_print_urls;
// Handle node tabs, or cases where the 'node_router' option is enabled.
$parts = explode('/', $path);
if (ctype_digit($parts[0]) && (count($parts) > 1 || variable_get('print_node_router', FALSE))) {
$path = 'node/' . $path;
}
$path = drupal_get_normal_path($path);
menu_set_active_item($path);
// Adapted from index.php.
$node = new stdClass();
$node->content = menu_execute_active_handler($path, FALSE);
if (is_array($node->content)) {
$node->content = drupal_render($node->content);
}
if (is_int($node->content)) {
switch ($node->content) {
case MENU_NOT_FOUND:
drupal_not_found();
drupal_exit();
break;
case MENU_ACCESS_DENIED:
drupal_access_denied();
drupal_exit();
break;
}
}
$node->title = drupal_get_title();
$node->path = $path;
$node->changed = REQUEST_TIME;
$node->type = '';
// Delete any links area.
$node->content = preg_replace('!\\s*<div class="links">.*?</div>!sim', '', $node->content);
// Delete the contextual links also.
$node->content = preg_replace('!\\s*<div class="contextual-links-wrapper">.*?</div>!sim', '', $node->content);
// Check URL list settings.
$_print_urls = _print_url_list_enabled($node, $format);
// Convert the a href elements.
$pattern = '!<(a\\s[^>]*?)>(.*?)(</a>)!is';
$node->content = preg_replace_callback($pattern, '_print_rewrite_urls', $node->content);
return $node;
}