Description: treeview has a license issue, cacti upstream is going to replace it with functionality from jquery.jstree. . This patch implements the changes needed for an upstream layout where the necessary code is in cacti/include/js/jquery/ but the code in that path is not included in this patch. . The necessary jquery scripts and theme info can come from cacti upstream and from debian packages (libjs-jquery and libjs-jquery-cookie) The version used when creating this patch can be found here: http://svn.cacti.net/viewvc/cacti/branches/0.8.9/include/js/jquery/jquery.js?pathrev=7324 http://svn.cacti.net/viewvc/cacti/branches/0.8.9/include/js/jquery/jquery.jstree.js?pathrev=7324 http://svn.cacti.net/viewvc/cacti/branches/main/include/js/jquery/themes/default/?pathrev=7324 http://anonscm.debian.org/gitweb/?p=pkg-javascript/jquery-goodies.git;a=blob;f=cookie/jquery.cookie.js;hb=c50e1a2d599cb48893e8d77470e71e83e44dfdb5 . This patch does NOT implement the changes needed for the Debian package of cacti. . This patch was updated with the patch from Jan Zalesak in http://bugs.debian.org/702690 which was further improved to also cover lib/graph_export.php and to keep tag alignment consistent. Bug: http://bugs.cacti.net/view.php?id=2228 Bug-Debian: http://bugs.debian.org/679980 Author: Paul Gevers Date: Sun, 31 Mar 2013 11:59:05 +0200 --- a/include/top_graph_header.php +++ b/include/top_graph_header.php @@ -84,8 +84,9 @@ - - + + + @@ -178,7 +179,6 @@
- \n"); - fwrite($fp,"\n"); fwrite($fp,"\n"); fwrite($fp,"\n"); } @@ -1383,16 +1374,7 @@ include_once($config["library_path"] . "/tree.php"); include_once($config["library_path"] . "/data_query.php"); - fwrite($fp, "\n"); + fwrite($fp, "\n"); + fwrite($fp, "\n"); + } /* get_graph_tree_array_export - returns a list of graph trees taking permissions into account if @@ -1478,8 +1485,7 @@ $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 @@ 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, @@ -1522,19 +1527,53 @@ $dhtml_tree_id = 0; if (sizeof($hierarchy) > 0) { + $last_tier = 1; + $openli = false; + $lasthost = false; + $opentree = false; 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"; + if ($opentree) { + $i++; + $dhtml_tree[$i] = "\t\t\t\n\t\t\n\t\n"; + } + $i++; + $clean_id = clean_up_export_name(get_tree_name($tree["id"])); + $dhtml_tree[$i] = "\t\n\t\t\n\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"; } } } @@ -1612,10 +1693,10 @@ $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 +1707,6 @@ } } - $treeview_dir = $dir . "/treeview"; - /* css */ copy("$cacti_root_path/include/main.css", "$dir/main.css"); @@ -1639,18 +1718,15 @@ 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 +1814,9 @@ - - + + + --- a/lib/html_tree.php +++ b/lib/html_tree.php @@ -495,17 +495,9 @@ include_once($config["library_path"] . "/data_query.php"); ?> - +\n"; + $i = 2; $tree_list = get_graph_tree_array(); @@ -567,7 +583,6 @@ if (sizeof($tree_list) > 0) { foreach ($tree_list as $tree) { - $i++; $hierarchy = db_fetch_assoc("select graph_tree_items.id, graph_tree_items.title, @@ -583,21 +598,45 @@ and graph_tree_items.local_graph_id = 0 order by graph_tree_items.order_key"); - $dhtml_tree[$i] = "ou0 = insFld(foldersTree, gFld(\"" . htmlspecialchars($tree["name"]) . "\", \"" . htmlspecialchars("graph_view.php?action=tree&tree_id=" . $tree["id"]) . "\"))\n"; $i++; - $dhtml_tree[$i] = "ou0.xID = \"tree_" . $tree["id"] . "\"\n"; + $dhtml_tree[$i] = "\t\n"; } + $i++; + $dhtml_tree[$i] = "\t\t\n\t\n"; } } + $i++; + $dhtml_tree[$i] = "\n"; + return $dhtml_tree; } @@ -758,14 +833,6 @@ } } - print ""; - /* ================= input validation ================= */ input_validate_input_number(get_request_var_post("graphs")); input_validate_input_number(get_request_var_post("page"));