count = taxonomy_term_count_nodes($galleries[$i]->tid, 'image'); $tree = taxonomy_get_tree($vid, $galleries[$i]->tid, -1); $descendant_tids = array_merge(array($galleries[$i]->tid), array_map('_taxonomy_get_tid_from_term', $tree)); // The values of $descendant_tids should be safe for raw inclusion in the // SQL since they're all loaded from integer fields in the database. $sql = "SELECT n.nid FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid $join WHERE tn.tid IN (" . implode(',', $descendant_tids) . ") AND n.type = 'image' AND n.status = 1 $where $order"; if ($nid = db_result(db_query(db_rewrite_sql($sql), $args))) { $galleries[$i]->latest = node_load(array('nid' => $nid)); } } $images = array(); if ($tid) { // Allow images to be sorted in a useful order. $query = "SELECT n.nid FROM {term_node} t INNER JOIN {node} n ON t.nid = n.nid $join WHERE n.status = 1 AND n.type = 'image' AND t.tid = %d $where $order"; $count_query = "SELECT COUNT(DISTINCT(n.nid)) FROM {term_node} t INNER JOIN {node} n ON t.nid = n.nid WHERE n.status = 1 AND n.type = 'image' AND t.tid = %d "; $args = array_merge(array($tid), $args); $result = pager_query(db_rewrite_sql($query), variable_get('image_images_per_page', 6), 0, db_rewrite_sql($count_query), $args); while ($node = db_fetch_object($result)) { $images[] = node_load(array('nid' => $node->nid)); } $gallery = taxonomy_get_term($tid); $parents = taxonomy_get_parents($tid); $breadcrumb = array(); $breadcrumb[] = l(t('Home'), NULL); $breadcrumb[] = l(t('Image galleries'), 'image'); foreach ($parents as $parent) { // Add parents to breadcrumb navigation $breadcrumb[] = l($parent->name, 'image/tid/' . $parent->tid); } drupal_set_breadcrumb($breadcrumb); drupal_set_title(check_plain($gallery->name)); } return theme('image_gallery', $galleries, $images); } /** * Theme a gallery page */ function theme_image_gallery($galleries, $images) { drupal_add_css(drupal_get_path('module', 'image_gallery') . '/image_gallery.css'); $size = image_get_sizes(IMAGE_THUMBNAIL); $content = ''; if (count($galleries)) { $content .= '
' . format_plural($gallery->count, 'There is 1 image in this gallery.', 'There are @count images in this gallery.') . "
\n"; if (isset($gallery->latest) && $gallery->latest->changed) { $content .= '' . t('Last updated: %date', array('%date' => format_date($gallery->latest->changed))) . "
\n"; } $content .= "' . format_plural(0, 'There is 1 image in this gallery.', 'There are @count images in this gallery.') . "
\n"; } return $content; } /** * Theme a gallery image. */ function theme_image_gallery_img($image, $size) { $width = $size['width']; // We'll add height to keep thumbnails lined up. $height = $size['height'] + 75; $content = '