function print_controller in Printer, email and PDF versions 7.2
Same name and namespace in other branches
- 5.4 print.pages.inc \print_controller()
- 5 print.module \print_controller()
- 5.2 print.module \print_controller()
- 5.3 print.pages.inc \print_controller()
- 6 print.pages.inc \print_controller()
- 7 print.pages.inc \print_controller()
- 5.x print.pages.inc \print_controller()
Select the print generator function based on the page type.
Depending on the type of node, this functions chooses the appropriate generator function.
Parameters
string $path: Path of the original page.
string $format: Format of the page being generated.
int $cid: Comment ID of the individual comment to be rendered.
string $view_mode: (Optional) view mode to be used when rendering the content.
Return value
object node-like object to be used in the print template
See also
4 calls to print_controller()
- print_controller_html in ./
print.pages.inc - Generate an HTML version of the printer-friendly page.
- print_epub_generate_path in print_epub/
print_epub.pages.inc - Gennerate a EPUB for a given Drupal path.
- print_mail_form_submit in print_mail/
print_mail.inc - Form submission handler for print_mail_form().
- print_pdf_generate_path in print_pdf/
print_pdf.pages.inc - Gennerate a PDF for a given Drupal path.
File
- ./
print.pages.inc, line 80
Code
function print_controller($path, $format, $cid = NULL, $view_mode = PRINT_VIEW_MODE) {
if (empty($path)) {
// If no path was provided, let's try to generate a page for the referer.
global $base_url;
$ref = $_SERVER['HTTP_REFERER'];
$path = preg_replace("!^{$base_url}/!", '', $ref);
if ($path === $ref || empty($path)) {
$path = variable_get('site_frontpage', 'node');
}
}
if ($alias = drupal_lookup_path('source', $path)) {
// Indirect call with print/alias
// If there is a path alias with these arguments, generate a
// printer-friendly version for it.
$path = $alias;
}
$parts = explode('/', $path);
$node_router = variable_get('print_node_router', FALSE);
if ($parts[0] == 'node' && count($parts) > 1 && ctype_digit($parts[1]) && !$node_router) {
array_shift($parts);
$path = implode('/', $parts);
}
$revision_view = preg_match('!^[\\d]*/revisions/[\\d]*/view$!', $path);
if (ctype_digit($parts[0]) && (count($parts) == 1 || $revision_view) && !$node_router) {
$vid = $revision_view ? $parts[2] : NULL;
$node = _print_generate_node($path, $format, $vid, $cid, $view_mode);
}
else {
$ret = preg_match('!^book/export/html/(.*)!i', $path, $matches);
if ($ret == 1) {
// This is a book PF page link, handle trough the book handling functions.
$node = _print_generate_book($matches[1], $format);
}
else {
// If no content node was found, handle the page printing with the
// 'printable' engine.
$node = _print_generate_path($path, $format);
}
}
return $node;
}