You are here

function print_ui_node_load in Printer, email and PDF versions 7.2

Implements hook_node_load().

File

print_ui/print_ui.module, line 298
Printer-friendly pages User Interface module.

Code

function print_ui_node_load($nodes, $types) {
  $ids = array();
  foreach ($nodes as $node) {
    $ids[] = $node->nid;
  }
  foreach (module_implements('print_link') as $module) {
    $function = $module . '_print_link';
    if (function_exists($function)) {
      $link = call_user_func_array($function, array());
      $display = 'print_' . $link['format'] . '_display';
      $display_comment = 'print_' . $link['format'] . '_display_comment';
      $display_urllist = 'print_' . $link['format'] . '_display_urllist';
      $result = db_query('SELECT nid, link, comments, url_list FROM {' . $module . '_node_conf} WHERE nid IN (:nids)', array(
        ':nids' => $ids,
      ))
        ->fetchAllAssoc('nid');
      foreach ($nodes as $node) {
        $node->{$display} = isset($result[$node->nid]) ? intval($result[$node->nid]->link) : variable_get($display . '_' . $node->type, PRINT_UI_TYPE_SHOW_LINK_DEFAULT);
        $node->{$display_comment} = isset($result[$node->nid]) ? intval($result[$node->nid]->comments) : variable_get($display_comment . '_' . $node->type, PRINT_UI_TYPE_COMMENT_LINK_DEFAULT);
        $node->{$display_urllist} = isset($result[$node->nid]) ? intval($result[$node->nid]->url_list) : variable_get($display_urllist . '_' . $node->type, PRINT_TYPE_URLLIST_DEFAULT);
      }
    }
  }
}