function print_pdf_node_load in Printer, email and PDF versions 7.2
Same name and namespace in other branches
- 7 print_pdf/print_pdf.module \print_pdf_node_load()
Implements hook_node_load().
File
- print_pdf/
print_pdf.module, line 184 - Displays Printer-friendly versions of Drupal pages.
Code
function print_pdf_node_load($nodes, $types) {
$ids = array();
foreach ($nodes as $node) {
$ids[] = $node->nid;
}
$link = print_pdf_print_link();
$size = 'print_' . $link['format'] . '_size';
$orientation = 'print_' . $link['format'] . '_orientation';
try {
$result = db_query('SELECT nid, size, orientation FROM {print_pdf_node_conf} WHERE nid IN (:nids)', array(
':nids' => $ids,
))
->fetchAllAssoc('nid');
} catch (PDOException $ex) {
// An exception may occur when a node is loaded before update 7203 runs.
$result = array();
}
foreach ($nodes as $node) {
$node->{$size} = isset($result[$node->nid]) && !empty($result[$node->nid]->size) ? $result[$node->nid]->size : variable_get($size . '_' . $node->type);
$node->{$orientation} = isset($result[$node->nid]) && !empty($result[$node->nid]->orientation) ? $result[$node->nid]->orientation : variable_get($orientation . '_' . $node->type);
}
}