function data_query_edit() { $_data_query_id = get_get_var_number("id"); if (empty($_data_query_id)) { $header_label = "[new]"; } else { $data_query = api_data_query_get($_data_query_id); $header_label = "[edit: " . $data_query["name"] . "]"; } form_start("data_queries.php", "form_data_query"); html_start_box("<strong>" . _("Data Queries") . "</strong> {$header_label}"); _data_query_field__name("name", isset($data_query["name"]) ? $data_query["name"] : "", isset($data_query["id"]) ? $data_query["id"] : "0"); _data_query_field__input_type("input_type", isset($data_query["input_type"]) ? $data_query["input_type"] : "", isset($data_query["id"]) ? $data_query["id"] : "0"); _data_query_field__index_order_type("index_order_type", isset($data_query["index_order_type"]) ? $data_query["index_order_type"] : "", isset($data_query["id"]) ? $data_query["id"] : "0"); _data_query_field__index_title_format("index_title_format", isset($data_query["index_title_format"]) ? $data_query["index_title_format"] : "|chosen_order_field|", isset($data_query["id"]) ? $data_query["id"] : "0"); if (!empty($_data_query_id)) { _data_query_field__field_specific_hdr(); _data_query_field__index_order("index_order", isset($data_query["index_order"]) ? $data_query["index_order"] : "", isset($data_query["id"]) ? $data_query["id"] : "0"); _data_query_field__index_field_id("index_field_id", $_data_query_id, isset($data_query["index_field_id"]) ? $data_query["index_field_id"] : "", isset($data_query["id"]) ? $data_query["id"] : "0"); } /* input type specific fields */ _data_query_field__snmp_specific_hdr(); _data_query_field__snmp_oid_num_rows("snmp_oid_num_rows", isset($data_query["snmp_oid_num_rows"]) ? $data_query["snmp_oid_num_rows"] : "", isset($data_query["id"]) ? $data_query["id"] : "0"); _data_query_field__script_specific_hdr(); _data_query_field__script_path("script_path", isset($data_query["script_path"]) ? $data_query["script_path"] : "", isset($data_query["id"]) ? $data_query["id"] : "0"); _data_query_field__script_server_specific_hdr(); _data_query_field__script_server_function("script_server_function", isset($data_query["script_server_function"]) ? $data_query["script_server_function"] : "", isset($data_query["id"]) ? $data_query["id"] : "0"); /* be sure that we have the correct input type value show we display the correct form rows */ if (isset_post_cache_field("input_type")) { $_input_type = get_post_cache_field("input_type"); } else { $_input_type = isset($data_query["input_type"]) ? $data_query["input_type"] : ""; } echo "<script language=\"JavaScript\">\n<!--\nupdate_data_query_type_fields('{$_input_type}');\n-->\n</script>\n"; html_end_box(); if (!empty($_data_query_id)) { html_start_box("<strong>" . _("Data Query Fields") . "</strong>"); ?> <tr class="heading"> <td colspan="2"> Input Fields </td> <td align="right"> <a href="data_queries.php?action=field_edit&field_type=<?php echo DATA_QUERY_FIELD_TYPE_INPUT; ?> &data_query_id=<?php echo $_data_query_id; ?> ">Add</a> </td> </tr> <?php $input_fields = api_data_query_field_list($_data_query_id, DATA_QUERY_FIELD_TYPE_INPUT); if (sizeof($input_fields) > 0) { foreach ($input_fields as $field) { ?> <tr class="item" id="row_<?php echo $field["id"]; ?> " onClick="display_row_select('row_<?php echo $field["id"]; ?> ', 'chk_<?php echo $field["id"]; ?> ')" onMouseOver="display_row_hover('row_<?php echo $field["id"]; ?> ')" onMouseOut="display_row_clear('row_<?php echo $field["id"]; ?> ')"> <td class="title"> <a class="linkEditMain" onClick="display_row_block('row_<?php echo $field["id"]; ?> ')" href="data_queries.php?action=field_edit&id=<?php echo $field["id"]; ?> &data_query_id=<?php echo $field["data_query_id"]; ?> "><?php echo $field["name"]; ?> </a> </td> <td> <?php echo $field["name_desc"]; ?> </td> <td align="right"> <input type='checkbox' id='chk_<?php echo $field["id"]; ?> ' name='chk_<?php echo $field["id"]; ?> ' title="<?php echo $field["name"]; ?> "> </td> </tr> <?php } } else { ?> <tr> <td class="empty" colspan="2"> No input fields found. Remember that <strong>at least one index field</strong> must be defined! </td> </tr> <?php } ?> <tr class="heading"> <td colspan="2"> Output Fields </td> <td align="right"> <a href="data_queries.php?action=field_edit&field_type=<?php echo DATA_QUERY_FIELD_TYPE_OUTPUT; ?> &data_query_id=<?php echo $_data_query_id; ?> ">Add</a> </td> </tr> <?php $output_fields = api_data_query_field_list($_data_query_id, DATA_QUERY_FIELD_TYPE_OUTPUT); if (sizeof($output_fields) > 0) { foreach ($output_fields as $field) { ?> <tr class="item" id="row_<?php echo $field["id"]; ?> " onClick="display_row_select('row_<?php echo $field["id"]; ?> ', 'chk_<?php echo $field["id"]; ?> ')" onMouseOver="display_row_hover('row_<?php echo $field["id"]; ?> ')" onMouseOut="display_row_clear('row_<?php echo $field["id"]; ?> ')"> <td class="item"> <a class="linkEditMain" onClick="display_row_block('row_<?php echo $field["id"]; ?> ')" href="data_queries.php?action=field_edit&id=<?php echo $field["id"]; ?> &data_query_id=<?php echo $field["data_query_id"]; ?> "><?php echo $field["name"]; ?> </a> </td> <td> <?php echo $field["name_desc"]; ?> </td> <td align="right"> <input type='checkbox' id='chk_<?php echo $field["id"]; ?> ' name='chk_<?php echo $field["id"]; ?> ' title="<?php echo $field["name"]; ?> "> </td> </tr> <?php } } else { ?> <tr class="empty"> <td colspan="2"> No output fields found. </td> </tr> <?php } html_end_box(); } form_hidden_box("data_query_id", $_data_query_id); form_save_button("data_queries.php", "save_data_query"); }
function form_text_area($field_name, $form_previous_value, $form_rows, $form_columns, $form_default_value) { if ($form_previous_value == "") { $form_previous_value = $form_default_value; } /* always use the cached value if it's available */ if (isset_post_cache_field($field_name)) { $form_previous_value = get_post_cache_field($field_name); } print "<textarea cols='$form_columns' id='$field_name' rows='$form_rows' name='$field_name'>" . htmlspecialchars($form_previous_value, ENT_QUOTES) . "</textarea>\n"; }