Exemple #1
0
 public static function buildTreeHtmlDeQui($parent_id, $table, $colums, $where = null, $order = null)
 {
     $rows = array();
     TochucHelper::recursive($table, $colums, $where, $parent_id, 1, $rows);
     $current_depth = 1;
     $counter = 0;
     $result = '<ul>';
     foreach ($rows as $node) {
         $node_depth = $node['level'];
         $node_name = $node['text'];
         $node_id = $node['id'];
         if ($node_depth == $current_depth) {
             if ($counter > 0) {
                 $result .= '</li>';
             }
         } elseif ($node_depth > $current_depth) {
             $result .= '<ul>';
             $current_depth = $current_depth + ($node_depth - $current_depth);
         } elseif ($node_depth < $current_depth) {
             $result .= str_repeat('</li></ul>', $current_depth - $node_depth) . '</li>';
             $current_depth = $current_depth - ($current_depth - $node_depth);
         }
         $result .= '<li id="c' . $node_id . '"';
         $result .= $node_depth < 2 ? ' class="open"' : '';
         $result .= '><a href="#"><ins>&nbsp;</ins>' . $node_name . '</a>';
         ++$counter;
     }
     $result .= str_repeat('</li></ul>', $node_depth) . '</li>';
     $result .= '</ul>';
     return $result;
 }