You are here

function _hierarchical_select_hierarchy_add_childinfo in Hierarchical Select 6.3

Same name and namespace in other branches
  1. 5.3 hierarchical_select.module \_hierarchical_select_hierarchy_add_childinfo()
  2. 7.3 hierarchical_select.module \_hierarchical_select_hierarchy_add_childinfo()

Extends a hierarchy object with child information: for each item in the hierarchy, the child count will be retrieved and stored in the hierarchy object, in the "childinfo" property. Items are grouped per level.

Parameters

$hierarchy: A hierarchy object with the "levels" property set.

$config: A config array with at least the following settings:

  • module
  • params

Return value

An updated hierarchy object with the "childinfo" property set.

1 call to _hierarchical_select_hierarchy_add_childinfo()
_hierarchical_select_hierarchy_generate in ./hierarchical_select.module
Generate the hierarchy object.

File

./hierarchical_select.module, line 1990
This module defines the "hierarchical_select" form element, which is a greatly enhanced way for letting the user select items in a hierarchy.

Code

function _hierarchical_select_hierarchy_add_childinfo($hierarchy, $config) {
  foreach ($hierarchy->levels as $depth => $level) {
    foreach (array_keys($level) as $item) {
      if (!preg_match('/(none|label_\\d+|create_new_item)/', $item)) {
        $hierarchy->childinfo[$depth][$item] = count(module_invoke($config['module'], 'hierarchical_select_children', $item, $config['params']));
      }
    }
  }
  return $hierarchy;
}