function theme_term_tree_list in Taxonomy Term Reference Tree Widget 7.2
Same name and namespace in other branches
- 8 term_reference_tree.module \theme_term_tree_list()
- 7 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 155
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) {
# current[children][term_id] = new array
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;
}