You are here

function hs_content_taxonomy_hierarchical_select_children in Hierarchical Select 6.3

Same name and namespace in other branches
  1. 5.3 modules/hs_content_taxonomy.module \hs_content_taxonomy_hierarchical_select_children()

Implementation of hook_hierarchical_select_children().

File

modules/hs_content_taxonomy.module, line 382
Implementation of the Hierarchical Select API for the Content Taxonomy module.

Code

function hs_content_taxonomy_hierarchical_select_children($parent, $params) {
  static $tree;
  $vid = $params['vid'];
  $tid = $params['tid'];
  $depth = $params['depth'];

  // Keep a static cache of the entire tree, this allows us to quickly look up
  // if a term is not too deep – because if it's too deep, we don't want to
  // return any children.
  if (!isset($tree[$vid][$tid])) {
    $raw_tree = _hs_taxonomy_hierarchical_select_get_tree($vid, $tid);
    foreach ($raw_tree as $term) {
      $tree[$vid][$tid][$term->tid] = $term->depth;
    }
  }
  $terms = $depth > 0 && $tree[$vid][$tid][$parent] + 1 >= $depth ? array() : _hs_taxonomy_hierarchical_select_get_tree($vid, $parent, -1, 1);
  return _hs_taxonomy_hierarchical_select_terms_to_options($terms);
}