function _tft_output_children in Taxonomy File Tree 8
Same name and namespace in other branches
- 3.x tft.module \_tft_output_children()
Return the sub-tree as an unordered list.
Parameters
array $tree: The folder tree.
bool $root: = FALSE A flag for setting this <ul> as the root <ul>.
Return value
array The HTML
1 call to _tft_output_children()
- _tft_output_tree in ./
tft.module - Output the tree as an HTML unordered list.
File
- ./
tft.module, line 401 - Contains tft.module.
Code
function _tft_output_children(array $tree, $root = FALSE) {
$data = [
'#theme' => 'item_list',
'#list_type' => 'ul',
'#attributes' => [
'class' => $root ? 'root-folder' : 'sub-folder',
],
'#items' => [],
];
$first = TRUE;
$odd = TRUE;
$count = count($tree);
$i = 1;
foreach ($tree as $tid => $item) {
$span_class = '';
if ($odd) {
$odd = FALSE;
$class = ' odd';
}
else {
$odd = TRUE;
$class = ' even';
}
if ($first) {
$class .= ' first';
$first = FALSE;
}
if ($i == $count) {
$class .= ' last';
}
if (isset($item['children'])) {
$class .= ' parent-folder closed';
$span_class = ' closed-icon';
}
$list_item = _tft_li($item['name'], $tid, $class, $span_class);
if (isset($item['children'])) {
$list_item[] = _tft_output_children($item['children']);
}
$data['#items'][] = $list_item;
$i++;
}
return $data;
}