You are here

function taxonomy_manager_tree_get_terms_to_expand in Taxonomy Manager 6

Same name and namespace in other branches
  1. 6.2 taxonomy_manager.module \taxonomy_manager_tree_get_terms_to_expand()
  2. 7 taxonomy_manager.module \taxonomy_manager_tree_get_terms_to_expand()

marks parent terms to expand if a child terms is selected by default

1 call to taxonomy_manager_tree_get_terms_to_expand()
taxonomy_manager_tree_process_elements in ./taxonomy_manager.module
Processes the tree form element

File

./taxonomy_manager.module, line 411
Taxonomy Manager

Code

function taxonomy_manager_tree_get_terms_to_expand($tree, $default_values, $multiple) {
  $terms = array();
  foreach (array_reverse($tree) as $term) {
    if (in_array($term->tid, array_values($default_values)) || in_array($term->tid, $terms)) {
      if (is_array($term->parents)) {
        foreach ($term->parents as $parent) {
          if ($parent) {
            $terms[$parent] = $parent;
          }
          if (!$multiple) {
            break;
          }
        }
      }
    }
  }
  return $terms;
}