function tripal_vocabulary_lookup_term_children_format
3.x tripal.term_lookup.inc | tripal_vocabulary_lookup_term_children_format($children) |
A helper function to format an array of terms into a list for the web page.
Parameters
$children: A list of children terms.
2 calls to tripal_vocabulary_lookup_term_children_format()
- tripal_vocabulary_lookup_term_children_ajax in tripal/
includes/ tripal.term_lookup.inc - An ajax callback to get the children of a term.
- tripal_vocabulary_lookup_vocab_page in tripal/
includes/ tripal.term_lookup.inc - Provides the content for a single controlled vocabulary.
File
- tripal/
includes/ tripal.term_lookup.inc, line 187
Code
function tripal_vocabulary_lookup_term_children_format($children) {
$items = '<ul id="tripal-cv-lookup-tree">';
foreach ($children as $child) {
$grand = tripal_get_term_children($child['vocabulary']['short_name'], $child['accession']);
$num_grand = count($grand);
$items .= '<li vocabulary = "' . $child['vocabulary']['short_name'] . '" ' .
'accession = "' . $child['accession'] . '" ' .
'children = "' . $num_grand . '" ' .
'state = "closed" ' .
'class = "cv-lookup-tree-node">';
$class = 'tree-node-closed';
if ($num_grand == 0) {
$class = 'tree-node-single';
}
$items .= '<i class = "tree-node-icon ' . $class . '"></i>';
$items .= l($child['name'], 'cv/lookup/' . $child['vocabulary']['short_name'] . '/' . $child['accession'], array('attributes' => array('target' => '_blank')));
if ($child['accession'] != $child['name']) {
$items .= ' [' . $child['vocabulary']['short_name'] . ':' . $child['accession'] . '] ';
}
if ($num_grand > 0) {
$items .= ' (' . $num_grand . ')';
}
$items .= '</li>';
}
$items .= '</ul>';
if (count($children) == 0) {
$items = '';
}
return $items;
}