You are here

function tft_output_children in Taxonomy File Tree 7.2

Same name and namespace in other branches
  1. 7 tft.module \tft_output_children()

Return the sub-tree as an unordered list.

Parameters

array $tree: The folder tree.

boolean $root = FALSE: A flag for setting this <ul> as the root <ul>.

Return value

string

Related topics

1 call to tft_output_children()
tft_output_tree in ./tft.module
Output the tree as an HTML unordered list.

File

./tft.module, line 403
Hook implementations and module logic for TFT.

Code

function tft_output_children($tree, $root = FALSE) {
  $html = '<ul class="' . ($root ? 'root-folder' : 'sub-folder') . '">';
  $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';
    }
    $html .= tft_li($item['name'], $tid, $class, $span_class);
    if (isset($item['children'])) {
      $html .= tft_output_children($item['children']);
    }
    $html .= '</li>';
    $i++;
  }
  $html .= '</ul>';
  return $html;
}