You are here

function og_vocab_build_list_items in OG Vocabulary 6

Same name and namespace in other branches
  1. 5 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 650
Give each group its own system controlled vocabularies.

Code

function og_vocab_build_list_items(&$index, $tree) {
  $items = array();
  if (array_key_exists($index, $tree)) {
    $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 (isset($tree[$index + 1]) && $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;
}