function template() { $menu_items = array("remove" => "Remove", "duplicate" => "Duplicate"); $filter_array = array(); /* search field: filter (searches template name) */ if (isset_get_var("search_filter")) { $filter_array["template_name"] = get_get_var("search_filter"); } /* get a list of all data templates on this page */ $data_templates = api_data_template_list($filter_array); /* get a list of data input types for display in the data sources list */ $data_input_types = api_data_source_input_type_list(); form_start("data_templates.php"); $box_id = "1"; html_start_box("<strong>" . _("Data Templates") . "</strong>", "data_templates.php?action=edit"); html_header_checkbox(array(_("Template Name"), _("Data Input Type"), _("Status")), $box_id); $i = 0; if (sizeof($data_templates) > 0) { foreach ($data_templates as $data_template) { ?> <tr class="item" id="box-<?php echo $box_id; ?> -row-<?php echo $data_template["id"]; ?> " onClick="display_row_select('<?php echo $box_id; ?> ',document.forms[0],'box-<?php echo $box_id; ?> -row-<?php echo $data_template["id"]; ?> ', 'box-<?php echo $box_id; ?> -chk-<?php echo $data_template["id"]; ?> ')" onMouseOver="display_row_hover('box-<?php echo $box_id; ?> -row-<?php echo $data_template["id"]; ?> ')" onMouseOut="display_row_clear('box-<?php echo $box_id; ?> -row-<?php echo $data_template["id"]; ?> ')"> <td class="title"> <a onClick="display_row_block('box-<?php echo $box_id; ?> -row-<?php echo $data_template["id"]; ?> ')" href="data_templates.php?action=edit&id=<?php echo $data_template["id"]; ?> "><span id="box-<?php echo $box_id; ?> -text-<?php echo $data_template["id"]; ?> "><?php echo html_highlight_words(get_get_var("search_filter"), $data_template["template_name"]); ?> </span></a> </td> <td> <?php echo $data_input_types[$data_template["data_input_type"]]; ?> </td> <td> <?php if ($data_template["active"] == "1") { echo _("Active"); } else { echo _("Disabled"); } ?> </td> <td class="checkbox" align="center"> <input type='checkbox' name='box-<?php echo $box_id; ?> -chk-<?php echo $data_template["id"]; ?> ' id='box-<?php echo $box_id; ?> -chk-<?php echo $data_template["id"]; ?> ' title="<?php echo $data_template["template_name"]; ?> "> </td> </tr> <?php } } else { ?> <tr class="empty"> <td colspan="6"> No data templates found. </td> </tr> <?php } html_box_toolbar_draw($box_id, "0", "3", HTML_BOX_SEARCH_NO_ICON); html_end_box(false); html_box_actions_menu_draw($box_id, "0", $menu_items); html_box_actions_area_create($box_id); form_hidden_box("action_post", "data_template_list"); form_end(); ?> <script language="JavaScript"> <!-- function action_area_handle_type(box_id, type, parent_div, parent_form) { if (type == 'remove') { parent_div.appendChild(document.createTextNode('Are you sure you want to remove these data templates?')); parent_div.appendChild(action_area_generate_selected_rows(box_id)); action_area_update_header_caption(box_id, 'Remove Data Template'); action_area_update_submit_caption(box_id, 'Remove'); action_area_update_selected_rows(box_id, parent_form); }else if (type == 'duplicate') { parent_div.appendChild(document.createTextNode('Are you sure you want to duplicate these data templates?')); parent_div.appendChild(action_area_generate_selected_rows(box_id)); parent_div.appendChild(action_area_generate_input('text', 'box-' + box_id + '-action-area-txt1', '')); action_area_update_header_caption(box_id, 'Duplicate Data Templates'); action_area_update_submit_caption(box_id, 'Duplicate'); action_area_update_selected_rows(box_id, parent_form); } } --> </script> <?php }
function ds() { $current_page = get_get_var_number("page", "1"); $menu_items = array("remove" => "Remove", "duplicate" => "Duplicate", "enable" => "Enable", "disable" => "Disable", "change_data_template" => "Change Data Template", "change_host" => "Change Host", "convert_data_template" => "Convert to Data Template"); $filter_array = array(); /* search field: device template */ if (isset_get_var("search_device")) { $filter_array["host_id"] = get_get_var("search_device"); } /* search field: filter (searches data source name) */ if (isset_get_var("search_filter")) { $filter_array["filter"] = array("name_cache|name" => get_get_var("search_filter")); } /* get a list of all data sources on this page */ $data_sources = api_data_source_list($filter_array, $current_page, read_config_option("num_rows_data_source")); /* get the total number of data sources on all pages */ $total_rows = api_data_source_total_get($filter_array); /* get a list of data input types for display in the data sources list */ $data_input_types = api_data_source_input_type_list(); /* generate page list */ $url_string = build_get_url_string(array("search_device", "search_filter")); $url_page_select = get_page_list($current_page, MAX_DISPLAY_PAGES, read_config_option("num_rows_data_source"), $total_rows, "data_sources.php" . $url_string . ($url_string == "" ? "?" : "&") . "page=|PAGE_NUM|"); form_start("data_sources.php"); $box_id = "1"; html_start_box("<strong>" . _("Data Sources") . "</strong>", "data_sources.php?action=edit", $url_page_select); html_header_checkbox(array(_("Name"), _("Data Input Type"), _("Active"), _("Template Name")), $box_id); $i = 0; if (sizeof($data_sources) > 0) { foreach ($data_sources as $data_source) { ?> <tr class="item" id="box-<?php echo $box_id; ?> -row-<?php echo $data_source["id"]; ?> " onClick="display_row_select('<?php echo $box_id; ?> ',document.forms[0],'box-<?php echo $box_id; ?> -row-<?php echo $data_source["id"]; ?> ', 'box-<?php echo $box_id; ?> -chk-<?php echo $data_source["id"]; ?> ')" onMouseOver="display_row_hover('box-<?php echo $box_id; ?> -row-<?php echo $data_source["id"]; ?> ')" onMouseOut="display_row_clear('box-<?php echo $box_id; ?> -row-<?php echo $data_source["id"]; ?> ')"> <td class="title"> <a onClick="display_row_block('box-<?php echo $box_id; ?> -row-<?php echo $data_source["id"]; ?> ')" href="data_sources.php?action=edit&id=<?php echo $data_source["id"]; ?> "><span id="box-<?php echo $box_id; ?> -text-<?php echo $data_source["id"]; ?> "><?php echo html_highlight_words(get_get_var("search_filter"), $data_source["name_cache"]); ?> </span></a> </td> <td> <?php echo $data_input_types[$data_source["data_input_type"]]; ?> </td> <td> <?php echo empty($data_source["active"]) ? "<span style='color: red;'>" . _("No") . "</span>" : _("Yes"); ?> </td> <td> <?php echo empty($data_source["data_template_name"]) ? "<em>" . _("None") . "</em>" : $data_source["data_template_name"]; ?> </td> <td class="checkbox" align="center"> <input type='checkbox' name='box-<?php echo $box_id; ?> -chk-<?php echo $data_source["id"]; ?> ' id='box-<?php echo $box_id; ?> -chk-<?php echo $data_source["id"]; ?> ' title="<?php echo $data_source["name_cache"]; ?> "> </td> </tr> <?php } } else { ?> <tr class="empty"> <td colspan="6"> No data sources found. </td> </tr> <?php } html_box_toolbar_draw($box_id, "0", "4", sizeof($filter_array) == 0 ? HTML_BOX_SEARCH_INACTIVE : HTML_BOX_SEARCH_ACTIVE, $url_page_select); html_end_box(false); html_box_actions_menu_draw($box_id, "0", $menu_items); html_box_actions_area_create($box_id); form_hidden_box("action_post", "data_source_list"); form_end(); /* pre-cache the device list since we need it in more than one place below */ $device_list = array_rekey(api_device_list(), "id", "description"); /* fill in the list of available devices for the search dropdown */ $search_devices = array(); $search_devices["-1"] = "Any"; $search_devices["0"] = "None"; $search_devices += $device_list; /* fill in the list of available devices for the change host dropdown */ $change_host_list = array(); $change_host_list["0"] = "None"; $change_host_list += $device_list; ?> <script language="JavaScript"> <!-- function action_area_handle_type(box_id, type, parent_div, parent_form) { if (type == 'remove') { parent_div.appendChild(document.createTextNode('Are you sure you want to remove these data sources?')); parent_div.appendChild(action_area_generate_selected_rows(box_id)); action_area_update_header_caption(box_id, 'Remove Data Source'); action_area_update_submit_caption(box_id, 'Remove'); action_area_update_selected_rows(box_id, parent_form); }else if (type == 'duplicate') { parent_div.appendChild(document.createTextNode('Are you sure you want to duplicate these data sources?')); parent_div.appendChild(action_area_generate_selected_rows(box_id)); parent_div.appendChild(action_area_generate_input('text', 'box-' + box_id + '-action-area-txt1', '')); action_area_update_header_caption(box_id, 'Duplicate Data Source'); action_area_update_submit_caption(box_id, 'Duplicate'); action_area_update_selected_rows(box_id, parent_form); }else if (type == 'search') { _elm_dt_input = action_area_generate_select('box-' + box_id + '-search_device'); <?php echo get_js_dropdown_code('_elm_dt_input', $search_devices, isset_get_var("search_device") ? get_get_var("search_device") : "-1"); ?> _elm_ht_input = action_area_generate_input('text', 'box-' + box_id + '-search_filter', '<?php echo get_get_var("search_filter"); ?> '); _elm_ht_input.size = '30'; parent_div.appendChild(action_area_generate_search_field(_elm_dt_input, 'Device', true, false)); parent_div.appendChild(action_area_generate_search_field(_elm_ht_input, 'Filter', false, true)); action_area_update_header_caption(box_id, 'Search'); action_area_update_submit_caption(box_id, 'Search'); }else if (type == 'enable') { parent_div.appendChild(document.createTextNode('Are you sure you want to enable these data sources?')); parent_div.appendChild(action_area_generate_selected_rows(box_id)); action_area_update_header_caption(box_id, 'Enable Data Source'); action_area_update_submit_caption(box_id, 'Enable'); action_area_update_selected_rows(box_id, parent_form); }else if (type == 'disable') { parent_div.appendChild(document.createTextNode('Are you sure you want to disable these data sources? If disabled, these data sources will no longer be polled.')); parent_div.appendChild(action_area_generate_selected_rows(box_id)); action_area_update_header_caption(box_id, 'Disable Data Source'); action_area_update_submit_caption(box_id, 'Disable'); action_area_update_selected_rows(box_id, parent_form); }else if (type == 'change_host') { parent_div.appendChild(document.createTextNode('Are you sure you want to change the host for these data sources?')); parent_div.appendChild(action_area_generate_selected_rows(box_id)); _elm_dt_input = action_area_generate_select('box-' + box_id + '-change_device'); <?php echo get_js_dropdown_code('_elm_dt_input', $change_host_list, "0"); ?> parent_div.appendChild(action_area_generate_search_field(_elm_dt_input, 'New Device', true, true)); action_area_update_header_caption(box_id, 'Change Host'); action_area_update_submit_caption(box_id, 'Change'); action_area_update_selected_rows(box_id, parent_form); } } --> </script> <?php }