function print_controller in Printer, email and PDF versions 6
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()
- 7.2 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
$path: path of the original page
$cid: comment ID of the individual comment to be rendered
$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
array with the fields to be used in the template
See also
3 calls to print_controller()
- print_controller_html in ./
print.pages.inc - Generate an HTML version of the printer-friendly page
- print_mail_form_submit in print_mail/
print_mail.inc - Process the send by-email form submission.
- print_pdf_generate_path in print_pdf/
print_pdf.pages.inc
File
- ./
print.pages.inc, line 66
Code
function print_controller($path, $cid = NULL, $format = PRINT_HTML_FORMAT, $teaser = FALSE, $message = NULL) {
if (empty($path)) {
// If no path was provided, let's try to generate a page for the referer
global $base_url;
$ref = referer_uri();
$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);
if ($parts[0] == 'node' && count($parts) > 1 && ctype_digit($parts[1])) {
array_shift($parts);
$path = implode('/', $parts);
}
if (ctype_digit($parts[0]) && count($parts) == 1) {
$print = _print_generate_node($path, $cid, $format, $teaser, $message);
}
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
$print = _print_generate_book($matches[1], $format, $teaser, $message);
}
else {
// If no content node was found, handle the page printing with the 'printable' engine
$print = _print_generate_path($path, $format, $teaser, $message);
}
}
return $print;
}