You are here

function _hierarchical_select_render in Hierarchical Select 5

Render the hierarchical select.

2 calls to _hierarchical_select_render()
hierarchical_select_ahah in ./hierarchical_select.module
Menu callback; AHAH callback: generates and outputs the appropriate HTML.
hierarchical_select_process in ./hierarchical_select.module
Hierarchical select form element processing function.

File

./hierarchical_select.module, line 178
This module defines the "hierarchical_select" form element, which is a greatly enhanced way for letting the user select an option in a hierarchy. Out of the box, this module supports the taxonomy and content_taxonomy modules, but that…

Code

function _hierarchical_select_render($hsid, $module, $selection, $store_lineage = FALSE, $enforce_deepest = TRUE, $required = FALSE, $params = array()) {

  // DEBUG
  //  $params['vid'] = 1;
  //  $selection = 8
  if (!$selection) {
    $selection = $store_lineage ? array() : -1;
  }
  if (!module_invoke($module, 'hierarchical_select_valid_item', $selection, $params)) {
    $selection = -1;
  }

  // Build the hierarchy.
  $hierarchy = new StdClass();
  if (!$store_lineage) {
    $depth = 0;

    // Get the root level.
    $hierarchy->levels[$depth] = module_invoke($module, 'hierarchical_select_root_level', $params);
    $depth++;

    // Build the lineage
    $hierarchy->lineage = module_invoke($module, 'hierarchical_select_lineage', $selection);
    if ($enforce_deepest) {
      $hierarchy->lineage = _hierarchial_select_enforce_deepest_selection($hierarchy->lineage, $hierarchy->levels[0], $module, $params);
    }

    // Build the rest of the hierarchy, based on the lineage.
    while ($depth < count($hierarchy->lineage)) {
      $hierarchy->levels[$depth] = module_invoke($module, 'hierarchical_select_children', $hierarchy->lineage[$depth - 1], $params);
      $depth++;
    }
  }
  else {

    // todo
    $hierarchy->lineage = $selection;

    // $selection should be an array of selected stuff now.
  }

  // DEBUG
  //  dpr($hierarchy);
  //  print _hierarchical_select_render_selects($hsid, $hierarchy);
  //  exit;
  // END DEBUG
  return _hierarchical_select_render_selects($hsid, $hierarchy);
}