function node_gallery_api_node_load in Node Gallery 7
Implements hook_node_load().
File
- ./
node_gallery_api.module, line 679 - Node Gallery module.
Code
function node_gallery_api_node_load($nodes, $types) {
$gallery_types = node_gallery_api_get_types('gallery');
foreach ($nodes as $i => $node) {
if (in_array($node->type, $gallery_types)) {
$gallery_info = db_select('node_gallery_galleries', 'ngg')
->fields('ngg')
->condition('ngid', $node->nid)
->execute()
->fetchAssoc();
if (empty($gallery_info)) {
// This node type turned into a gallery after this node was last saved.
$item_count = db_select('node_gallery_relationship', 'ngr')
->fields('ngr')
->condition('ngid', $node->nid)
->countQuery()
->execute()
->fetchField();
$q = db_select('node_gallery_relationship', 'ngr');
$q
->join('node', 'n');
$pub_item_count = $q
->fields('ngr')
->condition('ngid', $node->nid)
->condition('n.status', 1)
->countQuery()
->execute()
->fetchField();
$gallery_info = array(
'cover_item' => NULL,
'item_count' => $item_count,
'pub_item_count' => $pub_item_count,
);
}
$nodes[$i]->node_gallery = $gallery_info;
}
}
}