--- taxonomy.module.4.6.2 2005-07-18 11:14:43.738198400 -0700 +++ taxonomy.module 2005-07-18 11:16:27.547468800 -0700 @@ -34,11 +34,9 @@ } } else { - $links = array(); foreach (taxonomy_node_get_terms($node->nid) as $term) { $links[] = l($term->name, 'taxonomy/term/'. $term->tid); } - } return $links; } @@ -344,34 +342,67 @@ * Generate a tabular listing of administrative functions for vocabularies. */ function taxonomy_overview() { - $header = array(t('Name'), t('Type'), array('data' => t('Operations'), 'colspan' => '3')); - $vocabularies = taxonomy_get_vocabularies(); + $vid = arg(2); - foreach ($vocabularies as $vocabulary) { - $types = array(); - foreach($vocabulary->nodes as $type) { - $node_type = node_invoke($type, 'node_name'); - $types[] = $node_type ? $node_type : $type; + // Show all vocabularies, but don't show terms here, but instruct user to "view terms" instead. + if (!$vid) { + $header = array(t('Name'), t('Type'), array('data' => t('Operations'), 'colspan' => '3')); + $vocabularies = taxonomy_get_vocabularies(); + foreach ($vocabularies as $vocabulary) { + $types = array(); + foreach ($vocabulary->nodes as $type) { + $node_type = node_invoke($type, 'node_name'); + $types[] = $node_type ? $node_type : $type; + } + $rows[] = array(''. check_plain($vocabulary->name) .'', implode(', ', $types), + l(t('edit vocabulary'), "admin/taxonomy/edit/vocabulary/$vocabulary->vid"), l(t('add term'), "admin/taxonomy/add/term/$vocabulary->vid"), + l(t('view terms'), "admin/taxonomy/$vocabulary->vid")); } - $rows[] = array(check_plain($vocabulary->name), implode(', ', $types), l(t('edit vocabulary'), "admin/taxonomy/edit/vocabulary/$vocabulary->vid"), l(t('add term'), "admin/taxonomy/add/term/$vocabulary->vid"), l(t('preview form'), "admin/taxonomy/preview/vocabulary/$vocabulary->vid")); - - $tree = taxonomy_get_tree($vocabulary->vid); - if ($tree) { - unset($data); - foreach ($tree as $term) { - $data .= _taxonomy_depth($term->depth) .' '. check_plain($term->name) .' ('. l(t('edit term'), "admin/taxonomy/edit/term/$term->tid") .')
'; - } - $rows[] = array(array('data' => $data, 'colspan' => '5')); + if (!$rows) { + $rows[] = array(array('data' => t('No categories available.'), 'colspan' => '5', 'class' => 'message')); } } + + // Show vocabulary's terms with a pager + else { + $breadcrumb = drupal_get_breadcrumb(); + $breadcrumb[] = l(t('categories'), 'admin/taxonomy'); + drupal_set_breadcrumb($breadcrumb); + $destination = drupal_get_destination(); + + $header = array(t('Name'), array('data' => t('Operations'), 'width' => '60')); + $vocabulary = taxonomy_get_vocabulary($vid); + if ($vocabulary->module == 'taxonomy') { + drupal_set_title(check_plain($vocabulary->name)); + $start_from = $_GET['from'] ? $_GET['from'] : 0; + $total_entries = 0; // total count for pager + $page_increment = 1; // number of tids per page + $displayed_count = 0; // number of tids shown + + $tree = taxonomy_get_tree($vocabulary->vid); + foreach ($tree as $term) { + $total_entries++; // we're counting all-totals, not displayed + if (($start_from && $start_from >= $total_entries) || ($displayed_count == $page_increment)) { continue; } + $rows[] = array(_taxonomy_depth($term->depth) . ' ' . check_plain($term->name), l(t('edit term'), "admin/taxonomy/edit/term/$term->tid", array(), $destination)); + $displayed_count++; // we're counting tids displayed + } - if (!$rows) { - $rows[] = array(array('data' => t('No categories available.'), 'colspan' => '5')); + if (!$rows) { + $rows[] = array(array('data' => t('No terms available.'), 'colspan' => '2')); + } + + $GLOBALS['pager_from_array'][] = $start_from; + $GLOBALS['pager_total'][] = $total_entries; + + if ($total_entries > $page_increment) { + $rows[] = array(array('data' => theme('pager', NULL, $page_increment), 'colspan' => '2')); + } + } } - return theme('table', $header, $rows); + return theme('table', $header, $rows, array('id' => 'taxonomy')); } /** @@ -573,7 +604,7 @@ $result = db_query('SELECT t.* FROM {term_hierarchy} h, {term_data} t WHERE t.vid = %d AND h.tid = t.tid AND h.parent = %d ORDER BY weight, name', $vid, $tid); } else { - $result = db_query('SELECT t.* FROM {term_hierarchy} h, {term_data} t WHERE h.tid = t.tid AND parent = %d ORDER BY weight', $tid); + $result = db_query('SELECT t.* FROM {term_hierarchy} h, {term_data} t WHERE h.tid = t.tid AND parent = %d ORDER BY weight, name', $tid); } $children = array(); while ($term = db_fetch_object($result)) {