function _bricks_tree_items in Bricks 7.4
Same name and namespace in other branches
- 7.5 bricks.module \_bricks_tree_items()
Helper function: converts element's items to tree structure.
2 calls to _bricks_tree_items()
- bricks_preprocess_entity in ./
bricks.module - Preprocesses variables for entity.tpl.php.
- bricks_process_field in ./
bricks.module - Processes variables for theme_field().
File
- ./
bricks.module, line 106
Code
function _bricks_tree_items($element, $items) {
// Filter items:
$items = array_intersect_key($items, element_children($items));
// Simplify items:
foreach ($items as $delta => $item) {
$item = reset($item);
$item = reset($item);
$item['bricks'] = array();
$items[$delta] = $item;
}
// Process items in reverse order (without recursion):
$ritems = array_reverse($items, TRUE);
foreach ($ritems as $delta => $item) {
if (isset($element['#items'][$delta]['options'])) {
$items[$delta]['#options'] = $element['#items'][$delta]['options'];
}
if (isset($element['#items'][$delta]['parent_delta'])) {
$parent = $element['#items'][$delta]['parent_delta'];
array_unshift($items[$parent]['bricks'], $items[$delta]);
unset($items[$delta]);
}
}
return $items;
}