tag after ending
the box */
function html_end_box($trailing_br = true) { ?>
"; } ?>
tag before the start of the table */
function html_graph_start_box($cellpadding = 3, $leading_br = true) {
if ($leading_br == true) {
print " \n";
}
print "
\n";
}
/* html_graph_end_box - draws the end of an HTML graph view box */
function html_graph_end_box() {
print "
";
}
/* html_graph_area - draws an area the contains full sized graphs
@arg $graph_array - the array to contains graph information. for each graph in the
array, the following two keys must exist
$arr[0]["local_graph_id"] // graph id
$arr[0]["title_cache"] // graph title
@arg $no_graphs_message - display this message if no graphs are found in $graph_array
@arg $extra_url_args - extra arguments to append to the url
@arg $header - html to use as a header
@arg $columns - the number of columns to present */
function html_graph_area(&$graph_array, $no_graphs_message = "", $extra_url_args = "", $header = "", $columns = 0) {
global $config;
$i = 0; $k = 0; $j = 0;
$num_graphs = sizeof($graph_array);
if ($columns == 0) {
$columns = read_graph_config_option('num_columns');
}
?>
0) {
if ($header != "") {
print $header;
}
$start = true;
foreach ($graph_array as $graph) {
if (isset($graph["graph_template_name"])) {
if (isset($prev_graph_template_name)) {
if ($prev_graph_template_name != $graph["graph_template_name"]) {
$print = true;
$prev_graph_template_name = $graph["graph_template_name"];
}else{
$print = false;
}
}else{
$print = true;
$prev_graph_template_name = $graph["graph_template_name"];
}
if ($print) {
print "
";
}
}
}
/* html_graph_thumbnail_area - draws an area the contains thumbnail sized graphs
@arg $graph_array - the array to contains graph information. for each graph in the
array, the following two keys must exist
$arr[0]["local_graph_id"] // graph id
$arr[0]["title_cache"] // graph title
@arg $no_graphs_message - display this message if no graphs are found in $graph_array
@arg $extra_url_args - extra arguments to append to the url
@arg $header - html to use as a header
@arg $columns - the number of columns to present */
function html_graph_thumbnail_area(&$graph_array, $no_graphs_message = "", $extra_url_args = "", $header = "", $columns = 0) {
global $config;
$i = 0; $k = 0; $j = 0;
$num_graphs = sizeof($graph_array);
if ($columns == 0) {
$columns = read_graph_config_option('num_columns');
}
?>
0) {
if ($header != "") {
print $header;
}
$start = true;
foreach ($graph_array as $graph) {
if (isset($graph["graph_template_name"])) {
if (isset($prev_graph_template_name)) {
if ($prev_graph_template_name != $graph["graph_template_name"]) {
$prev_graph_template_name = $graph["graph_template_name"];
}
}else{
$prev_graph_template_name = $graph["graph_template_name"];
}
}elseif (isset($graph["data_query_name"])) {
if (isset($prev_data_query_name)) {
if ($prev_data_query_name != $graph["data_query_name"]) {
$print = true;
$prev_data_query_name = $graph["data_query_name"];
}else{
$print = false;
}
}else{
$print = true;
$prev_data_query_name = $graph["data_query_name"];
}
if ($print) {
if (!$start) {
while(($i % $columns) != 0) {
print "
";
}
}
}
function graph_drilldown_icons($local_graph_id, $type = 'graph_buttons') {
global $config;
$aggregate_url = aggregate_build_children_url($local_graph_id);
print " \n";
print " \n";
print " \n";
if (read_config_option('realtime_enabled') == 'on') {
print " \n";
}
if ($aggregate_url != '') {
print $aggregate_url;
}
api_plugin_hook($type, array('hook' => 'graphs_thumbnails', 'local_graph_id' => $local_graph_id, 'rra' => 0, 'view_type' => ''));
}
/* html_nav_bar - draws a navigation bar which includes previous/next links as well as current
page information
@arg $base_url - the base URL will all filter options except page#
@arg $max_pages - the maximum number of pages to display
@arg $current_page - the current page in the navigation system
@arg $rows_per_page - the number of rows that are displayed on a single page
@arg $total_rows - the total number of rows in the navigation system
@arg $object - the object types that is being displayed
@arg $page_var - the object types that is being displayed
@arg $return_to - paint the resulting page into this dom object */
function html_nav_bar($base_url, $max_pages, $current_page, $rows_per_page, $total_rows, $colspan=30, $object = "Rows", $page_var = "page", $return_to = "") {
if ($total_rows > $rows_per_page) {
if (substr_count($base_url, '?') == 0) {
$base_url = trim($base_url) . '?';
}else{
$base_url = trim($base_url) . '&';
}
$url_page_select = get_page_list($current_page, $max_pages, $rows_per_page, $total_rows, $base_url, $page_var, $return_to);
$nav = "
\n";
}
return $nav;
}
/* html_header_sort - draws a header row suitable for display inside of a box element. When
a user selects a column header, the collback function "filename" will be called to handle
the sort the column and display the altered results.
@arg $header_items - an array containing a list of column items to display. The
format is similar to the html_header, with the exception that it has three
dimensions associated with each element (db_column => display_text, default_sort_order)
alternatively (db_column => array('display' = 'blah', 'align' = 'blah', 'sort' = 'blah'))
@arg $sort_column - the value of current sort column.
@arg $sort_direction - the value the current sort direction. The actual sort direction
will be opposite this direction if the user selects the same named column.
@arg $last_item_colspan - the TD 'colspan' to apply to the last cell in the row */
function html_header_sort($header_items, $sort_column, $sort_direction, $last_item_colspan = 1) {
/* reverse the sort direction */
if ($sort_direction == "ASC") {
$new_sort_direction = "DESC";
}else{
$new_sort_direction = "ASC";
}
print "
\n";
$i = 1;
foreach ($header_items as $db_column => $display_array) {
if (array_key_exists('display', $display_array)) {
$display_text = $display_array['display'];
if ($sort_column == $db_column) {
$icon = $sort_direction;
$direction = $new_sort_direction;
}else{
$icon = '';
if (isset($display_array['sort'])) {
$direction = $display_array['sort'];
}else{
$direction = 'ASC';
}
}
if (isset($display_array['align'])) {
$align = $display_array['align'];
}else{
$align = 'left';
}
if (isset($display_array['tip'])) {
$tip = $display_array['tip'];
}else{
$tip = '';
}
}else{
/* by default, you will always sort ascending, with the exception of an already sorted column */
if ($sort_column == $db_column) {
$icon = $sort_direction;
$direction = $new_sort_direction;
$display_text = $display_array[0];
}else{
$icon = '';
$display_text = $display_array[0];
$direction = $display_array[1];
}
$align = 'left';
$tip = '';
}
if (strtolower($icon) == 'asc') {
$icon = 'fa fa-sort-asc';
}elseif (strtolower($icon) == 'desc') {
$icon = 'fa fa-sort-desc';
}else{
$icon = 'fa fa-unsorted';
}
if (($db_column == "") || (substr_count($db_column, "nosort"))) {
print "
" . $display_text . "
\n";
}else{
print "
";
print "
" . $display_text . "
\n";
}
$i++;
}
print "
\n";
}
/* html_header_sort_checkbox - draws a header row with a 'select all' checkbox in the last cell
suitable for display inside of a box element. When a user selects a column header,
the collback function "filename" will be called to handle the sort the column and display
the altered results.
@arg $header_items - an array containing a list of column items to display. The
format is similar to the html_header, with the exception that it has three
dimensions associated with each element (db_column => display_text, default_sort_order)
alternatively (db_column => array('display' = 'blah', 'align' = 'blah', 'sort' = 'blah'))
@arg $sort_column - the value of current sort column.
@arg $sort_direction - the value the current sort direction. The actual sort direction
will be opposite this direction if the user selects the same named column.
@arg $form_action - the url to post the 'select all' form to */
function html_header_sort_checkbox($header_items, $sort_column, $sort_direction, $include_form = true, $form_action = "") {
static $page = 0;
/* reverse the sort direction */
if ($sort_direction == "ASC") {
$new_sort_direction = "DESC";
}else{
$new_sort_direction = "ASC";
}
/* default to the 'current' file */
if ($form_action == "") { $form_action = basename($_SERVER["PHP_SELF"]); }
print "
\n";
foreach($header_items as $db_column => $display_array) {
$icon = '';
if (array_key_exists('display', $display_array)) {
$display_text = $display_array['display'];
if ($sort_column == $db_column) {
$icon = $sort_direction;
$direction = $new_sort_direction;
}else{
$icon = '';
if (isset($display_array['sort'])) {
$direction = $display_array['sort'];
}else{
$direction = 'ASC';
}
}
if (isset($display_array['align'])) {
$align = $display_array['align'];
}else{
$align = 'left';
}
if (isset($display_array['tip'])) {
$tip = $display_array['tip'];
}else{
$tip = '';
}
}else{
/* by default, you will always sort ascending, with the exception of an already sorted column */
if ($sort_column == $db_column) {
$icon = $sort_direction;
$direction = $new_sort_direction;
$display_text = $display_array[0];
}else{
$icon = '';
$display_text = $display_array[0];
$direction = $display_array[1];
}
$align = 'left';
$tip = '';
}
if (strtolower($icon) == 'asc') {
$icon = 'fa fa-sort-asc';
}elseif (strtolower($icon) == 'desc') {
$icon = 'fa fa-sort-desc';
}else{
$icon = 'fa fa-unsorted';
}
if (($db_column == "") || (substr_count($db_column, "nosort"))) {
print "
" . $display_text . "
\n";
}else{
print "
";
print "
" . $display_text . "
\n";
}
}
print "
" . ($include_form ? "
\n":"");
print "
\n";
$page++;
}
/* html_header - draws a header row suitable for display inside of a box element
@arg $header_items - an array containing a list of items to be included in the header
alternatively and array of header names and alignment array('display' = 'blah', 'align' = 'blah')
@arg $last_item_colspan - the TD 'colspan' to apply to the last cell in the row */
function html_header($header_items, $last_item_colspan = 1) {
print "
\n";
}
/* html_header_checkbox - draws a header row with a 'select all' checkbox in the last cell
suitable for display inside of a box element
@arg $header_items - an array containing a list of items to be included in the header
alternatively and array of header names and alignment array('display' = 'blah', 'align' = 'blah')
@arg $form_action - the url to post the 'select all' form to */
function html_header_checkbox($header_items, $include_form = true, $form_action = "", $resizable = true) {
/* default to the 'current' file */
if ($form_action == "") { $form_action = basename($_SERVER["PHP_SELF"]); }
print "
\n";
}
/* html_create_list - draws the items for an html dropdown given an array of data
@arg $form_data - an array containing data for this dropdown. it can be formatted
in one of two ways:
$array["id"] = "value";
-- or --
$array[0]["id"] = 43;
$array[0]["name"] = "Red";
@arg $column_display - used to indentify the key to be used for display data. this
is only applicable if the array is formatted using the second method above
@arg $column_id - used to indentify the key to be used for id data. this
is only applicable if the array is formatted using the second method above
@arg $form_previous_value - the current value of this form element */
function html_create_list($form_data, $column_display, $column_id, $form_previous_value) {
if (empty($column_display)) {
foreach (array_keys($form_data) as $id) {
print '\n";
}
}else{
if (sizeof($form_data) > 0) {
foreach ($form_data as $row) {
print "\n";
}else{
print ">" . title_trim(null_out_substitutions(htmlspecialchars($row[$column_display])), 75) . "\n";
}
}
}
}
}
/* html_split_string - takes a string and breaks it into a number of separated segments
@arg $string - string to be modified and returned
@arg $length - the maximal string length to split to
@arg $forgiveness - the maximum number of characters to walk back from to determine
the correct break location.
@returns $new_string - the modified string to be returned. */
function html_split_string($string, $length = 70, $forgiveness = 10) {
$new_string = "";
$j = 0;
$done = false;
while (!$done) {
if (strlen($string) > $length) {
for($i = 0; $i < $forgiveness; $i++) {
if (substr($string, $length-$i, 1) == " ") {
$new_string .= substr($string, 0, $length-$i) . " ";
break;
}
}
$string = substr($string, $length-$i);
}else{
$new_string .= $string;
$done = true;
}
$j++;
if ($j > 4) break;
}
return $new_string;
}
/* draw_graph_items_list - draws a nicely formatted list of graph items for display
on an edit form
@arg $item_list - an array representing the list of graph items. this array should
come directly from the output of db_fetch_assoc()
@arg $filename - the filename to use when referencing any external url
@arg $url_data - any extra GET url information to pass on when referencing any
external url
@arg $disable_controls - whether to hide all edit/delete functionality on this form */
function draw_graph_items_list($item_list, $filename, $url_data, $disable_controls) {
global $colors, $config;
include($config["include_path"] . "/global_arrays.php");
print "
";
}
}
/* draw_menu - draws the cacti menu for display in the console */
function draw_menu($user_menu = "") {
global $config, $user_auth_realm_filenames, $menu;
if (strlen($user_menu == 0)) {
$user_menu = $menu;
}
?>
$header_array) {
/* pass 1: see if we are allowed to view any children */
$show_header_items = false;
foreach ($header_array as $item_url => $item_title) {
$current_realm_id = (isset($user_auth_realm_filenames{basename($item_url)}) ? $user_auth_realm_filenames{basename($item_url)} : 0);
if (is_realm_allowed($current_realm_id)) {
$show_header_items = true;
}
}
if ($show_header_items == true) {
print "
\n";
/* pass 2: loop through each top level item and render it */
foreach ($header_array as $item_url => $item_title) {
$current_realm_id = (isset($user_auth_realm_filenames{basename($item_url)}) ? $user_auth_realm_filenames{basename($item_url)} : 0);
/* if this item is an array, then it contains sub-items. if not, is just
the title string and needs to be displayed */
if (is_array($item_title)) {
$i = 0;
if ($current_realm_id == -1 || is_realm_allowed($current_realm_id) || !isset($user_auth_realm_filenames{basename($item_url)})) {
/* if the current page exists in the sub-items array, draw each sub-item */
if (array_key_exists(basename($_SERVER["PHP_SELF"]), $item_title) == true) {
$draw_sub_items = true;
}else{
$draw_sub_items = false;
}
while (list($item_sub_url, $item_sub_title) = each($item_title)) {
$item_sub_url = $config['url_path'] . $item_sub_url;
/* always draw the first item (parent), only draw the children if we are viewing a page
that is contained in the sub-items array */
if (($i == 0) || ($draw_sub_items)) {
if (basename($_SERVER["PHP_SELF"]) == basename($item_sub_url)) {
print "