Commit e7ad23e1 authored by jcnventura's avatar jcnventura

Issue #1235842: remove undefined node variable warnings in PDF generation.

parent 545fca22
......@@ -75,11 +75,10 @@ function print_controller($path, $cid = NULL, $format = PRINT_HTML_FORMAT, $teas
$path = '';
}
}
if (!ctype_digit($path)) {
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 = drupal_get_normal_path($path);
$ret = preg_match('!^node/(.*)!i', $path, $matches);
$ret = preg_match('!^node/(.*)!i', $alias, $matches);
if ($ret == 1) {
$path = $matches[1];
}
......
......@@ -27,21 +27,18 @@ function print_pdf_controller() {
$path = implode('/', $args);
$cid = isset($_GET['comment']) ? (int)$_GET['comment'] : NULL;
if (ctype_digit($args[0])) {
if (drupal_lookup_path('source', $path)) {
// This is a numeric alias
$path = drupal_get_normal_path($path);
$path_arr = explode('/', $path);
$node = node_load($path_arr[1]);
}
else {
// normal nid
$node = node_load($args[0]);
}
if ($alias = drupal_lookup_path('source', $path)) {
// Alias
$path_arr = explode('/', $alias);
$node = node_load($path_arr[1]);
}
elseif (ctype_digit($args[0])) {
// normal nid
$node = node_load($args[0]);
}
$pdf_filename = variable_get('print_pdf_filename', PRINT_PDF_FILENAME_DEFAULT);
if (!empty($pdf_filename)) {
if (!empty($pdf_filename) && !empty($node)) {
$pdf_filename = token_replace($pdf_filename, array('node' => $node)) . '.pdf';
}
else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment