From c3380db41fbdf1ae28f1002f957c958e8f7f586e Mon Sep 17 00:00:00 2001 From: Paul Gevers Date: Wed, 21 Nov 2012 23:19:40 +0100 Subject: [PATCH] Third try on jstree inclusion (everything I tested works now) Not including the theme and style sheet. --- include/top_graph_header.php | 6 +- lib/graph_export.php | 149 +++++++++++++++++++++++++----------------- lib/html_tree.php | 101 +++++++++++++++++----------- 3 files changed, 153 insertions(+), 103 deletions(-) diff --git a/include/top_graph_header.php b/include/top_graph_header.php index 86bba4b..97766f4 100644 --- a/include/top_graph_header.php +++ b/include/top_graph_header.php @@ -84,8 +84,9 @@ $page_title = api_plugin_hook_function('page_title', draw_navigation_text("title - - + + + @@ -178,7 +179,6 @@ $page_title = api_plugin_hook_function('page_title', draw_navigation_text("title
- \n"); - fwrite($fp,"\n"); fwrite($fp,"\n"); fwrite($fp,"\n"); } @@ -1383,16 +1374,7 @@ function grow_dhtml_trees_export($fp, $tree_id) { include_once($config["library_path"] . "/tree.php"); include_once($config["library_path"] . "/data_query.php"); - fwrite($fp, "\n"); + fwrite($fp, "\t\n\n"); + fwrite($fp, "\n"); + } /* get_graph_tree_array_export - returns a list of graph trees taking permissions into account if @@ -1478,8 +1485,7 @@ function create_dhtml_tree_export($tree_id) { $dhtml_tree = array(); $dhtml_tree[0] = $start; $dhtml_tree[1] = read_graph_config_option("expand_hosts"); - $dhtml_tree[2] = "foldersTree = gFld(\"\", \"\")\n"; - $i = 2; + $i = 1; $tree_list = get_graph_tree_array_export(); @@ -1499,7 +1505,6 @@ function create_dhtml_tree_export($tree_id) { if (((read_config_option("export_tree_isolation") == "on") && ($tree_id == $tree["id"])) || (read_config_option("export_tree_isolation") == "off")) { - $i++; $hier_sql = "SELECT DISTINCT graph_tree_items.id, @@ -1524,17 +1529,24 @@ function create_dhtml_tree_export($tree_id) { if (sizeof($hierarchy) > 0) { foreach ($hierarchy as $leaf) { if ($dhtml_tree_id <> $tree["id"]) { - $dhtml_tree[$i] = "ou0 = insFld(foldersTree, gFld(\"" . get_tree_name($tree["id"]) . "\", \"" . clean_up_export_name(get_tree_name($tree["id"])) . "_leaf.html\"))\n"; + $i++; + $clean_id = clean_up_export_name(get_tree_name($tree["id"])); + $dhtml_tree[$i] = "\t\t
  • " . get_tree_name($tree["id"]) . "\n"; } $dhtml_tree_id = $tree["id"]; - $i++; $tier = tree_tier($leaf["order_key"]); if ($leaf["host_id"] > 0) { //It's a host - $dhtml_tree[$i] = "ou" . ($tier) . " = insFld(ou" . ($tier-1) . ", gFld(\"Host: " . $leaf["hostname"] . "\", \"" . clean_up_export_name($leaf["hostname"] . "_" . $leaf["id"]) . ".html\"))\n"; + $i++; + $dhtml_tree[$i] = "\t\t\t\n"; }else{ if ($dhtml_tree_id <> $tree["id"]) { - $dhtml_tree[$i] = "ou0 = insFld(foldersTree, gFld(\"" . get_tree_name($tree["id"]) . "\", \"" . clean_up_export_name(get_tree_name($tree["id"])) . "_leaf.html\"))\n"; $i++; + $clean_id = clean_up_export_name(get_tree_name($tree["id"])); + $dhtml_tree[$i] = "\t\t
  • " . get_tree_name($tree["id"]) . "
  • \n"; } } + $i++; + $dhtml_tree[$i] = "\t\t\n"; } } } @@ -1612,10 +1643,10 @@ function create_dhtml_tree_export($tree_id) { $dir - the export directory where graphs will either be staged or located. */ function create_export_directory_structure($cacti_root_path, $dir) { - /* create the treeview sub-directory */ - if (!is_dir("$dir/treeview")) { - if (!mkdir("$dir/treeview", 0755)) { - export_fatal("Create directory '" . $dir . "/treeview' failed. Can not continue"); + /* create the jquery sub-directory */ + if (!is_dir("$dir/js")) { + if (!mkdir("$dir/js", 0755)) { + export_fatal("Create directory '" . $dir . "/js' failed. Can not continue"); } } @@ -1626,8 +1657,6 @@ function create_export_directory_structure($cacti_root_path, $dir) { } } - $treeview_dir = $dir . "/treeview"; - /* css */ copy("$cacti_root_path/include/main.css", "$dir/main.css"); @@ -1639,18 +1668,15 @@ function create_export_directory_structure($cacti_root_path, $dir) { copy("$cacti_root_path/images/shadow_gray.gif", "$dir/shadow_gray.gif"); /* java scripts for the tree */ - copy("$cacti_root_path/include/treeview/ftiens4_export.js", "$treeview_dir/ftiens4.js"); - copy("$cacti_root_path/include/treeview/ua.js", "$treeview_dir/ua.js"); - - /* images for the tree */ - copy("$cacti_root_path/include/treeview/ftv2blank.gif", "$treeview_dir/ftv2blank.gif"); - copy("$cacti_root_path/include/treeview/ftv2lastnode.gif", "$treeview_dir/ftv2lastnode.gif"); - copy("$cacti_root_path/include/treeview/ftv2mlastnode.gif", "$treeview_dir/ftv2mlastnode.gif"); - copy("$cacti_root_path/include/treeview/ftv2mnode.gif", "$treeview_dir/ftv2mnode.gif"); - copy("$cacti_root_path/include/treeview/ftv2node.gif", "$treeview_dir/ftv2node.gif"); - copy("$cacti_root_path/include/treeview/ftv2plastnode.gif", "$treeview_dir/ftv2plastnode.gif"); - copy("$cacti_root_path/include/treeview/ftv2pnode.gif", "$treeview_dir/ftv2pnode.gif"); - copy("$cacti_root_path/include/treeview/ftv2vertline.gif", "$treeview_dir/ftv2vertline.gif"); + copy("$cacti_root_path/include/js/jquery/jquery.js", "$dir/js/jquery.js"); + copy("$cacti_root_path/include/js/jquery/jquery.jstree.js", "$dir/js/jquery.jstree.js"); + copy("$cacti_root_path/include/js/jquery/jquery.cookie.js", "$dir/js/jquery.cookie.js"); + + /* theme info for java scripts */ + copy("$cacti_root_path/include/js/jquery/themes/default/style.css", "$dir/js/style.css"); + copy("$cacti_root_path/include/js/jquery/themes/default/d.png", "$dir/js/d.png"); + copy("$cacti_root_path/include/js/jquery/themes/default/d.gif", "$dir/js/d.gif"); + copy("$cacti_root_path/include/js/jquery/themes/default/throbber.gif", "$dir/js/throbber.gif"); } function get_host_description($host_id) { @@ -1738,8 +1764,9 @@ define("HTML_HEADER_TREE", - - + + + diff --git a/lib/html_tree.php b/lib/html_tree.php index 861c6cc..a5bd796 100644 --- a/lib/html_tree.php +++ b/lib/html_tree.php @@ -495,17 +495,9 @@ function grow_dhtml_trees() { include_once($config["library_path"] . "/data_query.php"); ?> - +\n"; + $dhtml_tree[3] = "\t\n"; + $i++; + $dhtml_tree[$i] = "\n"; + return $dhtml_tree; } @@ -758,14 +789,6 @@ function grow_right_pane_tree($tree_id, $leaf_id, $host_group_data) { } } - print ""; - /* ================= input validation ================= */ input_validate_input_number(get_request_var_post("graphs")); input_validate_input_number(get_request_var_post("page")); -- 1.7.10.4