function html_dynamic_tree($session_variable, $tree_array, $root_node, $highlighted = null, $column_map = array()) { # Get the expanded tree array from the session $s_display_options = session_get_display_options($session_variable); $expanded = $s_display_options["filter"]["tree"]; # Add expanded node (if there is one) if (isset($_GET['expand'])) { $expanded[] = $_GET['expand']; } # Remove collapsed node (if there is one) if (isset($_GET['collapse'])) { $expanded = array_diff($expanded, array($_GET['collapse'])); } # Create variable to update the session $update_expanded = array("tree" => $expanded); # Update the tree variable in the session and get the returned value $s_display_options = session_set_display_options($session_variable, $update_expanded); $expanded = $s_display_options["filter"]["tree"]; global $db; # images html $img_tree_T = "<img align='absmiddle' border=0 src='" . IMG_SRC . "tree_dots_T.gif' alt=''>"; $img_tree_L = "<img align='absmiddle' border=0 src='" . IMG_SRC . "tree_dots_L.gif' alt=''>"; $img_tree_column = "<img align='absmiddle' border=0 src='" . IMG_SRC . "tree_dots_column.gif' alt=''>"; $img_tree_plus = "<img align='absmiddle' border=0 src='" . IMG_SRC . "tree_dots_plus.gif' alt=''>"; $img_tree_plus_b = "<img align='absmiddle' border=0 src='" . IMG_SRC . "tree_dots_plus_b.gif' alt=''>"; $img_tree_minus = "<img align='absmiddle' border=0 src='" . IMG_SRC . "tree_dots_minus.gif' alt=''>"; $img_tree_minus_b = "<img align='absmiddle' border=0 src='" . IMG_SRC . "tree_dots_minus_b.gif' alt=''>"; $img_tree_folder = "<img align='absmiddle' border=0 src='" . IMG_SRC . "tree_folder.gif' alt=''>"; $img_tree_folder_b = "<img align='absmiddle' border=0 src='" . IMG_SRC . "tree_folder_b.gif' alt=''>"; $img_spacer = "<img align='absmiddle' border=0 src='" . IMG_SRC . "1px_transparent.gif' width=15 height=1 alt=''>"; $column = $img_tree_column . $img_spacer; # display each child node for ($i = 0; $i < sizeof($tree_array); $i++) { $req_id = $tree_array[$i]['uid']; $req_version_id = requirement_get_latest_version($req_id); echo $img_spacer; foreach ($column_map as $column_type) { if ($column_type == "|") { echo $column; } elseif ($column_type == " ") { echo $img_spacer; } } # if the last node if ($i == sizeof($tree_array) - 1) { # if the last node has no children if (empty($tree_array[$i]["children"])) { echo $img_tree_L; # if the last node has children } else { # if last node has children and the node is in the expanded array if (util_array_value_search($req_id, $expanded)) { echo "<a href='?collapse={$req_id}#{$req_id}'>" . $img_tree_minus_b . $img_tree_folder_b . "</a>"; # if last node has children and the node is not in the expanded array } else { echo "<a href='?expand={$req_id}#{$req_id}'>" . $img_tree_plus_b . $img_tree_folder . "</a>"; } } $column_type = array(" "); # if not the last node } else { # if not the last node and the node has no children if (empty($tree_array[$i]["children"])) { echo $img_tree_T; } else { # if not the last node and the node is in the expanded array if (util_array_value_search($req_id, $expanded)) { echo "<a href='?collapse={$req_id}#{$req_id}'>" . $img_tree_minus . $img_tree_folder_b . "</a>"; # if not the last node and the node is not in the expanded array } else { echo "<a href='?expand={$req_id}#{$req_id}'>" . $img_tree_plus . $img_tree_folder . "</a>"; } } $column_type = array("|"); } # prints a closed folder if node has no children and $root_node is set to true if (empty($tree_array[$i]["children"]) && $root_node) { echo $img_tree_folder; } # formatting for highlighted node $style = ""; if ($req_id == $highlighted) { $style = "style='font-weight: bold; font-size: 120%;'"; } # print the node name echo " <a {$style} name={$req_id} href='requirement_detail_page.php?req_id={$req_id}&req_version_id={$req_version_id}'>" . $tree_array[$i]['name'] . "</a>"; echo "<br>" . NEWLINE; # display this nodes children if (util_array_value_search($req_id, $expanded)) { html_dynamic_tree($session_variable, $tree_array[$i]['children'], false, $highlighted, array_merge($column_map, $column_type)); } } }
print "</div>"; print "</form>"; $rows_top_level_requirements = requirement_get($project_id, $page_number = 0, $order_by = REQ_FILENAME, $order_dir = "ASC", $filter_doc_type, $filter_status, $filter_area_covered, $filter_functionality, $filter_assign_release, $filter_show_versions = 'latest', $filter_per_page, $filter_search, $filter_priority, $csv_name = null, $root_node = true); # tree array $tree = array(); if ($rows_top_level_requirements) { # get the children of the top level requirements foreach ($rows_top_level_requirements as $row_req) { $root_node = $row_req[REQ_ID]; $req_version = $row_req[REQ_VERS_VERSION]; $root_node_name = $row_req[REQ_FILENAME]; # build the tree array $tree[] = array("uid" => $root_node, "name" => $root_node_name, "children" => requirement_get_children($root_node)); } # print the tree array as html html_dynamic_tree("requirements", $tree, $root_node = true); } else { html_no_records_found_message(lang_get("no_requirements")); } html_print_footer(); # --------------------------------------------------------------------- # $Log: requirement_associations_page.php,v $ # Revision 1.6 2007/02/03 10:25:53 gth2 # no message # # Revision 1.5 2006/08/05 22:08:37 gth2 # adding NEWLINE constant to support multiple OS newline chars - gth # # Revision 1.4 2006/05/03 22:05:19 gth2 # no message #