You are here

function nodeorder_overview_terms in Node Order 6

Same name and namespace in other branches
  1. 5 nodeorder.module \nodeorder_overview_terms()

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

This code was cut and pasted from taxonomy_overview_terms. If If we were able to add another operation onto each term on the admin/content/taxonomy/VID page then we wouldn't even need this duplicate function.

TODO - put in a patch for a taxonomy hook that lets us add admin operation links per term... maybe it would call module_invoke_all('taxonomy', 'list', 'term', $term) and array_merge the results with each $row[]...

1 string reference to 'nodeorder_overview_terms'
nodeorder_menu in ./nodeorder.module
Implementation of hook_menu().

File

./nodeorder.module, line 808
Nodeorder module.

Code

function nodeorder_overview_terms($vid) {
  if (!nodeorder_vocabulary_can_be_ordered($vid)) {
    return t('This vocabulary is not orderable.  If you would like it to be orderable, check the Orderable box ') . l(t('here'), 'admin/content/taxonomy/edit/vocabulary' . $vid) . '.';
  }
  $header = array(
    t('Name'),
    t('Operations'),
  );
  $vocabularies = taxonomy_get_vocabularies();
  $vocabulary = $vocabularies[$vid];
  if (!$vocabulary) {
    return drupal_not_found();
  }
  drupal_set_title(t('Terms in %vocabulary', array(
    '%vocabulary' => $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(
      (isset($term->depth) && $term->depth > 0 ? theme('indentation', $term->depth) : '') . l($term->name, "nodeorder/term/{$term->tid}"),
      l(t('order nodes'), "nodeorder/term/{$term->tid}/order"),
    );
    $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',
  ));
}