You are here

function taxonomy_overview_terms in Drupal 4

Same name and namespace in other branches
  1. 5 modules/taxonomy/taxonomy.module \taxonomy_overview_terms()
  2. 6 modules/taxonomy/taxonomy.admin.inc \taxonomy_overview_terms()
  3. 7 modules/taxonomy/taxonomy.admin.inc \taxonomy_overview_terms()

Display a tree of all the terms in a vocabulary, with options to edit each one.

1 string reference to 'taxonomy_overview_terms'
taxonomy_menu in modules/taxonomy.module
Implementation of hook_menu().

File

modules/taxonomy.module, line 150
Enables the organization of content into categories.

Code

function taxonomy_overview_terms($vid) {
  $destination = drupal_get_destination();
  $header = array(
    t('Name'),
    t('Operations'),
  );
  $vocabulary = taxonomy_get_vocabulary($vid);
  drupal_set_title(check_plain($vocabulary->name));
  $start_from = $_GET['page'] ? $_GET['page'] : 0;
  $total_entries = 0;

  // total count for pager
  $page_increment = 25;

  // 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 * $page_increment >= $total_entries || $displayed_count == $page_increment) {
      continue;
    }
    $rows[] = array(
      _taxonomy_depth($term->depth) . ' ' . l($term->name, "taxonomy/term/{$term->tid}"),
      l(t('edit'), "admin/taxonomy/edit/term/{$term->tid}", array(), $destination),
    );
    $displayed_count++;

    // we're counting tids displayed
  }
  if (!$rows) {
    $rows[] = array(
      array(
        'data' => t('No terms available.'),
        'colspan' => '2',
      ),
    );
  }
  $GLOBALS['pager_page_array'][] = $start_from;

  // FIXME
  $GLOBALS['pager_total'][] = intval($total_entries / $page_increment) + 1;

  // FIXME
  if ($total_entries >= $page_increment) {
    $rows[] = array(
      array(
        'data' => theme('pager', NULL, $page_increment),
        'colspan' => '2',
      ),
    );
  }
  return theme('table', $header, $rows, array(
    'id' => 'taxonomy',
  ));
}