function theme_term_tree_list in Taxonomy Term Reference Tree Widget 7
Same name and namespace in other branches
- 8 term_reference_tree.module \theme_term_tree_list()
- 7.2 term_reference_tree.widget.inc \theme_term_tree_list()
Themes the term tree display (as opposed to the select widget).
1 theme call to theme_term_tree_list()
File
- ./
term_reference_tree.widget.inc, line 163
Code
function theme_term_tree_list($variables) {
$element =& $variables['element'];
$data =& $element['#data'];
$tree = array();
// For each selected term.
foreach ($data as $item) {
// Loop if the term ID is not zero.
$values = array();
$tid = $item['tid'];
$original_tid = $tid;
while ($tid != 0) {
// Unshift the term onto an array.
array_unshift($values, $tid);
// Repeat with parent term.
$tid = _term_reference_tree_get_parent($tid);
}
$current =& $tree;
// For each term in the above array.
foreach ($values as $tid) {
if (!isset($current['children'][$tid])) {
$current['children'][$tid] = array(
'selected' => FALSE,
);
}
// If this is the last value in the array,
// tree[children][term_id][selected] = TRUE.
if ($tid == $original_tid) {
$current['children'][$tid]['selected'] = TRUE;
}
$current['children'][$tid]['tid'] = $tid;
$current =& $current['children'][$tid];
}
}
$output = '<div class="term-tree-list">';
$output .= _term_reference_tree_output_list_level($element, $tree);
$output .= '</div>';
return $output;
}