You are here

function bundle_inherit_sort_rows in Bundle Inherit 7

Sort rows hierarchycly and allow to indent them.

Parameters

$entity_type: Entity type.

$rows: Rows.

$apply_indention: Whether ty apply indention or not. Default to TRUE.

$indention_options: (optional) Indention options. Structured array with following keys:

  • 'indention callback': The function to call to indent row.

Takes $row, $indention_options and $level as arguments. $level is the bundle level in hierarchy started from zero. Default callback is bundle_inherit_sort_rows_default_indent.

  • 'name col index': Used in default indention callback. If each row is an

array you can specify the column to indent. If not you cen set 'name col index' to 'self' and entire row will be indented.

  • 'indenter': Used in default indention callback. It is like a delimiter

in implode() function. Will be multiplied on the bundle level and prepend the row value.

File

./bundle_inherit.module, line 377
Bundle Inherit module.

Code

function bundle_inherit_sort_rows($entity_type, &$rows, $apply_indention = TRUE, $indention_options = array()) {
  $indention_options += array(
    'name col index' => 0,
    'indenter' => '- - ',
    'indention callback' => 'bundle_inherit_sort_rows_default_indent',
    'apply indention' => $apply_indention,
  );
  $tree = bundle_inherit_get_tree($entity_type);
  $new_rows = array();
  foreach ($tree as $bundle_type => $bundle) {
    if (isset($rows[$bundle_type])) {
      $new_row = $rows[$bundle_type];
      if ($indention_options['apply indention']) {
        $indention_options['indention callback']($new_row, $indention_options, $bundle['depth']);
      }
      $new_rows[] = $new_row;
    }
  }
  $rows = $new_rows;
}