You are here

function og_vocab_build_list_items in OG Vocabulary 5

Same name and namespace in other branches
  1. 6 og_vocab.module \og_vocab_build_list_items()
1 call to og_vocab_build_list_items()
og_vocab_block_view in ./og_vocab.module

File

./og_vocab.module, line 159
Give each group its own system controlled vocabularies

Code

function og_vocab_build_list_items(&$index, $tree) {
  $items = array();
  $current_depth = $tree[$index]->depth;
  while ($index < count($tree) && $tree[$index]->depth >= $current_depth) {
    $term = $tree[$index];
    $count = taxonomy_term_count_nodes($term->tid);
    if ($count) {
      $term_path = "taxonomy/term/{$term->tid}";
      $term_link = l($term->name, $term_path, array(
        'title' => t($term->description),
      ));
      $item = $term_link . " ({$count})";
      if ($tree[$index + 1]->depth > $current_depth) {
        $index++;
        $items[] = array(
          'data' => $item,
          'children' => og_vocab_build_list_items($index, $tree),
        );
      }
      else {
        $items[] = $item;
        $index++;
      }
    }
    else {
      $index++;
    }
  }
  return $items;
}