--- image_gallery.module 2006-05-04 10:01:42.000000000 -0700 +++ image_gallery_patched.module 2006-07-12 10:34:50.000000000 -0700 @@ -79,18 +79,39 @@ * Image gallery callback, displays an image gallery */ function image_gallery_page($type = NULL, $tid = 0) { - $galleries = taxonomy_get_tree(_image_gallery_get_vid(), $tid, -1, 1); + $galleries = taxonomy_get_tree(_image_gallery_get_vid(), $tid, -1, 1); for ($i=0; $i < count($galleries); $i++) { $galleries[$i]->count = taxonomy_term_count_nodes($galleries[$i]->tid, 'image'); $tree = taxonomy_get_tree(_image_gallery_get_vid(), $galleries[$i]->tid, -1); $descendant_tids = array_merge(array($galleries[$i]->tid), array_map('_taxonomy_get_tid_from_term', $tree)); - $last = db_fetch_object(db_query_range(db_rewrite_sql('SELECT n.nid FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid IN (%s) AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC'), implode(',', $descendant_tids), 0, 1)); - $galleries[$i]->latest = node_load(array('nid' => $last->nid)); + $db_rewrite_var = db_rewrite_sql( + 'SELECT n.nid, n.sticky, n.created + FROM {node} n + INNER JOIN {term_node} tn + ON n.nid = tn.nid + WHERE tn.tid IN (%s) + AND n.status = 1 + ORDER BY n.sticky DESC, n.created DESC' + ); + $db_query_range_var = db_query_range($db_rewrite_var, implode(',', $descendant_tids), 0, 1); + $last = db_fetch_object($db_query_range_var); + if($last->nid > 0) { $galleries[$i]->latest = node_load(array('nid' => $last->nid)); } } $images = array(); if ($tid) { - $result = pager_query(db_rewrite_sql("SELECT 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 ORDER BY n.sticky DESC, n.created DESC"), variable_get('image_images_per_page', 6), 0, NULL, $tid); + $result = pager_query( + db_rewrite_sql( + "SELECT n.nid, n.sticky, n.created + 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 + ORDER BY n.sticky DESC, n.created DESC" + ), variable_get('image_images_per_page', 6), 0, NULL, $tid + ); while ($node = db_fetch_object($result)) { $images[] = node_load(array('nid' => $node->nid)); } @@ -138,12 +159,9 @@ case t('Delete'): if (!$edit['confirm']) { $term = taxonomy_get_term($tid); - $form['tid'] = array('#type' => 'hidden', '#value' => $tid); - return confirm_form('image_confirm_delete', $form, t('Are you sure you want to delete the gallery %name?', array('%name' => theme('placeholder', $term->name))), 'admin/image', t('Deleting a gallery will delete all sub-forums as well. However, the images will not be deleted. This action cannot be undone.'), t('Delete'), t('Cancel')); - break; } else { @@ -179,8 +197,7 @@ $rows[] = array(_taxonomy_depth($term->depth) .' '. l($term->name, "image/tid/$term->tid"), l(t('edit gallery'), "admin/image/edit/$term->tid")); } return theme('table', $header, $rows); - } - else { + } else { return t('No galleries available'); } } @@ -212,8 +229,7 @@ if ($parents) { $parent = array_shift($parents); $parent = $parent->tid; - } - else { + } else { $parent = 0; } @@ -255,16 +271,18 @@ if (count($galleries)) { $content.= '
' . format_plural($gallery->count, 'There is 1 image in this gallery', 'There are %count images in this gallery') . "
\n"; - if ($gallery->latest->changed) { - $content.= ''. t('Last updated: %date', array('%date' => format_date($gallery->latest->changed))) . "
\n"; + if ($gallery->count > 0) { + $content .= '' . format_plural($gallery->count, 'There is 1 image in this gallery', 'There are %count images in this gallery') . "
\n"; + if ($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"; + $content.= '' . format_plural(0, 'There is 1 image in this gallery', 'There are %count images in this gallery') . "
\n"; } return $content;