function print_pdf_controller in Printer, email and PDF versions 5.x
Same name and namespace in other branches
- 5.4 print_pdf/print_pdf.pages.inc \print_pdf_controller()
- 5.3 print_pdf/print_pdf.pages.inc \print_pdf_controller()
- 6 print_pdf/print_pdf.pages.inc \print_pdf_controller()
- 7.2 print_pdf/print_pdf.pages.inc \print_pdf_controller()
- 7 print_pdf/print_pdf.pages.inc \print_pdf_controller()
Generate a PDF version of the printer-friendly page
See also
1 string reference to 'print_pdf_controller'
- print_pdf_menu in print_pdf/
print_pdf.module - Implementation of hook_menu().
File
- print_pdf/
print_pdf.pages.inc, line 22
Code
function print_pdf_controller() {
global $base_url;
// Disable caching for generated PDFs, as Drupal doesn't ouput the proper headers from the cache
$GLOBALS['conf']['cache'] = FALSE;
$args = func_get_args();
$path = implode('/', $args);
$cid = isset($_GET['comment']) ? (int) $_GET['comment'] : NULL;
$pdf_filename = variable_get('print_pdf_filename', PRINT_PDF_FILENAME_DEFAULT);
if (function_exists('token_replace') && !empty($pdf_filename)) {
$pdf_filename = token_replace($pdf_filename, 'node', $node) . '.pdf';
}
else {
$pdf_filename = str_replace('/', '_', $path) . '.pdf';
}
if (function_exists('transliteration_clean_filename')) {
$pdf_filename = transliteration_clean_filename($pdf_filename, language_default('language'));
}
$pdf = print_pdf_generate_path($path, $cid, $pdf_filename);
if ($pdf == NULL) {
drupal_goto($print['url']);
exit;
}
$nodepath = isset($node->path) ? drupal_get_normal_path($node->path) : 'node/' . $path;
db_query("UPDATE {print_pdf_page_counter} SET totalcount = totalcount + 1, timestamp = %d WHERE path = '%s'", time(), $nodepath);
// If we affected 0 rows, this is the first time viewing the node.
if (!db_affected_rows()) {
// We must create a new row to store counters for the new node.
db_query("INSERT INTO {print_pdf_page_counter} (path, totalcount, timestamp) VALUES ('%s', 1, %d)", $nodepath, time());
}
}