function hs_content_taxonomy_hierarchical_select_children in Hierarchical Select 5.3
Same name and namespace in other branches
- 6.3 modules/hs_content_taxonomy.module \hs_content_taxonomy_hierarchical_select_children()
Implementation of hook_hierarchical_select_children().
1 call to hs_content_taxonomy_hierarchical_select_children()
- hs_content_taxonomy_views_hierarchical_select_children in modules/
hs_content_taxonomy_views.module - Implementation of hook_hierarchical_select_children().
File
- modules/
hs_content_taxonomy.module, line 444 - 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 to 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);
}