You are here

function print_controller in Printer, email and PDF versions 5.4

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

$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 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_form_submit in print_mail/print_mail.inc
Process the send by-email form submission.
print_pdf_controller in print_pdf/print_pdf.pages.inc
Generate a PDF version of the printer-friendly page

File

./print.pages.inc, line 70

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) {
      $path = '';
    }
  }
  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]) && 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;
}