You are here

function print_controller in Printer, email and PDF versions 5.3

Same name and namespace in other branches
  1. 5.4 print.pages.inc \print_controller()
  2. 5 print.module \print_controller()
  3. 5.2 print.module \print_controller()
  4. 6 print.pages.inc \print_controller()
  5. 7.2 print.pages.inc \print_controller()
  6. 7 print.pages.inc \print_controller()
  7. 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

$teaser: if set to TRUE, outputs only the node's teaser

$message: optional sender's message (used by the send e-mail module)

Return value

array with the fields to be used in the template

See also

_print_generate_node()

_print_generate_path()

_print_generate_book()

3 calls to print_controller()
print_controller_html in ./print.pages.inc
Generate an HTML version of the printer-friendly page
print_mail_mail in print_mail/print_mail.inc
Implementation of hook_mail().
print_pdf_controller in print_pdf/print_pdf.pages.inc
Generate a PDF version of the printer-friendly page

File

./print.pages.inc, line 51
Contains the functions to generate Printer-friendly pages.

Code

function print_controller($path, $cid, $teaser = FALSE, $message = NULL) {
  if (!is_numeric($path)) {

    // Indirect call with print/alias
    // If there is a path alias with these arguments, generate a printer-friendly version for it
    $path = drupal_get_normal_path($path);
    $ret = preg_match('!^node/(.*)!i', $path, $matches);
    if ($ret == 1) {
      $path = $matches[1];
    }
  }
  $parts = explode('/', $path);
  if (is_numeric($parts[0])) {
    $print = _print_generate_node($path, $cid, $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], $teaser, $message);
    }
    else {

      // If no content node was found, handle the page printing with the 'printable' engine
      $print = _print_generate_path($path, $teaser, $message);
    }
  }
  return $print;
}