You are here

function _taxonomy_edge_unify_parents in Taxonomy Edge 7.2

Same name and namespace in other branches
  1. 8 taxonomy_edge.module \_taxonomy_edge_unify_parents()
  2. 6 taxonomy_edge.module \_taxonomy_edge_unify_parents()
  3. 7 taxonomy_edge.module \_taxonomy_edge_unify_parents()

Unify parents

Parameters

mixed $parents:

Return value

array Flattened array of parent term IDs

3 calls to _taxonomy_edge_unify_parents()
taxonomy_edge_get_tree_optimized in ./taxonomy_edge.core.inc
Reimplementation of taxonomy_get_tree(). Limit db fetch to only specified parent AND use presorting.
_taxonomy_edge_taxonomy_term_insert in ./taxonomy_edge.module
Insert a term into the edge tree.
_taxonomy_edge_taxonomy_term_update in ./taxonomy_edge.module
Update a term in the edge tree.

File

./taxonomy_edge.module, line 676
Selecting all children of a given taxonomy term can be a pain. This module makes it easier to do this, by maintaining a complete list of edges for each term using the adjecency matrix graph theory.

Code

function _taxonomy_edge_unify_parents($parents) {
  $parents = is_array($parents) ? $parents : array(
    $parents,
  );
  $new_parents = array();
  foreach ($parents as $parent) {
    if (is_array($parent)) {
      foreach ($parent as $new) {
        $new_parents[] = $new;
      }
    }
    else {
      $new_parents[] = $parent;
    }
  }
  return $new_parents;
}