2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
< ? php
2008-08-22 20:07:32 +02:00
2023-06-08 13:19:01 +02:00
// Pandora FMS - https://pandorafms.com
2009-06-08 20:26:14 +02:00
// ==================================================
2023-06-08 11:53:13 +02:00
// Copyright (c) 2005-2023 Pandora FMS
2023-06-08 13:19:01 +02:00
// Please see https://pandorafms.com/community/ for full contribution list
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
// This program is free software; you can redistribute it and/or
2009-06-08 20:26:14 +02:00
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
2009-06-08 20:26:14 +02:00
2009-08-14 Miguel de Dios <miguel.dedios@artica.es>
* godmode/agentes/agent_manager.php, godmode/agentes/massive_config.php,
godmode/alerts/alert_list.php, godmode/reporting/graph_builder.php,
godmode/reporting/map_builder.php, include/functions_db.php,
include/functions_html.php, operation/agentes/exportdata.php,
operation/agentes/ver_agente.php: very changes for add input text
autocomplete with ajax jquery for agent input in several forms. Add to form
this exportdata, graph_builder, map_builder.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1849 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-08-14 18:38:57 +02:00
/**
2019-01-30 16:18:44 +01:00
* @ package Include
2009-08-24 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_menu.php, include/functions_html.php,
include/functions_events.php, include/functions_messages.php,
include/functions_modules.php, include/functions_exportserver.php,
include/functions_reporting.php, include/functions_filemanager.php,
include/pchart_graph.php, include/pandora_graph.php, include/auth/ldap.php,
include/auth/mysql.php, include/config.inc.php,
include/functions_networkmap.php, include/functions_servers.php,
include/functions_network_profiles.php, include/gettext.php,
include/functions_network_components.php, include/functions_visual_map.php,
include/fgraph2.php, include/Image/image_functions.php,
include/functions_config.php, include/config_process.php,
include/functions_ui.php, include/htmlawed.php,
include/functions_custom_graphs.php, include/fgraph.php,
include/functions_incidents.php, include/functions.php,
include/functions_agents.php, include/functions_db.php,
include/functions_themes.php, include/streams.php,
include/functions_fsgraph.php, include/functions_alerts.php,
include/functions_reports.php, include/functions_extensions.php,
include/functions_ui_renders.php: change or add the subpackage in phpdoc
comment blocks for to organize more the result phpdoc files. Start to
document undocument functions.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1882 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-08-26 17:37:47 +02:00
* @ subpackage HTML
2009-08-24 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_menu.php, include/functions_html.php,
include/functions_events.php, include/functions_messages.php,
include/functions_modules.php, include/functions_exportserver.php,
include/functions_reporting.php, include/functions_filemanager.php,
include/pchart_graph.php, include/pandora_graph.php, include/auth/dev.php,
include/auth/ldap.php, include/auth/mysql.php, include/config.inc.php,
include/functions_networkmap.php, include/functions_servers.php,
include/FusionCharts/FusionCharts_Gen.php,
include/FusionCharts/FusionCharts.php,
include/functions_network_profiles.php, include/gettext.php,
include/functions_network_components.php, include/functions_visual_map.php,
include/fgraph2.php, include/Image/image_functions.php,
include/functions_config.php, include/help/en/help_plugin_parameters.php,
include/help/en/help_snmpcommunity.php, include/help/en/help_wmiquery.php,
include/help/en/help_postprocess.php,
include/help/en/help_prediction_source_module.php,
include/help/en/help_date_format.php, include/help/en/help_recontask.php,
include/help/en/help_alert-matches.php, include/help/en/help_tcp_send.php,
include/help/en/help_wmifield.php, include/help/en/help_duplicateconfig.php,
include/help/en/help_agent_status.php,
include/help/en/help_manage_alerts.php, include/help/en/help_wmikey.php,
include/help/en/help_alert_type.php,
include/help/en/help_network_component.php,
include/help/en/help_time_stamp-comparation.php,
include/help/en/help_eventview.php, include/help/en/help_timesource.php,
include/help/en/help_alert_validation.php,
include/help/en/help_map_builder.php,
include/help/en/help_alert_recovery.php,
include/help/en/help_module_type.php,
include/help/en/help_planned_downtime.php,
include/help/en/help_serverlag.php, include/help/en/help_alerts.php,
include/help/en/help_snmpwalk.php,
include/help/en/help_module_definition.php,
include/help/en/help_plugin_definition.php,
include/help/en/help_wminamespace.php, include/help/en/help_snmpoid.php
include/help/en/help_manageconfig.php,
include/help/es/help_alert_validation.php,
include/help/es/help_plugin_parameters.php,
include/help/es/help_snmpcommunity.php, include/help/es/help_wmiquery.php,
include/help/es/help_map_builder.php, include/help/es/help_postprocess.php,
include/help/es/help_date_format.php,
include/help/es/help_alert_recovery.php,
include/help/es/help_prediction_source_module.php,
include/help/es/help_module_type.php,
include/help/es/help_planned_downtime.php,
include/help/es/help_alert-matches.php, include/help/es/help_recontask.php,
include/help/es/help_alerts.php, include/help/es/help_serverlag.php,
include/help/es/help_snmpwalk.php,
include/help/es/help_module_definition.php,
include/help/es/help_tcp_send.php, include/help/es/help_duplicateconfig.php,
include/help/es/help_wmifield.php, include/help/es/help_manage_alerts.php,
include/help/es/help_wmikey.php, include/help/es/help_plugin_definition.php,
include/help/es/help_alert_type.php, include/help/es/help_snmpoid.php,
include/help/es/help_wminamespace.php,
include/help/es/help_network_component.php,
include/help/es/help_time_stamp-comparation.php,
include/help/es/help_manageconfig.php, include/help/es/help_timesource.php,
include/config_process.php, include/functions_ui.php, include/htmlawed.php,
include/functions_custom_graphs.php, include/fgraph.php,
include/functions_incidents.php, include/functions.php,
include/functions_agents.php, include/functions_db.php,
include/functions_themes.php, include/streams.php,
include/functions_fsgraph.php, include/functions_alerts.php,
include/functions_reports.php, include/functions_extensions.php,
include/functions_ui_renders.php: change comments blocks for delete the
warnings to construct phpDoc Files, give a struct and order in the
phpDoc files.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1881 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-08-25 19:39:28 +02:00
*/
2011-04-20 16:22:40 +02:00
if ( ! isset ( $config )) {
2019-01-30 16:18:44 +01:00
$working_dir = getcwd ();
$working_dir = str_replace ( '\\' , '/' , $working_dir );
2019-02-26 12:04:18 +01:00
// Windows compatibility.
2019-01-30 16:18:44 +01:00
$levels = substr_count ( $working_dir , '/' );
for ( $i = 0 ; $i < $levels ; $i ++ ) {
if ( file_exists ( str_repeat ( '../' , $i ) . 'config.php' )) {
include_once str_repeat ( '../' , $i ) . 'config.php' ;
break ;
2019-02-26 12:04:18 +01:00
// Skip config.php loading after load the first one.
2019-01-30 16:18:44 +01:00
} else if ( file_exists ( str_repeat ( '../' , $i ) . 'include/config.php' )) {
// For path from the enterprise structure dirs.
include_once str_repeat ( '../' , $i ) . 'include/config.php' ;
break ;
2019-02-26 12:04:18 +01:00
// Skip config.php loading after load the first one.
2019-01-30 16:18:44 +01:00
}
}
} else {
include_once $config [ 'homedir' ] . '/include/functions.php' ;
include_once $config [ 'homedir' ] . '/include/functions_users.php' ;
include_once $config [ 'homedir' ] . '/include/functions_groups.php' ;
include_once $config [ 'homedir' ] . '/include/functions_ui.php' ;
2017-03-22 15:26:54 +01:00
}
2012-02-24 Miguel de Dios <miguel.dedios@artica.es>
* pandora_console/include/functions_ui.php: changed the source code into the
function "ui_get_full_url" for accept false for to return url with the home
url or with any string (as query) return url with the php file.
* pandora_console/include/functions_graph.php,
pandora_console/include/functions_html.php,
pandora_console/include/functions_events.php,
pandora_console/include/functions_reporting.php,
pandora_console/include/functions_api.php,
pandora_console/include/functions.php, pandora_console/index.php,
pandora_console/extensions/system_info.php,
pandora_console/operation/agentes/stat_win.php,
pandora_console/operation/menu.php,
pandora_console/operation/events/events_rss.php,
pandora_console/operation/events/events_marquee.php,
pandora_console/operation/events/events.php: change in more part of source
code to use "ui_get_full_url" instead the hard write method of $_SERVER
vars, now Pandora Console run fine (in all actions I hope) with web servers
in other ports instead the typical 80.
Merged from branch pandora_4.0
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5646 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-02-24 14:48:46 +01:00
* include/functions_graph.php
include/functions_html.php
include/functions_messages.php
include/db/postgresql.php
include/db/mysql.php
include/db/oracle.php
include/functions_reporting.php
include/functions_filemanager.php
include/functions_gis.php
include/auth/ldap.php
include/auth/mysql.php
include/functions_networkmap.php
include/functions_network_components.php
include/ajax/skins.ajax.php
include/ajax/reporting.ajax.php
include/ajax/visual_console_builder.ajax.php
include/ajax/alert_list.ajax.php
include/ajax/module.php
include/functions_config.php
include/functions_api.php
include/help/en/help_timesource.php
include/help/es/help_timesource.php
include/help/ja/help_timesource.php
include/config_process.php
include/functions_ui.php
include/functions_custom_graphs.php
include/fgraph.php
include/functions_incidents.php
include/api.php
include/functions_reports.php
include/functions_ui_renders.php
extensions/insert_data.php
extensions/system_info.php
extensions/extension_uploader.php
extensions/pandora_logs.php
extensions/agents_modules.php
extensions/update_manager.php
extensions/ssh_console.php
extensions/dbmanager.php
extensions/vnc_view.php
extensions/resource_registration.php
extensions/resource_exportation.php
extensions/users_connected.php
extensions/module_groups.php
extensions/update_manager/load_updatemanager.php
extensions/update_manager/lib/libupdate_manager_client.php
extensions/update_manager/lib/libupdate_manager.php
extensions/update_manager/lib/libupdate_manager_components.php
extensions/update_manager/lib/libupdate_manager_updates.php
extensions/update_manager/settings.php
extensions/update_manager/main.php
extensions/plugin_registration.php
operation/incidents/incident.php
operation/incidents/incident_detail.php
operation/incidents/incident_statistics.php
operation/search_modules.php
operation/visual_console/render_view.php
operation/visual_console/index.php
operation/extensions.php
operation/agentes/status_monitor.php
operation/agentes/export_csv.php
operation/agentes/estado_ultimopaquete.php
operation/agentes/datos_agente.php
operation/agentes/alerts_status.php
operation/agentes/estado_generalagente.php
operation/agentes/custom_fields.php
operation/agentes/estado_agente.php
operation/agentes/networkmap.topology.php
operation/agentes/networkmap.groups.php
operation/agentes/sla_view.php
operation/agentes/exportdata.php
operation/agentes/gis_view.php
operation/agentes/estado_monitores.php
operation/agentes/ver_agente.php
operation/agentes/graphs.php
operation/agentes/agent_fields.php
operation/agentes/tactical.php
operation/agentes/group_view.php
operation/agentes/networkmap.php
operation/agentes/stat_win.php
operation/servers/view_server.php
operation/servers/view_server_detail.php
operation/menu.php
operation/search_agents.php
operation/search_graphs.php
operation/snmpconsole/snmp_view.php
operation/users/user_edit.php
operation/gis_maps/render_view.php
operation/gis_maps/ajax.php
operation/integria_incidents/incident.php
operation/integria_incidents/incident_detail.php
operation/integria_incidents/incident_statistics.php
operation/events/event_statistics.php
operation/events/events_rss.php
operation/events/export_csv.php
operation/events/sound_events.php
operation/events/events_validate.php
operation/events/events_list.php
operation/events/events_marquee.php
operation/events/events.php
operation/search_alerts.php
operation/messages/message.php
operation/reporting/reporting_xml.php
operation/reporting/reporting_viewer.php
operation/reporting/graph_viewer.php
operation/search_reports.php
operation/search_maps.php
operation/search_users.php
extras/pandora_diag.php
mobile/operation/agents/monitor_status.php
mobile/operation/agents/view_agents.php
mobile/operation/agents/view_alerts.php
mobile/operation/agents/group_view.php
mobile/operation/events/events.php
mobile/index.php
general/error_authconfig.php
general/links_menu.php
general/logon_ok.php
general/error_dbconfig.php
general/ui/agents_list.php
general/header.php
godmode/groups/modu_group_list.php
godmode/groups/configure_group.php
godmode/groups/configure_modu_group.php
godmode/groups/group_list.php
godmode/admin_access_logs.php
godmode/db/db_main.php
godmode/db/db_audit.php
godmode/db/db_sanity.php
godmode/db/db_refine.php
godmode/db/db_info.php
godmode/db/db_event.php
godmode/db/db_purge.php
godmode/extensions.php
godmode/agentes/agent_template.php
godmode/agentes/module_manager_editor_common.php
godmode/agentes/fields_manager.php
godmode/agentes/agent_conf_gis.php
godmode/agentes/module_manager_editor_prediction.php
godmode/agentes/module_manager.php
godmode/agentes/modificar_agente.php
godmode/agentes/configurar_agente.php
godmode/agentes/configure_field.php
godmode/agentes/module_manager_editor.php
godmode/agentes/planned_downtime.php
godmode/agentes/manage_config_remote.php
godmode/agentes/agent_manager.php
godmode/servers/recon_script.php
godmode/servers/plugin.php
godmode/servers/manage_recontask.php
godmode/servers/modificar_server.php
godmode/servers/manage_recontask_form.php
godmode/alerts/alert_list.list.php
godmode/alerts/configure_alert_compound.php
godmode/alerts/alert_compounds.php
godmode/alerts/alert_list.php
godmode/alerts/configure_alert_template.php
godmode/alerts/alert_templates.php
godmode/alerts/configure_alert_action.php
godmode/alerts/configure_alert_command.php
godmode/alerts/alert_actions.php
godmode/alerts/alert_list.builder.php
godmode/alerts/alert_commands.php
godmode/setup/file_manager.php
godmode/setup/os.list.php
godmode/setup/news.php
godmode/setup/gis_step_2.php
godmode/setup/links.php
godmode/setup/setup.php
godmode/setup/os.php
godmode/setup/performance.php
godmode/setup/setup_auth.php
godmode/setup/gis.php
godmode/setup/os.builder.php
godmode/setup/setup_visuals.php
godmode/snmpconsole/snmp_alert.php
godmode/snmpconsole/snmp_filters.php
godmode/users/user_list.php
godmode/users/configure_profile.php
godmode/gis_maps/configure_gis_map.php
godmode/gis_maps/index.php
godmode/massive/massive_add_alerts.php
godmode/massive/massive_copy_modules.php
godmode/massive/massive_delete_agents.php
godmode/massive/massive_enable_disable_alerts.php
godmode/massive/massive_operations.php
godmode/massive/massive_delete_profiles.php
godmode/massive/massive_edit_agents.php
godmode/massive/massive_delete_action_alerts.php
godmode/massive/massive_delete_modules.php
godmode/massive/massive_add_profiles.php
godmode/massive/massive_delete_alerts.php
godmode/massive/massive_edit_modules.php
godmode/massive/massive_standby_alerts.php
godmode/massive/massive_add_action_alerts.php
godmode/modules/manage_network_components_form.php
godmode/modules/manage_nc_groups_form.php
godmode/modules/manage_network_templates.php
godmode/modules/module_list.php
godmode/modules/manage_network_components_form_common.php
godmode/modules/manage_network_components_form_network.php
godmode/modules/manage_network_templates_form.php
godmode/modules/manage_network_components_form_wmi.php
godmode/modules/manage_network_components.php
godmode/modules/manage_nc_groups.php
godmode/reporting/visual_console_builder.wizard.php
godmode/reporting/graph_builder.main.php
godmode/reporting/reporting_builder.list_items.php
godmode/reporting/visual_console_builder.php
godmode/reporting/reporting_builder.preview.php
godmode/reporting/reporting_builder.main.php
godmode/reporting/visual_console_builder.data.php
godmode/reporting/visual_console_builder.elements.php
godmode/reporting/graph_builder.php
godmode/reporting/visual_console_builder.preview.php
godmode/reporting/graph_builder.graph_editor.php
godmode/reporting/reporting_builder.php
godmode/reporting/visual_console_builder.editor.php
godmode/reporting/reporting_builder.item_editor.php
godmode/reporting/map_builder.php
godmode/reporting/graphs.php
godmode/reporting/graph_builder.preview.php
include/functions_db.php: Added some includes and functions of this code have "db_" prefix.
* include/functions.php: Moved function check_login(), check_acl(),
dame_nombre_pluginid(), get_os_name() from functions_db.php to functions.php.
* include/functions_groups.php: Moved functions get_childrens(), safe_acl_group()
and get_parents(), give_disabled_group(), isAllGroups(), get_group_icon(), get_all_groups(),
get_id_groups_recursive(), get_user_groups_tree_recursive(), get_group_status(),
get_group_name(), get_group_users() from functions_db.php to this code.
* include/functions_profile.php: New library with profile functions. Moved functions
get_profile_name(), get_profiles(), create_user_profile(), delete_user_profile(),
delete_profile() from functions_db.php to this code. Added new parameter in function
get_profile() to retrieve profiles with filter conditions applied.
* include/functions_users.php: New library with users functions. Moved functions
get_users_info(), get_all_model_groups(), get_user_groups(), get_user_groups_tree(),
get_user_first_group(), user_access_to_agent() from funtions_db.php to this code.
* godmode/users/configure_user.php: Changed get_profile_filter() function to get_profile().
* include/functions_agents.php: Moved functions get_group_agents(), get_agent_modules(),
get_agent_module_id(), get_agent_id(), get_agent_name(), get_agent_modules_data_count(),
check_alert_fired(), get_agent_interval(), get_agent_os(), give_agentmodule_flag(),
agent_add_address(), agent_delete_address(), get_agent_address(), get_agent_with_ip(),
get_agent_addresses(), get_agent_status(), delete_agent(), get_agentmodule_group(),
get_agent_group() from functions_db.php to this code.
* include/functions_modules.php: Moved functions get_agentmodule(), get_agentmodule_id(),
get_agentmodule_is_init(), get_agent_modules_count(), get_module_type_name(),
get_module_type_icon(), get_agentmodule_agent(), get_agentmodule_agent_name(),
get_agentmodule_name(), get_agentmodule_type(), get_monitor_downs_in_period(),
get_monitor_last_down_timestamp_in_period(), get_monitors_in_group(),
get_monitors_in_agent(), get_monitors_down(), get_moduletype_name(),
get_moduletype_description(), get_moduletypes(), get_module_interval(), show_icon_type(),
give_modulecategory_name(),
give_agent_id_from_module_id(), get_module_status(), get_agent_module_last_value(),
get_previous_data(), get_agentmodule_modulegroup(), get_modulegroups(),
get_modulegroup_name() from functions_db.php to this code.
* include/functions_alerts.php: Moved functions get_alert_type(), get_agent_alert_fired(),
get_module_alert_fired(), get_alert_fires_in_period(), get_group_alerts(), get_alerts_fired(),
get_alert_last_fire_timestamp_in_period(), get_agentmodule_status(),
get_agentmodule_last_status() from functions_db.php to this code.
* include/functions_exportserver.php: Moved function dame_nombre_servidorexportacion()
from functions_db.php to this code.
* include/functions_events.php: Moved functions get_group_events(), get_agent_events(),
get_module_events() from functions_db.php to this code.
* include/functions_servers.php: Moved functions get_server_name(), show_server_type(),
check_server_status(), server_status() from functions_db.php to this code.
* include/functions_network_profiles.php: Moved function get_networkprofile_name()
from functions_db.php to this code.
* include/functions_visual_map.php: Moved functions get_layoutdata_x(), get_layoutdata_y()
from fucntions_db.php to this code.
* include/functions_io.php: Moved function __() from functions_db.php to this code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4258 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-04-19 20:42:49 +02:00
2009-08-24 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_menu.php, include/functions_html.php,
include/functions_events.php, include/functions_messages.php,
include/functions_modules.php, include/functions_exportserver.php,
include/functions_reporting.php, include/functions_filemanager.php,
include/pchart_graph.php, include/pandora_graph.php, include/auth/dev.php,
include/auth/ldap.php, include/auth/mysql.php, include/config.inc.php,
include/functions_networkmap.php, include/functions_servers.php,
include/FusionCharts/FusionCharts_Gen.php,
include/FusionCharts/FusionCharts.php,
include/functions_network_profiles.php, include/gettext.php,
include/functions_network_components.php, include/functions_visual_map.php,
include/fgraph2.php, include/Image/image_functions.php,
include/functions_config.php, include/help/en/help_plugin_parameters.php,
include/help/en/help_snmpcommunity.php, include/help/en/help_wmiquery.php,
include/help/en/help_postprocess.php,
include/help/en/help_prediction_source_module.php,
include/help/en/help_date_format.php, include/help/en/help_recontask.php,
include/help/en/help_alert-matches.php, include/help/en/help_tcp_send.php,
include/help/en/help_wmifield.php, include/help/en/help_duplicateconfig.php,
include/help/en/help_agent_status.php,
include/help/en/help_manage_alerts.php, include/help/en/help_wmikey.php,
include/help/en/help_alert_type.php,
include/help/en/help_network_component.php,
include/help/en/help_time_stamp-comparation.php,
include/help/en/help_eventview.php, include/help/en/help_timesource.php,
include/help/en/help_alert_validation.php,
include/help/en/help_map_builder.php,
include/help/en/help_alert_recovery.php,
include/help/en/help_module_type.php,
include/help/en/help_planned_downtime.php,
include/help/en/help_serverlag.php, include/help/en/help_alerts.php,
include/help/en/help_snmpwalk.php,
include/help/en/help_module_definition.php,
include/help/en/help_plugin_definition.php,
include/help/en/help_wminamespace.php, include/help/en/help_snmpoid.php
include/help/en/help_manageconfig.php,
include/help/es/help_alert_validation.php,
include/help/es/help_plugin_parameters.php,
include/help/es/help_snmpcommunity.php, include/help/es/help_wmiquery.php,
include/help/es/help_map_builder.php, include/help/es/help_postprocess.php,
include/help/es/help_date_format.php,
include/help/es/help_alert_recovery.php,
include/help/es/help_prediction_source_module.php,
include/help/es/help_module_type.php,
include/help/es/help_planned_downtime.php,
include/help/es/help_alert-matches.php, include/help/es/help_recontask.php,
include/help/es/help_alerts.php, include/help/es/help_serverlag.php,
include/help/es/help_snmpwalk.php,
include/help/es/help_module_definition.php,
include/help/es/help_tcp_send.php, include/help/es/help_duplicateconfig.php,
include/help/es/help_wmifield.php, include/help/es/help_manage_alerts.php,
include/help/es/help_wmikey.php, include/help/es/help_plugin_definition.php,
include/help/es/help_alert_type.php, include/help/es/help_snmpoid.php,
include/help/es/help_wminamespace.php,
include/help/es/help_network_component.php,
include/help/es/help_time_stamp-comparation.php,
include/help/es/help_manageconfig.php, include/help/es/help_timesource.php,
include/config_process.php, include/functions_ui.php, include/htmlawed.php,
include/functions_custom_graphs.php, include/fgraph.php,
include/functions_incidents.php, include/functions.php,
include/functions_agents.php, include/functions_db.php,
include/functions_themes.php, include/streams.php,
include/functions_fsgraph.php, include/functions_alerts.php,
include/functions_reports.php, include/functions_extensions.php,
include/functions_ui_renders.php: change comments blocks for delete the
warnings to construct phpDoc Files, give a struct and order in the
phpDoc files.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1881 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-08-25 19:39:28 +02:00
/**
* Prints the print_r with < pre > tags
2009-08-14 Miguel de Dios <miguel.dedios@artica.es>
* godmode/agentes/agent_manager.php, godmode/agentes/massive_config.php,
godmode/alerts/alert_list.php, godmode/reporting/graph_builder.php,
godmode/reporting/map_builder.php, include/functions_db.php,
include/functions_html.php, operation/agentes/exportdata.php,
operation/agentes/ver_agente.php: very changes for add input text
autocomplete with ajax jquery for agent input in several forms. Add to form
this exportdata, graph_builder, map_builder.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1849 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-08-14 18:38:57 +02:00
*/
2019-01-30 16:18:44 +01:00
function html_debug_print ( $var , $file = '' , $oneline = false )
{
$more_info = '' ;
if ( is_string ( $var )) {
$more_info = 'size: ' . strlen ( $var );
} else if ( is_bool ( $var )) {
$more_info = 'val: ' . ( $var ? 'true' : 'false' );
} else if ( is_null ( $var )) {
$more_info = 'is null' ;
} else if ( is_array ( $var )) {
$more_info = count ( $var );
}
if ( $file === true ) {
$file = '/tmp/logDebug' ;
}
if ( $oneline && is_string ( $var )) {
$var = preg_replace ( " /[ \t | \n | ]+/ " , ' ' , $var );
}
if ( strlen ( $file ) > 0 ) {
$f = fopen ( $file , 'a' );
ob_start ();
echo date ( 'Y/m/d H:i:s' ) . ' (' . gettype ( $var ) . ') ' . $more_info . " \n " ;
print_r ( $var );
echo " \n \n " ;
$output = ob_get_clean ();
fprintf ( $f , '%s' , $output );
fclose ( $f );
} else {
2023-04-13 09:38:52 +02:00
echo '<pre class="bg_white pdd_1em zindex10000 relative-mobile">' . date ( 'Y/m/d H:i:s' ) . ' (' . gettype ( $var ) . ') ' . $more_info . " \n " ;
2019-01-30 16:18:44 +01:00
print_r ( $var );
echo '</pre>' ;
}
2009-08-14 Miguel de Dios <miguel.dedios@artica.es>
* godmode/agentes/agent_manager.php, godmode/agentes/massive_config.php,
godmode/alerts/alert_list.php, godmode/reporting/graph_builder.php,
godmode/reporting/map_builder.php, include/functions_db.php,
include/functions_html.php, operation/agentes/exportdata.php,
operation/agentes/ver_agente.php: very changes for add input text
autocomplete with ajax jquery for agent input in several forms. Add to form
this exportdata, graph_builder, map_builder.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1849 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-08-14 18:38:57 +02:00
}
2019-01-30 16:18:44 +01:00
2023-02-06 16:34:40 +01:00
/**
* Console log .
*/
function jslog ( $var )
{
$more_info = '' ;
if ( is_string ( $var )) {
$more_info = 'size: ' . strlen ( $var );
} else if ( is_bool ( $var )) {
$more_info = 'val: ' . ( $var ? 'true' : 'false' );
} else if ( is_null ( $var )) {
$more_info = 'is null' ;
} else if ( is_array ( $var )) {
$more_info = count ( $var );
}
echo '<script>console.log("' . date ( 'Y/m/d H:i:s' ) . ' (' . gettype ( $var ) . ') ' . $more_info . '");</script>' . " \n " ;
echo '<script>console.log(' . json_encode ( $var ) . ');</script>' ;
}
2015-03-09 20:20:37 +01:00
// Alias for "html_debug_print"
2019-01-30 16:18:44 +01:00
function html_debug ( $var , $file = '' , $oneline = false )
{
html_debug_print ( $var , $file , $oneline );
2018-09-20 16:00:08 +02:00
}
2019-01-30 16:18:44 +01:00
2018-09-20 16:00:08 +02:00
// Alias for "html_debug_print"
2019-01-30 16:18:44 +01:00
function hd ( $var , $file = '' , $oneline = false )
{
html_debug_print ( $var , $file , $oneline );
2015-03-09 20:20:37 +01:00
}
2019-01-30 16:18:44 +01:00
2022-01-12 14:22:16 +01:00
function dd ( $var )
{
hd ( $var );
die ();
}
2019-09-03 12:40:16 +02:00
/**
* Encapsulation ( ob ) for debug print function .
*
* @ param mixed $var Variable to be dumped .
* @ param string $file Target file path .
* @ param boolean $oneline Show in oneline .
*
* @ return string Dump string .
*/
function obhd ( $var , $file = '' , $oneline = false )
{
ob_start ();
hd ( $var , $file , $oneline );
return ob_get_clean ();
}
2019-01-30 16:18:44 +01:00
function debug ()
{
$args_num = func_num_args ();
$arg_list = func_get_args ();
for ( $i = 0 ; $i < $args_num ; $i ++ ) {
html_debug_print ( $arg_list [ $i ], true );
}
2018-12-10 09:20:06 +01:00
}
2019-01-30 16:18:44 +01:00
function html_f2str ( $function , $params )
{
ob_start ();
2022-01-13 12:43:55 +01:00
call_user_func_array (
$function ,
array_values (( $params ? ? []))
);
2019-01-30 16:18:44 +01:00
return ob_get_clean ();
2009-12-22 13:56:46 +01:00
}
2019-01-30 16:18:44 +01:00
2013-02-18 19:10:53 +01:00
/**
* Print side layer
2019-01-30 16:18:44 +01:00
*
2013-02-18 19:10:53 +01:00
* @ params mixed Hash with all the params :
2019-01-30 16:18:44 +01:00
*
* position : left or right
2013-02-18 19:10:53 +01:00
* width : width of the layer
2019-01-30 16:18:44 +01:00
* height : height of the layer
* icon_closed : icon showed when layer is hidden
* icon_open : icon showed when layer is showed
* top_text : text over the content
* body_text : content of layer
* bottom_text : text under the contet
2013-02-18 19:10:53 +01:00
*
* @ return string HTML code if return parameter is true .
*/
2019-01-30 16:18:44 +01:00
function html_print_side_layer ( $params )
{
global $config ;
// Check mandatory values, if any of them is missed, return ''
$mandatory = [
'icon_closed' ,
'body_text' ,
];
foreach ( $mandatory as $man ) {
if ( ! isset ( $params [ $man ])) {
return '' ;
}
}
// Set default values if not setted
$defaults = [
'position' => 'left' ,
'width' => '400' ,
'height' => '97%' ,
'top_text' => '' ,
'bottom_text' => '' ,
'top' => '0' ,
'autotop' => '' ,
'right' => '0' ,
'autoright' => '' ,
'vertical_mode' => 'out' ,
'icon_width' => 50 ,
'icon_height' => 50 ,
'icon_open' => $params [ 'icon_closed' ],
];
foreach ( $defaults as $token => $value ) {
if ( ! isset ( $params [ $token ])) {
$params [ $token ] = $value ;
}
}
// z-index is 1 because 2 made the calendar show under the side_layer
switch ( $params [ 'position' ]) {
case 'left' :
$round_class = 'menu_sidebar_radius_right' ;
$body_float = 'left' ;
$button_float = 'right' ;
break ;
case 'right' :
$round_class = 'menu_sidebar_radius_left' ;
$body_float = 'right' ;
$button_float = 'left' ;
break ;
case 'bottom' :
$round_class = 'menu_sidebar_radius_left menu_sidebar_radius_right' ;
$body_float = 'right' ;
$button_float = 'left' ;
break ;
}
2021-03-11 15:40:23 +01:00
$out_html = '<div id="side_layer" class="menu_sidebar invisible overflow_hidden' . $round_class . '" style=" z-index:1; height: ' . $params [ 'height' ] . '; width: ' . $params [ 'width' ] . ';">' ;
2019-01-30 16:18:44 +01:00
$table = new stdClass ();
$table -> id = 'side_layer_layout' ;
$table -> width = $params [ 'width' ] . 'px' ;
$table -> cellspacing = 2 ;
$table -> cellpadding = 2 ;
$table -> class = 'none' ;
2021-03-11 15:40:23 +01:00
$top = '<div id="side_top_text" class="w100p">' . $params [ 'top_text' ] . '</div>' ;
2019-01-30 16:18:44 +01:00
2021-03-11 15:40:23 +01:00
$button = '<div id="show_menu" class="vertical_middle relative right pdd_r_17px" style="width: ' . $params [ 'icon_width' ] . 'px; height: ' . $params [ 'icon_height' ] . 'px;">' ;
2019-01-30 16:18:44 +01:00
// Use the no_meta parameter because this image is only in the base console
$button .= html_print_image (
$params [ 'position' ] == 'left' ? $params [ 'icon_open' ] : $params [ 'icon_closed' ],
true ,
[ 'id' => 'graph_menu_arrow' ],
false ,
false ,
true
);
$button .= '</div>' ;
2021-03-11 15:40:23 +01:00
$body = '<div id="side_body_text" class="w100p">' . $params [ 'body_text' ] . '</div>' ;
2019-01-30 16:18:44 +01:00
$bottom = '<div id="side_bottom_text" style="text-align: ' . $params [ 'position' ] . ';">' . $params [ 'bottom_text' ] . '</div>' ;
switch ( $params [ 'position' ]) {
case 'left' :
$table -> size [ 1 ] = '15%' ;
$table -> data [ 0 ][ 0 ] = $top ;
$table -> data [ 0 ][ 1 ] = '' ;
$table -> rowclass [ 0 ] = '' ;
$table -> data [ 1 ][ 0 ] = $body ;
$table -> data [ 1 ][ 1 ] = $button ;
$table -> rowclass [ 1 ] = '' ;
$table -> data [ 2 ][ 0 ] = $bottom ;
$table -> data [ 2 ][ 1 ] = '' ;
$table -> rowclass [ 2 ] = '' ;
break ;
case 'right' :
$table -> size [ 0 ] = '15%' ;
$table -> data [ 0 ][ 0 ] = '' ;
$table -> data [ 0 ][ 1 ] = $top ;
$table -> rowclass [ 0 ] = '' ;
$table -> data [ 1 ][ 0 ] = $button ;
$table -> data [ 1 ][ 1 ] = $body ;
$table -> rowclass [ 1 ] = '' ;
$table -> data [ 2 ][ 0 ] = '' ;
$table -> data [ 2 ][ 1 ] = $bottom ;
$table -> rowclass [ 2 ] = '' ;
break ;
case 'bottom' :
$table -> data [ 0 ][ 0 ] = $button ;
$table -> cellstyle [ 0 ][ 0 ] = 'text-align: center;' ;
$table -> rowclass [ 0 ] = '' ;
$table -> data [ 1 ][ 0 ] = $top ;
$table -> rowclass [ 1 ] = '' ;
$table -> data [ 2 ][ 0 ] = $body ;
$table -> rowclass [ 2 ] = '' ;
$table -> data [ 3 ][ 0 ] = $bottom ;
$table -> rowclass [ 3 ] = '' ;
break ;
}
$out_html .= html_print_table ( $table , true );
$out_html .= '</div>' ;
$out_js = " <script type='text/javascript'>
2013-02-18 19:10:53 +01:00
<!--
2019-01-30 16:18:44 +01:00
hidded_sidebar ( '".$params[' position ']."' , " . $params['width'] . " , '".$params[' height ']."' , " . $params['icon_width'] . " ,
'".$params[' top ']."' , '".$params[' autotop ']."' , '".$params[' right ']."' ,
'".$params[' autoright ']."' , '".$params[' icon_closed ']."' , '".$params[' icon_open ']."' , '".$config[' homeurl ']."'
, '".$params[' vertical_mode ']."' );
2013-02-18 19:10:53 +01:00
//-->
</ script > " ;
2019-01-30 16:18:44 +01:00
echo $out_html . $out_js ;
2013-02-18 19:10:53 +01:00
}
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
2019-01-30 16:18:44 +01:00
2009-07-22 17:26:31 +02:00
/**
* Prints an array of fields in a popup menu of a form .
2019-01-30 16:18:44 +01:00
*
* Based on choose_from_menu () from Moodle
*
2009-07-22 17:26:31 +02:00
* @ param array Array with dropdown values . Example : $fields [ " value " ] = " label "
* @ param string Select form name
* @ param variant Current selected value . Can be a single value or an
* array of selected values ( in combination with multiple )
* @ param string Javascript onChange code .
* @ param string Label when nothing is selected .
* @ param variant Value when nothing is selected
* @ param bool Whether to return an output string or echo now ( optional , echo by default ) .
* @ param bool Set the input to allow multiple selections ( optional , single selection by default ) .
* @ param bool Whether to sort the options or not ( optional , unsorted by default ) .
*
* @ return string HTML code if return parameter is true .
*/
2019-01-30 16:18:44 +01:00
function html_print_select_style ( $fields , $name , $selected = '' , $style = '' , $script = '' , $nothing = '' , $nothing_value = 0 , $return = false , $multiple = false , $sort = true , $class = '' , $disabled = false )
{
$output = " \n " ;
static $idcounter = [];
// If duplicate names exist, it will start numbering. Otherwise it won't
if ( isset ( $idcounter [ $name ])) {
$idcounter [ $name ] ++ ;
} else {
$idcounter [ $name ] = 0 ;
}
$id = preg_replace ( '/[^a-z0-9\:\;\-\_]/i' , '' , $name . ( $idcounter [ $name ] ? $idcounter [ $name ] : '' ));
$attributes = '' ;
if ( ! empty ( $script )) {
$attributes .= ' onchange="' . $script . '"' ;
}
if ( ! empty ( $multiple )) {
$attributes .= ' multiple="multiple" size="10"' ;
}
if ( ! empty ( $class )) {
$attributes .= ' class="' . $class . '"' ;
}
if ( ! empty ( $disabled )) {
$attributes .= ' disabled="disabled"' ;
}
$output .= '<select style="' . $style . '" id="' . $id . '" name="' . $name . '"' . $attributes . '>' ;
if ( $nothing != '' || empty ( $fields )) {
if ( $nothing == '' ) {
$nothing = __ ( 'None' );
}
$output .= '<option value="' . $nothing_value . '"' ;
if ( $nothing_value == $selected ) {
$output .= ' selected="selected"' ;
}
$output .= '>' . $nothing . '</option>' ;
}
if ( ! empty ( $fields )) {
if ( $sort !== false ) {
asort ( $fields );
}
foreach ( $fields as $value => $label ) {
$output .= '<option value="' . $value . '"' ;
if ( is_array ( $selected ) && in_array ( $value , $selected )) {
$output .= ' selected="selected"' ;
} else if ( is_numeric ( $value ) && is_numeric ( $selected ) && $value == $selected ) {
// This fixes string ($value) to int ($selected) comparisons
$output .= ' selected="selected"' ;
} else if ( $value === $selected ) {
// Needs type comparison otherwise if $selected = 0 and $value = "string" this would evaluate to true
$output .= ' selected="selected"' ;
}
if ( $label === '' ) {
$output .= '>' . $value . '</option>' ;
} else {
$output .= '>' . $label . '</option>' ;
}
}
}
$output .= '</select>' ;
if ( $return ) {
return $output ;
}
echo $output ;
2009-07-22 17:26:31 +02:00
}
2019-01-30 16:18:44 +01:00
2010-07-15 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_html.php: added the function "print_select_groups" to
print the field select box for groups with tree style.
* include/functions_db.php: in function "get_user_groups" added test to
false value in parameter $privilege for get all groups without ACL test.
Fixed in function "get_user_groups_tree" the call to "get_user_groups" with
the correct parameters.
* operation/incidents/incident.php, operation/incidents/incident_detail.php,
operation/events/events.php, operation/agentes/status_monitor.php,
operation/agentes/estado_agente.php,
operation/agentes/alerts_status.functions.php,
operation/agentes/exportdata.php, operation/agentes/networkmap.php,
operation/messages/message.php, general/ui/agents_list.php,
godmode/groups/configure_group.php, godmode/groups/group_list.php,
godmode/agentes/massive_add_alerts.php,
godmode/agentes/massive_delete_agents.php,
godmode/agentes/massive_config.php,
godmode/agentes/massive_delete_action_alerts.php,
godmode/agentes/massive_delete_alerts.php,
godmode/agentes/modificar_agente.php,
godmode/agentes/massive_delete_modules.php,
godmode/agentes/massive_add_action_alerts.php,
godmode/agentes/planned_downtime.php,
godmode/agentes/manage_config_remote.php, godmode/agentes/agent_manager.php,
godmode/servers/manage_recontask_form.php,
godmode/alerts/configure_alert_compound.php,
godmode/alerts/alert_compounds.php,
godmode/alerts/configure_alert_template.php,
godmode/alerts/configure_alert_action.php, godmode/setup/gis_step_2.php,
godmode/users/configure_user.php, godmode/gis_maps/configure_gis_map.php,
godmode/reporting/graph_builder.main.php,
godmode/reporting/reporting_builder.main.php,
godmode/reporting/visual_console_builder.data.php: changed the fields select
box of group to tree style select box for groups.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3009 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2010-07-15 17:20:43 +02:00
/**
2020-09-11 14:34:41 +02:00
* Print or return selector for groups .
2019-01-30 16:18:44 +01:00
*
2020-09-11 14:34:41 +02:00
* @ param string $id_user User id .
* @ param string $privilege The privilege to evaluate .
* @ param boolean $returnAllGroup Flag the return group , ( true ) .
* @ param boolean $name Name of input field .
* @ param array $selected Array with dropdown values . Example :
* $fields [ " value " ] = " label " .
* @ param string $script Javascript onChange code .
* @ param mixed $nothing Label when nothing is selected .
* @ param array $nothing_value Value when nothing is selected .
* @ param string $return Return string or dump to output .
* @ param boolean $multiple Enable multiple select .
* @ param mixed $sort Sort values or not ( default false ) .
* @ param boolean $class CSS classes to apply .
* @ param boolean $disabled Disabled or enabled .
* @ param boolean $style CSS inline style .
* @ param string $option_style CSS inline style in array format .
2020-10-21 18:31:10 +02:00
* @ param integer $id_group Exclude group branch from id_group .
2020-09-11 14:34:41 +02:00
* @ param string $keys_field Field to be used as array key , ( id ) .
* @ param boolean $strict_user Strict .
* @ param array $delete_groups Remove groups from select .
* @ param array $include_groups Add groups to select .
* @ param string $size Style , size ( width ) of element .
* @ param boolean $simple_multiple_options Discovery simple multiple inputs .
2020-09-29 15:48:20 +02:00
* @ param boolean $required Required input .
2021-06-25 09:37:26 +02:00
* @ param string $inverse Change All to None with inverse condition .
2010-07-15 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_html.php: added the function "print_select_groups" to
print the field select box for groups with tree style.
* include/functions_db.php: in function "get_user_groups" added test to
false value in parameter $privilege for get all groups without ACL test.
Fixed in function "get_user_groups_tree" the call to "get_user_groups" with
the correct parameters.
* operation/incidents/incident.php, operation/incidents/incident_detail.php,
operation/events/events.php, operation/agentes/status_monitor.php,
operation/agentes/estado_agente.php,
operation/agentes/alerts_status.functions.php,
operation/agentes/exportdata.php, operation/agentes/networkmap.php,
operation/messages/message.php, general/ui/agents_list.php,
godmode/groups/configure_group.php, godmode/groups/group_list.php,
godmode/agentes/massive_add_alerts.php,
godmode/agentes/massive_delete_agents.php,
godmode/agentes/massive_config.php,
godmode/agentes/massive_delete_action_alerts.php,
godmode/agentes/massive_delete_alerts.php,
godmode/agentes/modificar_agente.php,
godmode/agentes/massive_delete_modules.php,
godmode/agentes/massive_add_action_alerts.php,
godmode/agentes/planned_downtime.php,
godmode/agentes/manage_config_remote.php, godmode/agentes/agent_manager.php,
godmode/servers/manage_recontask_form.php,
godmode/alerts/configure_alert_compound.php,
godmode/alerts/alert_compounds.php,
godmode/alerts/configure_alert_template.php,
godmode/alerts/configure_alert_action.php, godmode/setup/gis_step_2.php,
godmode/users/configure_user.php, godmode/gis_maps/configure_gis_map.php,
godmode/reporting/graph_builder.main.php,
godmode/reporting/reporting_builder.main.php,
godmode/reporting/visual_console_builder.data.php: changed the fields select
box of group to tree style select box for groups.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3009 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2010-07-15 17:20:43 +02:00
*
* @ return string HTML code if return parameter is true .
*/
2019-01-30 16:18:44 +01:00
function html_print_select_groups (
$id_user = false ,
$privilege = 'AR' ,
$returnAllGroup = true ,
2020-09-11 14:34:41 +02:00
$name = null ,
2019-01-30 16:18:44 +01:00
$selected = '' ,
$script = '' ,
$nothing = '' ,
$nothing_value = 0 ,
$return = false ,
$multiple = false ,
2020-09-11 14:34:41 +02:00
$sort = false ,
2019-01-30 16:18:44 +01:00
$class = '' ,
$disabled = false ,
$style = false ,
$option_style = false ,
$id_group = false ,
$keys_field = 'id_grupo' ,
$strict_user = false ,
$delete_groups = false ,
2019-04-22 17:46:04 +02:00
$include_groups = false ,
2019-04-24 12:32:33 +02:00
$size = false ,
2020-09-29 15:48:20 +02:00
$simple_multiple_options = false ,
2021-06-25 09:37:26 +02:00
$required = false ,
2023-03-09 19:25:14 +01:00
$inverse = '' ,
$form = ''
2019-01-30 16:18:44 +01:00
) {
2020-09-28 16:02:54 +02:00
$output = '' ;
2021-03-11 15:40:23 +01:00
global $config ;
2021-03-15 17:55:54 +01:00
$select2_css = 'select2.min' ;
2021-03-11 15:40:23 +01:00
2022-01-17 10:22:30 +01:00
if ( $config [ 'style' ] === 'pandora_black' && ! is_metaconsole ()) {
2021-03-11 15:40:23 +01:00
$select2_css = 'select2_dark.min' ;
}
2020-09-28 16:02:54 +02:00
if ( is_ajax ()) {
$output .= '<script src="' ;
2020-10-02 14:00:04 +02:00
$output .= ui_get_full_url (
'include/javascript/select2.min.js' ,
false ,
false ,
false
);
2023-03-24 12:06:40 +01:00
$output .= '?v=' . $config [ 'current_package' ] . '" type="text/javascript"></script>' ;
2020-09-28 16:02:54 +02:00
$output .= '<link rel="stylesheet" href="' ;
2020-10-02 14:00:04 +02:00
$output .= ui_get_full_url (
2021-03-11 15:40:23 +01:00
'include/styles/' . $select2_css . '.css' ,
2020-10-02 14:00:04 +02:00
false ,
false ,
false
);
2023-03-24 12:06:40 +01:00
$output .= '?v=' . $config [ 'current_package' ] . '"/>' ;
2020-09-28 16:02:54 +02:00
} else {
2021-03-11 15:40:23 +01:00
ui_require_css_file ( $select2_css );
2020-09-28 16:02:54 +02:00
ui_require_javascript_file ( 'select2.min' );
}
2020-09-11 14:34:41 +02:00
if ( $name === null ) {
static $idcounter = [];
if ( isset ( $idcounter [ $name ]) === true ) {
$idcounter [ $name ] ++ ;
} else {
$idcounter [ $name ] = 0 ;
2019-01-30 16:18:44 +01:00
}
2020-09-11 14:34:41 +02:00
$name = 'group_select' . $idcounter [ $name ];
2019-01-30 16:18:44 +01:00
}
2020-10-27 16:03:35 +01:00
if ( $id_group !== false ) {
2020-10-21 18:31:10 +02:00
$children = groups_get_children ( $id_group );
foreach ( $children as $child ) {
$delete_groups [] = $child [ 'id_grupo' ];
}
$delete_groups [] = $id_group ;
}
2020-09-11 14:34:41 +02:00
$fields = [];
// Preload selector.
if ( is_array ( $selected ) === false ) {
if ( empty ( $selected ) === false ) {
$fields = [ $selected => groups_get_name ( $selected ) ];
2020-09-29 14:22:58 +02:00
} else if ( $returnAllGroup === true && $multiple === false ) {
2021-06-25 09:37:26 +02:00
if ( $selected === 0 && $inverse !== '' ) {
$fields = [ $selected => 'None' ];
} else {
$fields = [ $selected => groups_get_name ( null , true ) ];
}
2020-09-11 14:34:41 +02:00
}
} else {
foreach ( $selected as $k ) {
2020-10-20 18:06:05 +02:00
if ( $k === null || $k === '' ) {
continue ;
}
2020-10-20 17:47:35 +02:00
$fields [ $k ] = groups_get_name ( $k , $returnAllGroup );
2019-01-30 16:18:44 +01:00
}
2020-10-20 18:06:05 +02:00
if ( empty ( $fields ) === true && $returnAllGroup ) {
$fields [ 0 ] = groups_get_name ( null , true );
2019-01-30 16:18:44 +01:00
}
2020-09-11 14:34:41 +02:00
}
2019-01-30 16:18:44 +01:00
2020-10-08 16:41:26 +02:00
if ( empty ( $nothing ) === false ) {
$fields [ $nothing_value ] = $nothing ;
2023-08-01 14:51:31 +02:00
if ( $include_groups === false ) {
$include_groups = [];
}
2020-10-08 16:41:26 +02:00
$include_groups [ $nothing_value ] = $nothing ;
}
2021-02-09 12:05:59 +01:00
$json_exclusions = '' ;
$json_inclusions = '' ;
2020-09-11 14:34:41 +02:00
if ( is_array ( $delete_groups ) === true ) {
$json_exclusions = json_encode ( $delete_groups );
2019-01-30 16:18:44 +01:00
}
2020-09-11 14:34:41 +02:00
if ( is_array ( $include_groups ) === true ) {
$json_inclusions = json_encode ( $include_groups );
2019-01-30 16:18:44 +01:00
}
2020-09-28 16:02:54 +02:00
$output .= html_print_select (
2019-01-30 16:18:44 +01:00
$fields ,
$name ,
$selected ,
$script ,
$nothing ,
$nothing_value ,
$return ,
$multiple ,
2020-09-11 14:34:41 +02:00
$sort ,
2019-01-30 16:18:44 +01:00
$class ,
$disabled ,
$style ,
2019-04-22 17:46:04 +02:00
$option_style ,
2019-04-24 12:32:33 +02:00
$size ,
false ,
'' ,
false ,
2020-09-29 15:48:20 +02:00
$simple_multiple_options ,
2023-03-09 19:25:14 +01:00
$required ,
false ,
true ,
false ,
false ,
$form
2019-01-30 16:18:44 +01:00
);
2021-01-11 13:53:52 +01:00
if ( $required !== false ) {
2021-03-18 11:48:52 +01:00
$require_message = __ ( 'Please select an item from this list.' );
2021-01-11 13:53:52 +01:00
}
2020-09-11 14:34:41 +02:00
if ( empty ( $size ) === true ) {
$size = '100%' ;
}
ob_start ();
?>
< style type = " text/css " >
. select2 - search__field {
background : url ( '<?php echo ui_get_full_url(' images / zoom . png '); ?>' ) no - repeat ;
background - position : right 10 px center ;
background - size : 1 em ;
}
</ style >
< script type = " text/javascript " >
2021-08-24 13:30:50 +02:00
2020-09-11 14:34:41 +02:00
$ ( document ) . ready ( function () {
2021-08-24 13:30:50 +02:00
2020-09-11 14:34:41 +02:00
$ ( 'select[name="<?php echo $name; ?>"]' ) . each (
function () {
$ ( this ) . select2 ({
2020-09-29 14:22:58 +02:00
multiple : < ? php echo ( $multiple ) ? 'true' : 'false' ; ?> ,
placeholder : " <?php echo __('Please select...'); ?> " ,
2020-09-11 14:34:41 +02:00
debug : 0 ,
width : '<?php echo $size; ?>' ,
templateResult : function ( node ) {
if ( ! node . id ) {
return node . text ;
}
return $ ( '<span style="padding-left:' + ( 5 * node . level ) + 'px;">' + node . text + '</span>' );
},
ajax : {
delay : 500 ,
method : 'post' ,
url : '<?php echo ui_get_full_url(' ajax . php '); ?>' ,
dataType : 'json' ,
data : function ( params ) {
var query = {
search : params . term ,
page : 'include/ajax/group' ,
method : 'getGroupsForSelect' ,
2020-09-30 17:47:44 +02:00
id_user : '<?php echo $id_user; ?>' ,
privilege : '<?php echo $privilege; ?>' ,
2020-09-11 14:34:41 +02:00
exclusions : '<?php echo $json_exclusions; ?>' ,
inclusions : '<?php echo $json_inclusions; ?>' ,
2020-09-11 14:53:29 +02:00
step : params . page || 1 ,
2020-09-11 14:34:41 +02:00
strict : " <?php echo $strict_user ; ?> " ,
2021-08-24 13:30:50 +02:00
not_condition : $ ( '#not_condition_switch' ) . prop ( 'checked' ),
2020-09-11 15:30:18 +02:00
returnAllGroup : < ? php echo ( int ) $returnAllGroup ; ?>
2020-09-11 14:34:41 +02:00
}
return query ;
}
}
});
2021-03-18 10:35:41 +01:00
< ? php
if ( $required !== false ) {
?>
$ ( this ) . on ( 'change' , function ( e ) {
e . currentTarget . setCustomValidity ( '' );
})
$ ( this ) . on ( 'invalid' , function ( e ) {
if ( $ ( e . currentTarget ) . val () == null ) {
e . currentTarget . setCustomValidity (
'<?php echo $require_message; ?>'
);
}
})
< ? php
}
?>
2020-09-11 14:34:41 +02:00
}
);
2020-09-29 14:22:58 +02:00
< ? php
if ( empty ( $fields ) === true ) {
?>
$ ( 'select[name="<?php echo $name; ?>"]' ) . val ( null ) . trigger ( " change " );
2020-09-30 17:47:44 +02:00
$ ( 'select[name="<?php echo $name; ?>"] option[value=""]' ) . each ( function () {
$ ( this ) . remove ();
});
2020-09-29 14:22:58 +02:00
< ? php
}
?>
2020-09-11 14:34:41 +02:00
});
</ script >
< ? php
$output .= ob_get_clean ();
2019-01-30 16:18:44 +01:00
if ( $return ) {
return $output ;
} else {
echo $output ;
}
2010-07-15 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_html.php: added the function "print_select_groups" to
print the field select box for groups with tree style.
* include/functions_db.php: in function "get_user_groups" added test to
false value in parameter $privilege for get all groups without ACL test.
Fixed in function "get_user_groups_tree" the call to "get_user_groups" with
the correct parameters.
* operation/incidents/incident.php, operation/incidents/incident_detail.php,
operation/events/events.php, operation/agentes/status_monitor.php,
operation/agentes/estado_agente.php,
operation/agentes/alerts_status.functions.php,
operation/agentes/exportdata.php, operation/agentes/networkmap.php,
operation/messages/message.php, general/ui/agents_list.php,
godmode/groups/configure_group.php, godmode/groups/group_list.php,
godmode/agentes/massive_add_alerts.php,
godmode/agentes/massive_delete_agents.php,
godmode/agentes/massive_config.php,
godmode/agentes/massive_delete_action_alerts.php,
godmode/agentes/massive_delete_alerts.php,
godmode/agentes/modificar_agente.php,
godmode/agentes/massive_delete_modules.php,
godmode/agentes/massive_add_action_alerts.php,
godmode/agentes/planned_downtime.php,
godmode/agentes/manage_config_remote.php, godmode/agentes/agent_manager.php,
godmode/servers/manage_recontask_form.php,
godmode/alerts/configure_alert_compound.php,
godmode/alerts/alert_compounds.php,
godmode/alerts/configure_alert_template.php,
godmode/alerts/configure_alert_action.php, godmode/setup/gis_step_2.php,
godmode/users/configure_user.php, godmode/gis_maps/configure_gis_map.php,
godmode/reporting/graph_builder.main.php,
godmode/reporting/reporting_builder.main.php,
godmode/reporting/visual_console_builder.data.php: changed the fields select
box of group to tree style select box for groups.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3009 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2010-07-15 17:20:43 +02:00
}
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
2019-01-30 16:18:44 +01:00
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
/**
* Prints an array of fields in a popup menu of a form .
2019-01-30 16:18:44 +01:00
*
* Based on choose_from_menu () from Moodle
*
2009-01-12 Esteban Sanchez <estebans@artica.es>
* godmode/agentes/alert_manager.php: Complete rewritten of the alert
system when assigned alerts to an agent.
* pandoradb.sql: New tables for alert system. These are:
talert_commands, talert_actions, talert_templates,
talert_template_modules, talert_template_module_actions. No migration
tool is available yet.
* godmode/alerts/configure_alert_template.php,
godmode/alerts/configure_alert_action.php,
godmode/alerts/alert_templates.php,
godmode/alerts/configure_alert_command.php,
godmode/alerts/alert_actions.php: Added to repository. Administration
interface to new alert system.
* godmode/alerts/modify_alert.php: Deleted from repository.
* godmode/setup/setup.php: Added an example of the date format. Main
table has now percentage width.
* godmode/menu.php, operation/menu.php: Added new alert options.
Removed refr value when it's not neccesary.
* include/styles/pandora.css: Added width to textarea elements. Style
correction and cleanup. Tables doesn't have a odd-even pattern, but
the hovered row now changes its colour. New styles for alert pages.
* include/functions_custom_graphs.php: Added to repository. custom
graphs functions moved here.
* include/functions_incidents.php, include/functions_events.php: Moved
to LGPL. Style comment corrections.
* include/functions_html.php: Documentation style correction. Added
print_input_file() and print_label().
* include/functions_ui.php: Doc style correction.
* operation/reporting/graph_viewer.php: Include new function file with
custom graphs. Use generic functions.
* index.php: Unset pass from POST and REQUEST arrays.
* include/functions_db.php: Some documentation updated to new format.
Added format_array_to_update_sql() to generate SQL sentences for
updates. Style correction.
* godmode/agentes/configurar_agente.php: Variables renamed to have a
meaning.
* extensions/update_manager/main.php: Mark an string translatable.
* extensions/update_manager/lib/libupdate_manager_client.php,
godmode/alerts/configure_alert.php, include/functions.php,
godmode/agentes/module_manager.php, operation/agentes/networkmap.php,
operation/reporting/reporting_viewer.php,
godmode/agentes/manage_config.php: Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-12 15:31:01 +01:00
* @ param array Array with dropdown values . Example : $fields [ " value " ] = " label "
* @ param string Select form name
* @ param variant Current selected value . Can be a single value or an
2012-12-05 Miguel de Dios <miguel.dedios@artica.es>
* extensions/update_manager/lib/libupdate_manager_client.php,
extensions/update_manager/lib/libupdate_manager.php,
operation/agentes/ver_agente.php,
operation/agentes/status_monitor.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/estado_agente.php,
operation/integria_incidents/incident.php,
operation/reporting/reporting_xml.php,
godmode/reporting/visual_console_builder.editor.js,
godmode/reporting/visual_console_builder.wizard.php,
godmode/reporting/visual_console_builder.elements.php,
include/functions_visual_map.php,
include/functions_visual_map_editor.php: uploaded the changes of
source code style previous to my next commit for to make the next
commit more easy.
* godmode/reporting/visual_console_builder.php: set empty string
for the new visualmap.
* include/ajax/visual_console_builder.ajax.php: fixed the regular
expresion to extract the url for the graph.
* include/functions_html.php: fixed into the function
"html_print_select_groups" lost code for to show the selectbox.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7230 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-12-05 15:20:47 +01:00
* array of selected values ( in combination with multiple )
2009-01-12 Esteban Sanchez <estebans@artica.es>
* godmode/agentes/alert_manager.php: Complete rewritten of the alert
system when assigned alerts to an agent.
* pandoradb.sql: New tables for alert system. These are:
talert_commands, talert_actions, talert_templates,
talert_template_modules, talert_template_module_actions. No migration
tool is available yet.
* godmode/alerts/configure_alert_template.php,
godmode/alerts/configure_alert_action.php,
godmode/alerts/alert_templates.php,
godmode/alerts/configure_alert_command.php,
godmode/alerts/alert_actions.php: Added to repository. Administration
interface to new alert system.
* godmode/alerts/modify_alert.php: Deleted from repository.
* godmode/setup/setup.php: Added an example of the date format. Main
table has now percentage width.
* godmode/menu.php, operation/menu.php: Added new alert options.
Removed refr value when it's not neccesary.
* include/styles/pandora.css: Added width to textarea elements. Style
correction and cleanup. Tables doesn't have a odd-even pattern, but
the hovered row now changes its colour. New styles for alert pages.
* include/functions_custom_graphs.php: Added to repository. custom
graphs functions moved here.
* include/functions_incidents.php, include/functions_events.php: Moved
to LGPL. Style comment corrections.
* include/functions_html.php: Documentation style correction. Added
print_input_file() and print_label().
* include/functions_ui.php: Doc style correction.
* operation/reporting/graph_viewer.php: Include new function file with
custom graphs. Use generic functions.
* index.php: Unset pass from POST and REQUEST arrays.
* include/functions_db.php: Some documentation updated to new format.
Added format_array_to_update_sql() to generate SQL sentences for
updates. Style correction.
* godmode/agentes/configurar_agente.php: Variables renamed to have a
meaning.
* extensions/update_manager/main.php: Mark an string translatable.
* extensions/update_manager/lib/libupdate_manager_client.php,
godmode/alerts/configure_alert.php, include/functions.php,
godmode/agentes/module_manager.php, operation/agentes/networkmap.php,
operation/reporting/reporting_viewer.php,
godmode/agentes/manage_config.php: Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-12 15:31:01 +01:00
* @ param string Javascript onChange code .
* @ param string Label when nothing is selected .
* @ param variant Value when nothing is selected
* @ param bool Whether to return an output string or echo now ( optional , echo by default ) .
* @ param bool Set the input to allow multiple selections ( optional , single selection by default ) .
* @ param bool Whether to sort the options or not ( optional , unsorted by default ) .
2019-01-30 16:18:44 +01:00
* @ param string $style The string of style .
* @ param mixed $size Max elements showed in the select or default ( size = 10 ) .
2008-12-16 11:20:33 +01:00
*
* @ return string HTML code if return parameter is true .
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
*/
2019-01-30 16:18:44 +01:00
function html_print_select (
$fields ,
$name ,
$selected = '' ,
$script = '' ,
$nothing = '' ,
$nothing_value = 0 ,
$return = false ,
$multiple = false ,
$sort = true ,
$class = '' ,
$disabled = false ,
$style = false ,
$option_style = false ,
$size = false ,
$modal = false ,
$message = '' ,
2019-04-24 12:32:33 +02:00
$select_all = false ,
2020-09-29 15:48:20 +02:00
$simple_multiple_options = false ,
2021-04-07 12:52:39 +02:00
$required = false ,
2021-04-19 12:59:52 +02:00
$truncate_size = false ,
2021-10-07 17:12:00 +02:00
$select2_enable = true ,
2021-11-12 13:11:49 +01:00
$select2_multiple_enable = false ,
2023-03-09 19:25:14 +01:00
$select2_multiple_enable_all = false ,
2023-05-08 10:35:59 +02:00
$form = '' ,
$order = false ,
2019-01-30 16:18:44 +01:00
) {
$output = " \n " ;
static $idcounter = [];
2021-03-18 09:53:39 +01:00
global $config ;
2019-01-30 16:18:44 +01:00
// If duplicate names exist, it will start numbering. Otherwise it won't
if ( isset ( $idcounter [ $name ])) {
$idcounter [ $name ] ++ ;
} else {
$idcounter [ $name ] = 0 ;
}
$id = preg_replace ( '/[^a-z0-9\:\;\-\_]/i' , '' , $name . ( $idcounter [ $name ] ? $idcounter [ $name ] : '' ));
$attributes = '' ;
if ( ! empty ( $script )) {
$attributes .= ' onchange="' . $script . '"' ;
}
2019-04-24 12:32:33 +02:00
if ( ! empty ( $multiple )) {
if ( $size !== false ) {
$attributes .= ' multiple="multiple" size="' . $size . '"' ;
} else {
$attributes .= ' multiple="multiple" size="10"' ;
}
}
2019-04-22 17:46:04 +02:00
2019-04-24 12:32:33 +02:00
if ( $simple_multiple_options === true ) {
if ( $size !== false ) {
$attributes .= ' size="' . $size . '"' ;
} else {
$attributes .= ' size="10"' ;
}
}
2019-01-30 16:18:44 +01:00
2023-05-08 10:35:59 +02:00
if ( $multiple === true && $order === true ) {
$class .= ' order-arrows' ;
}
2019-01-30 16:18:44 +01:00
if ( ! empty ( $class )) {
$attributes .= ' class="' . $class . '"' ;
}
2023-03-09 19:25:14 +01:00
if ( ! empty ( $form )) {
$attributes .= ' form="' . $form . '"' ;
}
2019-01-30 16:18:44 +01:00
if ( ! empty ( $disabled )) {
$attributes .= ' disabled="disabled"' ;
}
if ( $style === false ) {
2021-03-11 15:40:23 +01:00
$styleText = ' ' ;
2022-01-17 10:22:30 +01:00
if ( $config [ 'style' ] === 'pandora_black' && ! is_metaconsole ()) {
2021-03-18 09:53:39 +01:00
$styleText = 'style="color: white"' ;
}
2019-01-30 16:18:44 +01:00
} else {
2022-01-17 10:22:30 +01:00
if ( $config [ 'style' ] === 'pandora_black' && ! is_metaconsole ()) {
2021-03-18 09:53:39 +01:00
$style .= ' color: white' ;
}
2019-01-30 16:18:44 +01:00
$styleText = 'style="' . $style . '"' ;
}
2020-09-29 15:48:20 +02:00
if ( $required ) {
$required = 'required' ;
}
2021-11-12 13:11:49 +01:00
if ( $select2_multiple_enable === true
&& $select2_multiple_enable_all === true
) {
$output .= '<div class="flex-row-center">' ;
}
2022-03-31 20:11:52 +02:00
$output .= '<select ' . $required . ' id="' . $id . '" name="' . $name . '"' . $attributes . ' ' . $styleText . '>' ;
2019-01-30 16:18:44 +01:00
2020-05-14 17:42:58 +02:00
if ( $nothing !== false ) {
if ( $nothing != '' || empty ( $fields )) {
if ( $nothing == '' ) {
$nothing = __ ( 'None' );
}
2019-01-30 16:18:44 +01:00
2020-05-14 17:42:58 +02:00
$output .= '<option value="' . $nothing_value . '"' ;
2019-01-30 16:18:44 +01:00
2020-05-14 17:42:58 +02:00
if ( $nothing_value == $selected ) {
2019-01-30 16:18:44 +01:00
$output .= ' selected="selected"' ;
2020-05-14 17:42:58 +02:00
} else if ( is_array ( $selected )) {
if ( in_array ( $nothing_value , $selected )) {
$output .= ' selected="selected"' ;
}
2019-01-30 16:18:44 +01:00
}
2020-05-14 17:42:58 +02:00
$output .= '>' . $nothing . '</option>' ;
}
2019-01-30 16:18:44 +01:00
}
if ( is_array ( $fields ) && ! empty ( $fields )) {
if ( $sort !== false ) {
// Sorting the fields in natural way and case insensitive preserving keys
$first_elem = reset ( $fields );
if ( ! is_array ( $first_elem )) {
uasort ( $fields , 'strnatcasecmp' );
}
}
$lastopttype = '' ;
foreach ( $fields as $value => $label ) {
$optlabel = $label ;
if ( is_array ( $label )) {
if ( isset ( $label [ 'optgroup' ])) {
if ( $label [ 'optgroup' ] != $lastopttype ) {
if ( $lastopttype != '' ) {
$output .= '</optgroup>' ;
}
$output .= '<optgroup label="' . $label [ 'optgroup' ] . '">' ;
$lastopttype = $label [ 'optgroup' ];
}
}
$optlabel = $label [ 'name' ];
}
$output .= '<option ' ;
if ( $select_all ) {
$output .= 'selected ' ;
}
$output .= 'value="' . $value . '"' ;
if ( is_array ( $selected ) && in_array ( $value , $selected )) {
$output .= ' selected="selected"' ;
} else if ( is_numeric ( $value ) && is_numeric ( $selected )
2023-05-22 12:08:27 +02:00
&& $value === $selected
2019-01-30 16:18:44 +01:00
) {
// This fixes string ($value) to int ($selected) comparisons
$output .= ' selected="selected"' ;
2023-05-23 13:39:40 +02:00
} else if ( is_numeric ( $value ) && is_string ( $selected )) {
$str_value = strval ( $value );
if ( $str_value === $selected ) {
$output .= ' selected="selected"' ;
}
2019-01-30 16:18:44 +01:00
} else if ( $value === $selected ) {
// Needs type comparison otherwise if $selected = 0 and $value = "string" this would evaluate to true
$output .= ' selected="selected"' ;
}
if ( is_array ( $option_style )
&& in_array ( $value , array_keys ( $option_style ))
) {
$output .= ' style="' . $option_style [ $value ] . '"' ;
}
2021-04-07 12:52:39 +02:00
if ( $truncate_size !== false ) {
$output .= ' Title="' . $optlabel . '"' ;
$optlabel = ui_print_truncate_text (
$optlabel ,
$truncate_size ,
false ,
true ,
false
);
}
2019-01-30 16:18:44 +01:00
if ( $optlabel === '' ) {
2019-03-07 12:34:09 +01:00
$output .= '>None</option>' ;
2019-01-30 16:18:44 +01:00
} else {
$output .= '>' . $optlabel . '</option>' ;
}
}
if ( is_array ( $label )) {
$output .= '</optgroup>' ;
}
}
$output .= '</select>' ;
2021-11-12 13:11:49 +01:00
if ( $select2_multiple_enable === true
&& $select2_multiple_enable_all === true
) {
$output .= '<div class="margin-left-2 flex-column">' ;
$output .= '<span>' . __ ( 'All' ) . '</span>' ;
$output .= html_print_checkbox_switch (
$id . '-check-all' ,
1 ,
false ,
true ,
$disabled ,
'checkMultipleAll(' . $id . ')'
);
$output .= '</div>' ;
$output .= '</div>' ;
}
2019-01-30 16:18:44 +01:00
if ( $modal && ! enterprise_installed ()) {
$output .= "
2021-03-31 10:29:57 +02:00
< div id = '".$message."' class = 'publienterprise publicenterprise_div' title = 'Community version' >< img data - title = '".__(' Enterprise version not installed ')."' class = 'img_help forced_title' data - use_title_for_force_title = '1' src = 'images/alert_enterprise.png' ></ div >
2016-09-19 16:20:18 +02:00
" ;
2019-01-30 16:18:44 +01:00
}
2021-04-14 12:07:38 +02:00
$select2 = 'select2.min' ;
2022-10-27 17:31:48 +02:00
if ( $config [ 'style' ] === 'pandora_black' && is_metaconsole () === false ) {
2021-04-14 12:07:38 +02:00
$select2 = 'select2_dark.min' ;
}
2021-11-12 13:11:49 +01:00
if (( $multiple === false || $select2_multiple_enable === true ) && $select2_enable === true ) {
2022-10-27 17:31:48 +02:00
if ( is_ajax () === true ) {
2021-02-16 13:35:04 +01:00
$output .= '<script src="' ;
$output .= ui_get_full_url (
'include/javascript/select2.min.js' ,
false ,
false ,
false
);
2023-03-24 12:06:40 +01:00
$output .= '?v=' . $config [ 'current_package' ] . '" type="text/javascript"></script>' ;
2021-02-16 13:35:04 +01:00
$output .= '<link rel="stylesheet" href="' ;
$output .= ui_get_full_url (
2021-04-14 12:07:38 +02:00
'include/styles/' . $select2 . '.css' ,
2021-02-16 13:35:04 +01:00
false ,
false ,
false
);
2023-03-24 12:06:40 +01:00
$output .= '?v=' . $config [ 'current_package' ] . '"/>' ;
2021-02-16 13:35:04 +01:00
} else {
2021-04-09 12:00:11 +02:00
ui_require_css_file ( $select2 );
2021-02-16 13:35:04 +01:00
ui_require_javascript_file ( 'select2.min' );
}
2021-06-18 15:36:52 +02:00
$output .= '<script type="text/javascript">' ;
2022-02-22 11:00:11 +01:00
$output .= '$("#' . $id . ' " ).select2( {
closeOnSelect : '.(($select2_multiple_enable === true) ? ' false ' : ' true ').'
}); ' ;
2021-06-18 15:36:52 +02:00
if ( $required !== false ) {
$require_message = __ ( 'Please select an item from this list.' );
$output .= '$("#' . $id . ' " ).on( " change " , function(e) {
e . currentTarget . setCustomValidity ( " " );
}); ' ;
$output .= '$("#' . $id . ' " ).on( " invalid " , function(e) {
if ( $ ( e . currentTarget ) . val () == null ) {
e . currentTarget . setCustomValidity (
" '. $require_message .' "
);
}
}); ' ;
}
2021-11-12 13:11:49 +01:00
if ( $select2_multiple_enable === true
&& $select2_multiple_enable_all === true
) {
2022-06-30 14:09:29 +02:00
$output .= 'if($("#' . $id . ' > option").length !== $("#' . $id . ' > option : selected " ).length) {
checked = false ;
} else {
checked = true ;
}
$ ( " #checkbox-'. $id .'-check-all " ) . prop ( " checked " , checked ); ' ;
2021-11-12 13:11:49 +01:00
$output .= '$("#' . $id . ' " ).on( " change " , function(e) {
var checked = false ;
if ( e . target . length !== $ ( " #'. $id .' > option:selected " ) . length ) {
checked = false ;
} else {
checked = true ;
}
$ ( " #checkbox-'. $id .'-check-all " ) . prop ( " checked " , checked );
}); ' ;
2022-02-22 11:00:11 +01:00
$output .= 'var count_shift_' . $id . ' = 0;' ;
$output .= 'var shift_array_' . $id . ' = [];' ;
$output .= 'var options_selecteds_' . $id . ' = [];' ;
$output .= '$("#' . $id . ' " ).on( " select2 : select " , function (e) {
if ( event . shiftKey ) {
shift_array_ '.$id.' . push ( e . params . data . element . index );
count_shift_ '.$id.' ++ ;
}
if ( count_shift_ '.$id.' == 2 ){
if ( shift_array_ '.$id.' [ 0 ] <= shift_array_ '.$id.' [ 1 ]) {
for ( var i = shift_array_ '.$id.' [ 0 ]; i <= shift_array_ '.$id.' [ 1 ]; i ++ ) {
2022-07-05 13:38:59 +02:00
if ( $ ( " #'. $id .' option " ) . eq ( i ) . text () . includes ( $ ( " .select2-search__field " ) . val ()) == true ) {
var option_value = $ ( " #'. $id .' option " ) . eq ( i ) . val ();
options_selecteds_ '.$id.' . push ( option_value );
}
2022-02-22 11:00:11 +01:00
}
} else {
for ( var i = shift_array_ '.$id.' [ 0 ]; i >= shift_array_ '.$id.' [ 1 ]; i -- ) {
2022-07-05 13:38:59 +02:00
if ( $ ( " #'. $id .' option " ) . eq ( i ) . text () . includes ( $ ( " .select2-search__field " ) . val ()) == true ) {
var option_value = $ ( " #'. $id .' option " ) . eq ( i ) . val ();
options_selecteds_ '.$id.' . push ( option_value );
}
2022-02-22 11:00:11 +01:00
}
}
$ ( " #'. $id .' " ) . val (
[
... $ ( " #'. $id .' " ) . val (),
... options_selecteds_ '.$id.'
]
);
$ ( " #'. $id .' " ) . trigger ( " change " );
$ ( " #'. $id .' " ) . select2 ( " close " );
count_shift_ '.$id.' = 0 ;
shift_array_ '.$id.' = [];
options_selecteds_ '.$id.' = [];
}
}); ' ;
$output .= 'var delete_count_shift_' . $id . ' = 0;' ;
$output .= 'var delete_shift_array_' . $id . ' = [];' ;
$output .= 'var delete_options_selecteds_' . $id . ' = [];' ;
$output .= '$("#' . $id . ' " ).on( " select2 : unselect " , function (e) {
if ( event . shiftKey ) {
delete_shift_array_ '.$id.' . push ( e . params . data . element . index );
delete_count_shift_ '.$id.' ++ ;
}
if ( delete_count_shift_ '.$id.' == 2 ){
if ( delete_shift_array_ '.$id.' [ 0 ] <= delete_shift_array_ '.$id.' [ 1 ]) {
for ( var i = delete_shift_array_ '.$id.' [ 0 ]; i <= delete_shift_array_ '.$id.' [ 1 ]; i ++ ) {
var option_value = $ ( " #'. $id .' option " ) . eq ( i ) . val ();
delete_options_selecteds_ '.$id.' . push ( option_value );
}
} else {
for ( var i = delete_shift_array_ '.$id.' [ 0 ]; i >= delete_shift_array_ '.$id.' [ 1 ]; i -- ) {
var option_value = $ ( " #'. $id .' option " ) . eq ( i ) . val ();
delete_options_selecteds_ '.$id.' . push ( option_value );
}
}
var result = [];
$ ( " #'. $id .' " ) . val () . forEach ( function ( value ) {
if ( delete_options_selecteds_ '.$id.' . includes ( value ) == false ) {
result . push ( value );
}
});
$ ( " #'. $id .' " ) . val ( result );
$ ( " #'. $id .' " ) . trigger ( " change " );
$ ( " #'. $id .' " ) . select2 ( " close " );
delete_count_shift_ '.$id.' = 0 ;
delete_shift_array_ '.$id.' = [];
delete_options_selecteds_ '.$id.' = [];
}
}); ' ;
2021-11-12 13:11:49 +01:00
$output .= ' function checkMultipleAll ( id ){
if ( $ ( " #checkbox- " + id . id + " -check-all " ) . is ( " :checked " )) {
$ ( " # " + id . id + " > option " ) . prop ( " selected " , " selected " );
$ ( " # " + id . id ) . trigger ( " change " );
} else {
$ ( " # " + id . id ) . val ( null ) . trigger ( " change " );
}
} ' ;
}
2021-06-18 15:36:52 +02:00
$output .= '</script>' ;
2021-02-16 13:35:04 +01:00
}
2023-05-08 10:35:59 +02:00
if ( $multiple === true && $order === true ) {
$output .= '<script>' ;
$output .= '
if ( typeof draggingOption === " undefined " ) {
let draggingOption = null ;
} else {
draggingOption = null ;
}
document . getElementById ( " '. $id .' " ) . addEventListener ( " mousedown " , e => {
if ( e . target . tagName === " OPTION " ) {
draggingOption = e . target ;
document . getElementById ( " '. $id .' " ) . classList . add ( " dragging " );
}
});
document . getElementById ( " '. $id .' " ) . addEventListener ( " mousemove " , e => {
if ( typeof draggingOption !== " undefined " ) {
if ( draggingOption ) {
e . preventDefault ();
const targetOption = document . elementFromPoint ( e . clientX , e . clientY );
if ( targetOption && targetOption . tagName === " OPTION " ) {
const boundingRect = targetOption . getBoundingClientRect ();
if ( e . clientY < boundingRect . top + boundingRect . height / 2 ) {
document . getElementById ( " '. $id .' " ) . insertBefore ( draggingOption , targetOption );
} else {
document . getElementById ( " '. $id .' " ) . insertBefore ( draggingOption , targetOption . nextSibling );
}
}
}
}
});
document . getElementById ( " '. $id .' " ) . addEventListener ( " mouseup " , e => {
if ( typeof draggingOption !== " undefined " ) {
if ( draggingOption ) {
document . getElementById ( " '. $id .' " ) . classList . remove ( " dragging " );
draggingOption = null ;
}
}
}); ' ;
$output .= '</script>' ;
}
2019-01-30 16:18:44 +01:00
if ( $return ) {
return $output ;
}
echo $output ;
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
}
2019-01-30 16:18:44 +01:00
2020-05-14 17:42:58 +02:00
/**
* Generates a multiselect component with filters .
*
* @ param array $available Available .
* @ param array $selected Selected .
* @ param string $name Custom identifier ( optional ) .
* @ param string $class Custom class for main container ( optional ) .
* @ param boolean $return Dump to output or only return .
* @ param array $group_filter Ajax information to reload content while
* using different group filter ( if enabled ) . Uses :
* [
* page => 'your/controller/php' ,
* method => 'yourMethodName'
* ]
* Ensure you return data in json format as :
* { id : label , id2 : label2 ... }
* Provided by caller .
* @ param array $texts Texts .
* @ param array $sections Enables or disables sub - components .
*
* @ return string HTML code with component .
*/
function html_print_select_multiple_filtered (
array $available ,
array $selected ,
? string $name = null ,
string $class = '' ,
bool $return = true ,
array $group_filter = [],
array $texts = [],
array $sections = []
) {
ui_require_css_file ( 'multiselect_filtered' );
2020-07-17 10:33:40 +02:00
if ( is_ajax () === true ) {
ui_require_javascript_file ( 'multiselect_filtered' , 'include/javascript/' , true );
} else {
ui_require_javascript_file ( 'multiselect_filtered' );
}
2020-05-14 17:42:58 +02:00
if ( empty ( $name ) === true ) {
$rid = uniqid ();
} else {
$rid = $name ;
}
if ( empty ( $texts ) === true ) {
2020-05-20 19:04:42 +02:00
$texts = [];
}
if ( empty ( $texts [ 'filter-item' ]) === true ) {
$texts [ 'filter-item' ] = 'Filter agent alias' ;
}
if ( empty ( $texts [ 'title-add' ]) === true ) {
$texts [ 'title-add' ] = 'Add selected' ;
}
if ( empty ( $texts [ 'title-del' ]) === true ) {
$texts [ 'title-del' ] = 'Remove selected' ;
}
if ( empty ( $texts [ 'title-left' ]) === true ) {
$texts [ 'title-left' ] = 'Available items' ;
}
if ( empty ( $texts [ 'title-right' ]) === true ) {
$texts [ 'title-right' ] = 'Selected items' ;
2020-05-14 17:42:58 +02:00
}
if ( empty ( $sections ) === true ) {
2020-05-20 19:04:42 +02:00
$sections = [];
}
2020-11-30 14:52:03 +01:00
if ( isset ( $sections [ 'filters' ]) === false ) {
2020-05-20 19:04:42 +02:00
$sections [ 'filters' ] = 1 ;
}
2020-11-30 14:52:03 +01:00
// Show/hide all left/rigth sfilters.
if ( isset ( $sections [ 'item-selected-filters' ]) === false ) {
$sections [ 'item-selected-filters' ] = 1 ;
}
if ( isset ( $sections [ 'item-available-filters' ]) === false ) {
$sections [ 'item-available-filters' ] = 1 ;
}
if ( isset ( $sections [ 'group-filter' ]) == false ) {
2020-05-20 19:04:42 +02:00
$sections [ 'group-filter' ] = 1 ;
}
2020-11-30 14:52:03 +01:00
if ( isset ( $sections [ 'item-available-filter' ]) === false ) {
2020-05-20 19:04:42 +02:00
$sections [ 'item-available-filter' ] = 1 ;
}
2020-11-30 14:52:03 +01:00
if ( isset ( $sections [ 'item-selected-filter' ]) === false ) {
2020-05-20 19:04:42 +02:00
$sections [ 'item-selected-filter' ] = 1 ;
2020-05-14 17:42:58 +02:00
}
2020-11-30 14:52:03 +01:00
if ( isset ( $group_filter ) === false ) {
2020-05-14 17:42:58 +02:00
$sections [ 'group-filter' ] = 0 ;
}
2020-11-30 14:52:03 +01:00
if ( isset ( $group_filter [ 'nothing' ]) === false ) {
$group_filter [ 'nothing' ] = '' ;
}
if ( isset ( $group_filter [ 'nothing_value' ]) === false ) {
$group_filter [ 'nothing_value' ] = 0 ;
}
2020-05-14 17:42:58 +02:00
// Main container.
2020-11-30 14:52:03 +01:00
$output = '<div class="multi-select flex-row-end ' . $class . '">' ;
2020-05-14 17:42:58 +02:00
// Left box.
$output .= '<div class="multi-select-container flex-column">' ;
2020-05-25 18:18:38 +02:00
$disable_filters = '' ;
2020-05-14 17:42:58 +02:00
// Filtering.
if ( isset ( $sections [ 'filters' ]) === true
&& $sections [ 'filters' ] === 1
2020-11-30 14:52:03 +01:00
&& $sections [ 'item-available-filters' ] === 1
2020-05-14 17:42:58 +02:00
) {
// Filtering.
if ( isset ( $sections [ 'group-filter' ]) === true
&& $sections [ 'group-filter' ] === 1
) {
$output .= '<div class="filter">' ;
$output .= '<div class="group-filter flex-row-vcenter">' ;
$reload_content = " reloadContent(' " . $rid . " ' " ;
$reload_content .= " , ' " . ui_get_full_url ( 'ajax.php' ) . " ' " ;
$reload_content .= " , ' " . base64_encode (
json_encode ( $group_filter )
) . " ' " ;
$reload_content .= " , 'left' " ;
$reload_content .= " , ' " . __ ( 'None' ) . " ') " ;
$output .= html_print_input (
[
2020-11-30 14:52:03 +01:00
'input_class' => 'flex-row-vcenter' ,
2020-05-14 17:42:58 +02:00
'label' => __ ( 'Filter group' ),
'name' => 'id-group-available-select-' . $rid ,
'returnAllGroup' => true ,
'privilege' => 'AR' ,
'type' => 'select_groups' ,
'return' => true ,
'script' => $reload_content ,
2020-11-30 14:52:03 +01:00
'nothing' => $group_filter [ 'nothing' ],
'nothing_value' => $group_filter [ 'nothing_value' ],
2020-05-14 17:42:58 +02:00
]
);
$output .= html_print_input (
[
2020-11-30 14:52:03 +01:00
'label' => __ ( 'Group recursion' ),
'input_class' => 'flex-row-vcenter' ,
'name' => 'id-group-recursion-available-select-' . $rid ,
'id' => 'checkbox-id-group-recursion-available-select-' . $rid ,
'type' => 'switch' ,
'onchange' => $reload_content ,
'return' => true ,
2020-05-14 17:42:58 +02:00
]
);
$output .= '</div>' ;
$output .= '</div>' ;
2020-05-25 18:18:38 +02:00
$disable_filters = " disableFilters(' " . $rid . " ') " ;
2020-05-14 17:42:58 +02:00
}
if ( isset ( $sections [ 'item-available-filter' ]) === true
&& $sections [ 'item-available-filter' ] === 1
) {
$output .= '<div class="item-filter flex-row-vcenter">' ;
2021-12-30 18:26:59 +01:00
$output .= '<div style="display:none">' ;
2020-05-14 17:42:58 +02:00
$output .= html_print_input (
[
'style' => 'display:none;' ,
'name' => 'tmp-available-select-' . $rid ,
'type' => 'select' ,
'nothing' => false ,
'return' => true ,
]
);
2021-12-30 18:26:59 +01:00
$output .= '</div>' ;
2020-05-14 17:42:58 +02:00
$f = " filterAvailableItems(this.value,' " . $rid . " ',' " . __ ( 'None' ) . " ') " ;
$output .= html_print_input (
[
'label' => __ ( $texts [ 'filter-item' ]),
'name' => 'filter-item-available-' . $rid ,
'onKeyUp' => $f ,
'input_class' => 'filter w100p' ,
'size' => 20 ,
'type' => 'text' ,
'return' => true ,
]
);
$output .= '</div>' ;
}
}
$output .= '<span class="title">' . $texts [ 'title-left' ] . '</span>' ;
// Selector boxes.
$output .= html_print_input (
[
'type' => 'select' ,
'fields' => $available ,
'name' => 'available-select-' . $rid . '[]' ,
'selected' => '' ,
2020-05-25 18:18:38 +02:00
'script' => $disable_filters ,
2020-05-14 17:42:58 +02:00
'nothing' => '' ,
'nothing_value' => 0 ,
'return' => true ,
'multiple' => true ,
'sort' => true ,
'class' => 'select-multiple' ,
'disabled' => false ,
'style' => false ,
'option_style' => false ,
'size' => false ,
'modal' => false ,
'message' => '' ,
'select_all' => false ,
'simple_multiple_options' => false ,
]
);
$output .= '</div>' ;
// Middle buttons actions.
$add = " addItems(' " . $rid . " ',' " . __ ( 'None' ) . " '); return false " ;
$del = " removeItems(' " . $rid . " ',' " . __ ( 'None' ) . " '); return false " ;
$output .= '<div class="arrows-container flex-column">' ;
2023-03-07 14:15:02 +01:00
$output .= html_print_image (
'images/plus.svg' ,
true ,
2020-05-14 17:42:58 +02:00
[
2023-03-07 14:15:02 +01:00
'id' => 'right_autorefreshlist' ,
'style' => 'width: 24px; margin: 10px 10px 0;' ,
'alt' => __ ( 'Push selected pages into autorefresh list' ),
'title' => __ ( 'Push selected pages into autorefresh list' ),
'onclick' => $add ,
2020-05-14 17:42:58 +02:00
]
);
2023-03-07 14:15:02 +01:00
$output .= html_print_image (
'images/minus.svg' ,
true ,
2020-05-14 17:42:58 +02:00
[
2023-03-07 14:15:02 +01:00
'id' => 'left_autorefreshlist' ,
'style' => 'width: 24px; margin: 10px 10px 0;' ,
'alt' => __ ( 'Pop selected pages out of autorefresh list' ),
'title' => __ ( 'Pop selected pages out of autorefresh list' ),
'onclick' => $del ,
2020-05-14 17:42:58 +02:00
]
);
$output .= '</div>' ;
2020-07-07 19:10:24 +02:00
// Right box.
2020-05-14 17:42:58 +02:00
$output .= '<div class="multi-select-container flex-column">' ;
// Filtering.
if ( isset ( $sections [ 'filters' ]) === true
&& $sections [ 'filters' ] === 1
2020-11-30 14:52:03 +01:00
&& $sections [ 'item-selected-filters' ]
2020-05-14 17:42:58 +02:00
) {
if ( isset ( $sections [ 'group-filter' ]) === true
&& $sections [ 'group-filter' ] === 1
) {
$output .= '<div class="filter">' ;
$output .= '<div class="group-filter flex-row-vcenter">' ;
$reload_content = " reloadContent(' " . $rid . " ' " ;
$reload_content .= " , ' " . ui_get_full_url ( 'ajax.php' ) . " ' " ;
$reload_content .= " , ' " . base64_encode (
json_encode ( $group_filter )
) . " ' " ;
$reload_content .= " , 'right' " ;
$reload_content .= " , ' " . __ ( 'None' ) . " ') " ;
$output .= html_print_input (
[
2020-11-30 14:52:03 +01:00
'input_class' => 'flex-row-vcenter' ,
2020-05-14 17:42:58 +02:00
'label' => __ ( 'Filter group' ),
'name' => 'id-group-selected-select-' . $rid ,
'returnAllGroup' => true ,
'privilege' => 'AR' ,
'type' => 'select_groups' ,
'return' => true ,
'script' => $reload_content ,
]
);
$output .= html_print_input (
[
2020-11-30 14:52:03 +01:00
'input_class' => 'flex-row-vcenter' ,
'label' => __ ( 'Group recursion' ),
'name' => 'id-group-recursion-selected-select-' . $rid ,
2021-12-30 18:26:59 +01:00
'type' => 'switch' ,
2020-11-30 14:52:03 +01:00
'script' => $reload_content ,
'return' => true ,
2020-05-14 17:42:58 +02:00
]
);
$output .= '</div>' ;
$output .= '</div>' ;
}
// Filtering.
if ( isset ( $sections [ 'item-selected-filter' ]) === true
&& $sections [ 'item-selected-filter' ] === 1
) {
$output .= '<div class="item-filter flex-row-vcenter">' ;
2021-12-30 18:26:59 +01:00
$output .= '<div style="display:none">' ;
2020-05-14 17:42:58 +02:00
$output .= html_print_input (
[
'style' => 'display:none;' ,
'name' => 'tmp-selected-select-' . $rid ,
'type' => 'select' ,
'nothing' => false ,
'return' => true ,
]
);
2021-12-30 18:26:59 +01:00
$output .= '</div>' ;
2020-05-14 17:42:58 +02:00
$f = " filterSelectedItems(this.value,' " . $rid . " ',' " . __ ( 'None' ) . " ') " ;
$output .= html_print_input (
[
'label' => __ ( $texts [ 'filter-item' ]),
'name' => 'filter-item-selected-' . $rid ,
'onKeyUp' => $f ,
2020-11-30 14:52:03 +01:00
'input_class' => 'flex-row-vcenter filter w100p' ,
2020-05-14 17:42:58 +02:00
'size' => 20 ,
'type' => 'text' ,
'return' => true ,
]
);
$output .= '</div>' ;
}
}
$output .= '<span class="title">' . $texts [ 'title-right' ] . '</span>' ;
$output .= html_print_input (
[
'type' => 'select' ,
'fields' => $selected ,
'name' => 'selected-select-' . $rid . '[]' ,
'selected' => '' ,
'script' => '' ,
'nothing' => '' ,
'nothing_value' => 0 ,
'return' => true ,
'multiple' => true ,
'sort' => true ,
'class' => 'select-multiple' ,
'disabled' => false ,
'style' => false ,
'option_style' => false ,
'size' => false ,
'modal' => false ,
'message' => '' ,
'select_all' => true ,
'simple_multiple_options' => false ,
]
);
$output .= '</div>' ;
// Close main.
$output .= '</div>' ;
if ( $return === false ) {
echo $output ;
}
return $output ;
}
2020-07-07 19:10:24 +02:00
/**
* Form multiple inputs for slect groups .
*
* @ param array $data Data inputs .
*
* @ return string Html output .
*/
function html_print_select_multiple_modules_filtered ( array $data ) : string
{
if ( is_ajax () === true ) {
ui_require_javascript_file (
'multiselect_filtered' ,
'include/javascript/' ,
true
);
2021-06-07 21:19:11 +02:00
ui_require_css_file (
'multiselect_filtered' ,
'include/styles/' ,
true
);
2020-07-07 19:10:24 +02:00
} else {
ui_require_javascript_file ( 'multiselect_filtered' );
2021-06-07 21:19:11 +02:00
ui_require_css_file ( 'multiselect_filtered' );
2020-07-07 19:10:24 +02:00
}
$uniqId = $data [ 'uniqId' ];
2021-01-15 13:52:31 +01:00
$return_all_group = isset ( $data [ 'mReturnAllGroup' ]) ? $data [ 'mReturnAllGroup' ] : true ;
2020-07-07 19:10:24 +02:00
// Group.
$output = '<div>' ;
$output .= html_print_input (
[
'label' => __ ( 'Group' ),
2023-03-31 10:44:51 +02:00
'label_class' => 'font-title-font' ,
2020-07-07 19:10:24 +02:00
'name' => 'filtered-module-group-' . $uniqId ,
2021-01-15 13:52:31 +01:00
'returnAllGroup' => $return_all_group ,
2020-07-07 19:10:24 +02:00
'privilege' => 'AR' ,
'type' => 'select_groups' ,
'return' => true ,
'script' => 'fmAgentChange(\'' . $uniqId . '\')' ,
'selected' => $data [ 'mGroup' ],
]
);
// Recursion.
$output .= html_print_input (
[
2023-03-31 10:44:51 +02:00
'label' => __ ( 'Recursion' ),
'label_class' => 'font-title-font' ,
'type' => 'switch' ,
'name' => 'filtered-module-recursion-' . $uniqId ,
'value' => ( empty ( $data [ 'mRecursion' ]) === true ) ? false : true ,
'checked' => ( empty ( $data [ 'mRecursion' ]) === true ) ? false : true ,
'return' => true ,
'id' => 'filtered-module-recursion-' . $uniqId ,
'onchange' => 'fmAgentChange(\'' . $uniqId . '\')' ,
2020-07-07 19:10:24 +02:00
]
);
// Groups module.
$module_groups = db_get_all_rows_sql (
'SELECT * FROM tmodule_group ORDER BY name'
);
$module_groups = array_reduce (
$module_groups ,
function ( $carry , $item ) {
$carry [ $item [ 'id_mg' ]] = $item [ 'name' ];
return $carry ;
}
);
$output .= html_print_input (
[
'label' => __ ( 'Module group' ),
2023-03-31 10:44:51 +02:00
'label_class' => 'font-title-font' ,
2020-07-07 19:10:24 +02:00
'type' => 'select' ,
'fields' => $module_groups ,
'name' => 'filtered-module-module-group-' . $uniqId ,
'selected' => $data [ 'mModuleGroup' ],
'return' => true ,
'nothing' => __ ( 'All' ),
'nothing_value' => 0 ,
2022-01-25 20:15:40 +01:00
'script' => 'fmModuleChange(\'' . $uniqId . '\', ' . ( int ) is_metaconsole () . ')' ,
2020-07-07 19:10:24 +02:00
]
);
$output .= '</div>' ;
2022-01-25 20:15:40 +01:00
if ( empty ( $data [ 'searchBar' ]) === false && $data [ 'searchBar' ] === true ) {
$output .= '<div>' ;
$output .= '<div>' ;
$output .= html_print_input (
[
2022-01-26 11:52:49 +01:00
'type' => 'text' ,
'name' => 'agent-searchBar-' . $uniqId ,
'onKeyUp' => 'searchAgent(\'' . $uniqId . '\')' ,
'placeholder' => __ ( 'Type to search agents' ),
'return' => true ,
2022-01-25 20:15:40 +01:00
]
);
$output .= '</div>' ;
$output .= '<div>' ;
$output .= html_print_input (
[
2022-01-26 11:52:49 +01:00
'type' => 'text' ,
'name' => 'module-searchBar-' . $uniqId ,
'onKeyUp' => 'searchModule(\'' . $uniqId . '\')' ,
'return' => true ,
'placeholder' => __ ( 'Type to search modules' ),
2022-01-25 20:15:40 +01:00
]
);
$output .= '</div>' ;
$output .= '</div>' ;
}
2020-07-07 19:10:24 +02:00
$output .= '<div>' ;
// Agent.
2021-04-06 12:53:12 +02:00
$agents = agents_get_group_agents (
// Id_group.
$data [ 'mGroup' ],
// Search.
false ,
// Case.
'lower' ,
// NoACL.
false ,
// ChildGroups.
false ,
// Serialized.
false ,
// Separator.
'|' ,
// Add_alert_bulk_op.
false ,
// Force_serialized.
false ,
// Meta_fields.
2021-06-23 14:24:16 +02:00
( $data [ 'mMetaFields' ] ? ? is_metaconsole ())
2021-04-06 12:53:12 +02:00
);
2020-07-07 19:10:24 +02:00
if (( empty ( $agents )) === true || $agents == - 1 ) {
$agents = [];
}
2021-01-15 13:52:31 +01:00
if ( $data [ 'mShowSelectedOtherGroups' ]) {
$selected_agents = explode ( ',' , $data [ 'mAgents' ]);
foreach ( $selected_agents as $agent_id ) {
if ( ! array_key_exists ( $agent_id , $agents )) {
$agents [ $agent_id ] = agents_get_alias ( $agent_id );
}
}
}
2020-07-07 19:10:24 +02:00
$output .= html_print_input (
[
2023-03-31 10:44:51 +02:00
'label' => __ ( 'Agents' ),
'label_class' => 'font-title-font' ,
2023-07-18 09:34:14 +02:00
'type' => 'select_from_sql' ,
'sql' => 'SELECT `id_agente`,`nombre` FROM tagente' ,
2023-03-31 10:44:51 +02:00
'name' => 'filtered-module-agents-' . $uniqId ,
'selected' => explode ( ',' , $data [ 'mAgents' ]),
'return' => true ,
'multiple' => true ,
'style' => 'min-width: 200px;max-width:200px;' ,
'script' => 'fmModuleChange(\'' . $uniqId . '\', ' . ( int ) is_metaconsole () . ')' ,
2020-07-07 19:10:24 +02:00
]
);
2022-09-19 14:40:31 +02:00
$commonModules = 0 ;
if ( empty ( $data [ 'mShowCommonModules' ]) === false ) {
$commonModules = 1 ;
2022-02-15 17:36:00 +01:00
}
2020-07-07 19:10:24 +02:00
2022-09-19 14:40:31 +02:00
$output .= html_print_input (
[
2023-03-31 10:44:51 +02:00
'label' => __ ( 'Only common modules' ),
'label_class' => 'font-title-font' ,
'type' => 'switch' ,
'checked' => $commonModules ,
'value' => $commonModules ,
'name' => 'filtered-module-show-common-modules-' . $uniqId ,
'id' => 'filtered-module-show-common-modules-' . $uniqId ,
'return' => true ,
'onchange' => 'fmModuleChange(\'' . $uniqId . '\', ' . ( int ) is_metaconsole () . ')' ,
2022-09-19 14:40:31 +02:00
]
);
2022-05-18 12:55:10 +02:00
if ( empty ( $data [ 'mAgents' ]) === false
&& empty ( $data [ 'mModuleGroup' ] === false )
) {
2022-01-11 16:06:58 +01:00
$all_modules = get_modules_agents (
2021-06-22 15:32:15 +02:00
$data [ 'mModuleGroup' ],
explode ( ',' , $data [ 'mAgents' ]),
2022-09-19 14:40:31 +02:00
! $commonModules ,
2022-01-11 16:06:58 +01:00
false ,
true
2021-06-22 15:32:15 +02:00
);
} else {
$all_modules = [];
}
2020-07-07 19:10:24 +02:00
2022-09-19 14:40:31 +02:00
$mModules = $data [ 'mModules' ];
2022-03-17 14:48:01 +01:00
if ( is_array ( $data [ 'mModules' ]) === false ) {
2022-09-19 14:40:31 +02:00
$mModules = explode (
',' ,
$data [ 'mModules' ]
);
}
$result = [];
// Clean double safe input.
foreach ( $mModules as $name ) {
$result [] = io_safe_output ( $name );
2022-03-17 14:48:01 +01:00
}
2020-07-07 19:10:24 +02:00
$output .= html_print_input (
[
2023-03-31 10:44:51 +02:00
'label' => __ ( 'Modules' ),
'label_class' => 'font-title-font' ,
'type' => 'select' ,
'fields' => $all_modules ,
'name' => 'filtered-module-modules-' . $uniqId ,
'selected' => $result ,
'return' => true ,
'multiple' => true ,
'style' => 'min-width: 200px;max-width:200px;' ,
2020-07-07 19:10:24 +02:00
]
);
$output .= '</div>' ;
if ( $data [ 'return' ] === false ) {
echo $output ;
}
return $output ;
}
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
/**
* Prints an array of fields in a popup menu of a form based on a SQL query .
* The first and second columns of the query will be used .
2019-01-30 16:18:44 +01:00
*
2008-12-16 11:20:33 +01:00
* The element will have an id like : " password- $value " . Based on choose_from_menu () from Moodle .
2019-01-30 16:18:44 +01:00
*
* @ param string $sql SQL sentence , the first field will be the identifier of the option .
* The second field will be the shown value in the dropdown .
* @ param string $name Select form name
* @ param string $selected Current selected value .
* @ param string $script Javascript onChange code .
* @ param string $nothing Label when nothing is selected .
* @ param string $nothing_value Value when nothing is selected
* @ param boolean $return Whether to return an output string or echo now ( optional , echo by default ) .
* @ param boolean $multiple Whether to allow multiple selections or not . Single by default
* @ param boolean $sort Whether to sort the options or not . Sorted by default .
* @ param boolean $disabled if it ' s true , disable the select .
* @ param string $style The string of style .
* @ param mixed $size Max elements showed in select or default ( size = 10 )
* @ param integer $truncante_size Truncate size of the element , by default is set to GENERIC_SIZE_TEXT constant
2020-04-07 18:50:56 +02:00
* @ param integer $class Class to apply .
2020-10-26 13:37:05 +01:00
* @ param boolean $required Select is required or not .
2008-12-16 11:20:33 +01:00
*
* @ return string HTML code if return parameter is true .
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
*/
2019-01-30 16:18:44 +01:00
function html_print_select_from_sql (
$sql ,
$name ,
$selected = '' ,
$script = '' ,
$nothing = '' ,
$nothing_value = '0' ,
$return = false ,
$multiple = false ,
$sort = true ,
$disabled = false ,
$style = false ,
$size = false ,
2021-04-07 12:52:39 +02:00
$truncate_size = GENERIC_SIZE_TEXT ,
2020-10-26 13:37:05 +01:00
$class = '' ,
$required = false
2019-01-30 16:18:44 +01:00
) {
global $config ;
$fields = [];
$result = db_get_all_rows_sql ( $sql );
if ( $result === false ) {
$result = [];
}
foreach ( $result as $row ) {
$id = array_shift ( $row );
$value = array_shift ( $row );
2021-04-07 12:52:39 +02:00
$fields [ $id ] = $value ;
2019-01-30 16:18:44 +01:00
}
return html_print_select (
$fields ,
$name ,
$selected ,
$script ,
$nothing ,
$nothing_value ,
$return ,
$multiple ,
$sort ,
2020-04-07 18:50:56 +02:00
$class ,
2019-01-30 16:18:44 +01:00
$disabled ,
$style ,
'' ,
2020-10-26 13:37:05 +01:00
$size ,
// Modal.
false ,
// Message.
'' ,
// Select_all.
false ,
// Simple_multiple_options.
false ,
// Required.
2021-04-07 12:52:39 +02:00
$required ,
2022-10-27 17:31:48 +02:00
$truncate_size ,
true ,
true
2019-01-30 16:18:44 +01:00
);
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
}
2019-01-30 16:18:44 +01:00
function html_print_extended_select_for_unit (
$name ,
$selected = '' ,
$script = '' ,
$nothing = '' ,
$nothing_value = '0' ,
$size = false ,
$return = false ,
$select_style = false ,
$unique_name = true ,
$disabled = false ,
2023-07-18 09:34:14 +02:00
$no_change = 0
2019-01-30 16:18:44 +01:00
) {
global $config ;
// $fields = post_process_get_custom_values();
$fields [ '_timeticks_' ] = 'Timeticks' ;
2019-12-05 17:41:44 +01:00
$default_module_custom_units = get_custom_module_units ();
$fields = array_merge ( $fields , $default_module_custom_units );
2019-01-30 16:18:44 +01:00
if ( $no_change != 0 ) {
$fields [ - 1 ] = __ ( 'No change' );
}
// $selected_float = (float)$selected;
// $found = false;
//
// if (array_key_exists($selected, $fields))
// $found = true;
//
// if (!$found) {
// $fields[$selected] = floatval($selected);
// }
if ( $unique_name === true ) {
$uniq_name = uniqid ( $name );
} else {
$uniq_name = $name ;
}
ob_start ();
2023-07-18 09:34:14 +02:00
echo '<div id="' . $uniq_name . '_default" class="w100p inline_line">' ;
2019-01-30 16:18:44 +01:00
html_print_select (
$fields ,
$uniq_name . '_select' ,
$selected ,
'' . $script ,
$nothing ,
$nothing_value ,
false ,
false ,
false ,
'' ,
$disabled ,
'font-size: xx-small;' . $select_style
);
echo ' <a href="javascript:">' . html_print_image (
2023-02-27 16:33:46 +01:00
'images/edit.svg' ,
2019-01-30 16:18:44 +01:00
true ,
[
2023-02-27 16:33:46 +01:00
'class' => $uniq_name . '_toggler main_menu_icon invert_filter' ,
2019-01-30 16:18:44 +01:00
'alt' => __ ( 'Custom' ),
'title' => __ ( 'Custom' ),
'style' => 'width: 18px;' ,
]
) . '</a>' ;
echo '</div>' ;
2021-03-11 15:40:23 +01:00
echo '<div id="' . $uniq_name . '_manual" class="w100p inline_line">' ;
2019-01-30 16:18:44 +01:00
html_print_input_text ( $uniq_name . '_text' , $selected , '' , 20 );
html_print_input_hidden ( $name , $selected , false , $uniq_name );
echo ' <a href="javascript:">' . html_print_image (
2023-02-27 16:33:46 +01:00
'images/logs@svg.svg' ,
2019-01-30 16:18:44 +01:00
true ,
[
2023-02-27 16:33:46 +01:00
'class' => $uniq_name . '_toggler main_menu_icon invert_filter' ,
2019-01-30 16:18:44 +01:00
'alt' => __ ( 'List' ),
'title' => __ ( 'List' ),
'style' => 'width: 18px;' ,
]
) . '</a>' ;
echo '</div>' ;
echo " <script type='text/javascript'>
2017-09-14 12:10:41 +02:00
$ ( document ) . ready ( function () {
post_process_select_init_unit ( '$uniq_name' , '$selected' );
post_process_select_events_unit ( '$uniq_name' , '$selected' );
});
</ script > " ;
2018-07-31 15:25:44 +02:00
2019-01-30 16:18:44 +01:00
$returnString = ob_get_clean ();
2018-07-31 15:25:44 +02:00
2019-01-30 16:18:44 +01:00
if ( $return ) {
return $returnString ;
} else {
echo $returnString ;
}
}
2017-06-30 14:18:23 +02:00
2018-07-31 15:25:44 +02:00
2019-01-30 16:18:44 +01:00
function html_print_extended_select_for_post_process (
$name ,
$selected = '' ,
$script = '' ,
$nothing = '' ,
$nothing_value = '0' ,
$size = false ,
$return = false ,
$select_style = false ,
$unique_name = true ,
$disabled = false ,
$no_change = 0
) {
global $config ;
include_once $config [ 'homedir' ] . '/include/functions_post_process.php' ;
$fields = post_process_get_custom_values ();
if ( $no_change != 0 ) {
$fields [ - 1 ] = __ ( 'No change' );
}
$selected_float = ( float ) $selected ;
$found = false ;
if ( $selected ) {
2022-10-26 18:25:16 +02:00
if ( array_key_exists ( number_format ( $selected , 14 , $config [ 'decimal_separator' ], $config [ 'thousand_separator' ]), $fields )) {
2019-01-30 16:18:44 +01:00
$found = true ;
}
}
if ( ! $found ) {
$fields [ $selected ] = floatval ( $selected );
}
if ( $unique_name === true ) {
$uniq_name = uniqid ( $name );
} else {
$uniq_name = $name ;
}
2021-09-20 12:16:08 +02:00
$style = 'font-size: xx-small;' ;
if ( $select_style !== false ) {
$style .= sprintf ( ' %s' , $select_style );
}
2019-01-30 16:18:44 +01:00
ob_start ();
2021-03-11 15:40:23 +01:00
echo '<div id="' . $uniq_name . '_default" style="w100p inline_line">' ;
2019-01-30 16:18:44 +01:00
html_print_select (
$fields ,
$uniq_name . '_select' ,
$selected ,
'' . $script ,
$nothing ,
$nothing_value ,
false ,
false ,
false ,
'' ,
$disabled ,
2021-09-20 12:16:08 +02:00
$style
2019-01-30 16:18:44 +01:00
);
echo ' <a href="javascript:">' . html_print_image (
2023-02-27 16:33:46 +01:00
'images/edit.svg' ,
2019-01-30 16:18:44 +01:00
true ,
[
2023-02-27 16:33:46 +01:00
'class' => $uniq_name . '_toggler main_menu_icon invert_filter' ,
2019-01-30 16:18:44 +01:00
'alt' => __ ( 'Custom' ),
'title' => __ ( 'Custom' ),
'style' => 'width: 18px;' ,
]
) . '</a>' ;
echo '</div>' ;
2021-03-11 15:40:23 +01:00
echo '<div id="' . $uniq_name . '_manual" style="w100p inline_line">' ;
2019-01-30 16:18:44 +01:00
html_print_input_text ( $uniq_name . '_text' , $selected , '' , 20 );
html_print_input_hidden ( $name , $selected , false , $uniq_name );
echo ' <a href="javascript:">' . html_print_image (
2023-02-27 16:33:46 +01:00
'images/logs@svg.svg' ,
2019-01-30 16:18:44 +01:00
true ,
[
2023-02-27 16:33:46 +01:00
'class' => $uniq_name . '_toggler main_menu_icon invert_filter' ,
2019-01-30 16:18:44 +01:00
'alt' => __ ( 'List' ),
'title' => __ ( 'List' ),
'style' => 'width: 18px;' ,
]
) . '</a>' ;
echo '</div>' ;
echo " <script type='text/javascript'>
2015-02-09 19:34:36 +01:00
$ ( document ) . ready ( function () {
post_process_select_init ( '$uniq_name' );
post_process_select_events ( '$uniq_name' );
});
2018-07-31 15:25:44 +02:00
2015-02-09 19:34:36 +01:00
</ script > " ;
2018-07-31 15:25:44 +02:00
2019-01-30 16:18:44 +01:00
$returnString = ob_get_clean ();
2018-07-31 15:25:44 +02:00
2019-01-30 16:18:44 +01:00
if ( $return ) {
return $returnString ;
} else {
echo $returnString ;
}
2015-02-09 19:34:36 +01:00
}
2019-01-30 16:18:44 +01:00
2009-10-06 20:50:48 +02:00
/**
* Render a pair of select for times and text box for set the time more fine .
2019-01-30 16:18:44 +01:00
*
2021-09-20 12:16:08 +02:00
* @ param string $name Select form name .
* @ param mixed $selected Current selected value . Can be a single value or an array of selected values ( in combination with multiple ) .
2020-01-16 13:50:39 +01:00
* @ param string $script Javascript onChange ( select ) code .
* @ param string $nothing Label when nothing is selected .
2021-09-20 12:16:08 +02:00
* @ param mixed $nothing_value Value when nothing is selected .
2020-01-16 13:50:39 +01:00
* @ param integer $size Size of the input .
* @ param boolean $return Whether to return an output string or echo now ( optional , echo by default ) .
2021-09-20 12:16:08 +02:00
* @ param boolean $select_style Wherter to assign to combo a unique name ( to have more than one on same page , like dashboard ) .
* @ param boolean $unique_name Uunique name value .
* @ param string $class Class value .
* @ param boolean $readonly Readonly value .
* @ param string $custom_fields Custom fields value .
* @ param string $style_icon Style icon value .
* @ param boolean $no_change No change value .
2020-01-16 13:50:39 +01:00
* @ param boolean $allow_zero Allow the use of the value zero .
2009-10-06 20:50:48 +02:00
* @ return string HTML code if return parameter is true .
*/
2019-01-30 16:18:44 +01:00
function html_print_extended_select_for_time (
$name ,
$selected = '' ,
$script = '' ,
$nothing = '' ,
$nothing_value = '0' ,
$size = false ,
$return = false ,
$select_style = false ,
$unique_name = true ,
$class = '' ,
$readonly = false ,
$custom_fields = false ,
$style_icon = '' ,
2020-01-16 13:50:39 +01:00
$no_change = false ,
2023-07-10 16:26:33 +02:00
$allow_zero = 0 ,
$units = null
2019-01-30 16:18:44 +01:00
) {
global $config ;
$admin = is_user_admin ( $config [ 'id_user' ]);
if ( $custom_fields ) {
$fields = $custom_fields ;
} else {
2020-01-16 13:50:39 +01:00
$fields = get_periods ( true , true , $allow_zero );
2019-01-30 16:18:44 +01:00
}
if ( $no_change ) {
$fields [ '-2' ] = __ ( 'No change' );
}
2022-09-28 15:02:11 +02:00
if ( empty ( $selected ) === false
&& $selected !== '0'
&& isset ( $fields [ $selected ]) === false
) {
$allow_zero = false ;
$fields [ $selected ] = human_time_description_raw ( $selected , true );
2020-01-16 13:50:39 +01:00
}
2023-04-03 10:00:08 +02:00
if ( empty ( $nothing ) === true && ( is_int ( $selected ) === true )) {
2022-09-28 15:02:11 +02:00
$selected = 300 ;
2019-01-30 16:18:44 +01:00
}
2023-07-10 16:26:33 +02:00
if ( empty ( $units ) === true ) {
$units = [
1 => __ ( 'seconds' ),
SECONDS_1MINUTE => __ ( 'minutes' ),
SECONDS_1HOUR => __ ( 'hours' ),
SECONDS_1DAY => __ ( 'days' ),
SECONDS_1WEEK => __ ( 'weeks' ),
SECONDS_1MONTH => __ ( 'months' ),
SECONDS_1YEAR => __ ( 'years' ),
];
}
2019-01-30 16:18:44 +01:00
if ( $unique_name === true ) {
$uniq_name = uniqid ( $name );
} else {
$uniq_name = $name ;
}
if ( $readonly ) {
$readonly = true ;
}
ob_start ();
2020-05-26 11:26:49 +02:00
// Use the no_meta parameter because this image is only in the base console.
2021-07-07 12:09:47 +02:00
echo '<div id="' . $uniq_name . '_default" class="wauto inline_flex">' ;
2022-11-15 08:05:04 +01:00
html_print_select (
$fields ,
$uniq_name . '_select' ,
$selected ,
'' . $script ,
$nothing ,
$nothing_value ,
false ,
false ,
2023-08-09 12:47:51 +02:00
true ,
2022-11-15 08:05:04 +01:00
$class ,
$readonly ,
'font-size: xx-small;' . $select_style
);
2020-05-26 11:26:49 +02:00
// The advanced control is only for admins.
2022-11-15 08:05:04 +01:00
if ( $admin === true ) {
html_print_anchor (
2019-01-30 16:18:44 +01:00
[
2022-11-15 08:05:04 +01:00
'href' => 'javascript:' ,
'content' => html_print_image (
2023-02-27 16:33:46 +01:00
'images/edit.svg' ,
2022-11-15 08:05:04 +01:00
true ,
[
2023-02-27 16:33:46 +01:00
'class' => $uniq_name . '_toggler ' . $class . ' main_menu_icon invert_filter' ,
2022-11-15 08:05:04 +01:00
'alt' => __ ( 'Custom' ),
'title' => __ ( 'Custom' ),
2023-02-22 10:33:45 +01:00
'style' => 'width: 18px; margin-bottom: -5px; margin-left: 10px; padding-top: 10px;' . $style_icon ,
2022-11-15 08:05:04 +01:00
],
false ,
false ,
true ,
),
]
);
2019-01-30 16:18:44 +01:00
}
echo '</div>' ;
2023-02-22 10:33:45 +01:00
echo '<div id="' . $uniq_name . '_manual" class="w100p inline_flex">' ;
2019-01-30 16:18:44 +01:00
html_print_input_text ( $uniq_name . '_text' , $selected , '' , $size , 255 , false , $readonly , false , '' , $class );
html_print_input_hidden ( $name , $selected , false , $uniq_name );
html_print_select (
$units ,
$uniq_name . '_units' ,
2021-07-13 11:38:46 +02:00
'1' ,
2019-01-30 16:18:44 +01:00
'' . $script ,
2022-09-28 15:02:11 +02:00
'' ,
0 ,
2019-01-30 16:18:44 +01:00
false ,
false ,
false ,
$class ,
$readonly ,
2023-02-22 10:33:45 +01:00
' margin-left: 5px; width: 140px;' . $select_style ,
2022-09-28 15:02:11 +02:00
false ,
false ,
false ,
'' ,
false ,
false ,
false ,
false ,
false
2019-01-30 16:18:44 +01:00
);
echo ' <a href="javascript:">' . html_print_image (
2023-02-27 16:33:46 +01:00
'images/logs@svg.svg' ,
2019-01-30 16:18:44 +01:00
true ,
[
2023-02-27 16:33:46 +01:00
'class' => $uniq_name . '_toggler main_menu_icon invert_filter' ,
2019-01-30 16:18:44 +01:00
'alt' => __ ( 'List' ),
'title' => __ ( 'List' ),
2023-02-22 10:33:45 +01:00
'style' => 'width: 18px;margin-bottom: -5px; padding-top: 10px;' . $style_icon ,
2019-01-30 16:18:44 +01:00
]
) . '</a>' ;
echo '</div>' ;
echo " <script type='text/javascript'>
2012-03-16 10:23:09 +01:00
$ ( document ) . ready ( function () {
2022-09-28 15:02:11 +02:00
period_select_init ( '".$uniq_name."' , " .(( $allow_zero ) ? 1 : 0). " );
2020-05-26 11:26:49 +02:00
period_select_events ( '".$uniq_name."' );
2012-03-16 10:23:09 +01:00
});
2012-07-05 11:16:57 +02:00
function period_select_ " . $name . " _update ( seconds ) {
$ ( '#text-".$uniq_name."_text' ) . val ( seconds );
adjustTextUnits ( '".$uniq_name."' );
calculateSeconds ( '".$uniq_name."' );
2020-05-26 11:26:49 +02:00
$ ( '#".$uniq_name."_manual' ) . show ();
$ ( '#".$uniq_name."_default' ) . hide ();
2012-07-05 11:16:57 +02:00
}
2023-04-03 10:00:08 +02:00
if ( $ ( '#text-".$uniq_name."_text' ) . val () === '0' ) {
setTimeout (() => {
$ ( '#".$uniq_name."_manual' ) . hide ();
$ ( '#".$uniq_name."_default' ) . show ();
}, 100 );
}
2012-07-05 11:16:57 +02:00
</ script > " ;
2019-01-30 16:18:44 +01:00
$returnString = ob_get_clean ();
if ( $return ) {
return $returnString ;
} else {
echo $returnString ;
}
2009-10-06 20:50:48 +02:00
}
2019-01-30 16:18:44 +01:00
2012-10-23 Ramon Novoa <rnovoa@artica.es>
* include/functions_cron.php: Added to repository. Cron related
functions.
* include/functions_html.php, pandoradb.sql,
pandoradb.postgreSQL.sql, pandoradb.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
godmode/agentes/module_manager_editor_common.php,
godmode/agentes/configurar_agente.php,
godmode/agentes/module_manager_editor.php: Added support for remote
cron modules.
* godmode/netflow/nf_item_list.php,
godmode/netflow/nf_report_item.php,
operation/netflow/nf_view.php,
include/functions_netflow.php: Added a description to report items.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7083 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-10-23 12:45:25 +02:00
/**
* Print selects to configure the cron of a module .
2019-01-30 16:18:44 +01:00
*
2021-09-20 12:16:08 +02:00
* @ param string $hour Run hour .
* @ param string $minute Run minute .
* @ param string $mday Run day of the month .
* @ param string $month Run month .
* @ param string $wday Run day of the week .
* @ param boolean $return Whether to return an output string or echo now ( optional , echo by default ) .
* @ param boolean $disabled If true , the control will show disabled .
* @ param boolean $to Print cron grayed .
2019-01-30 16:18:44 +01:00
*
2012-10-23 Ramon Novoa <rnovoa@artica.es>
* include/functions_cron.php: Added to repository. Cron related
functions.
* include/functions_html.php, pandoradb.sql,
pandoradb.postgreSQL.sql, pandoradb.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
godmode/agentes/module_manager_editor_common.php,
godmode/agentes/configurar_agente.php,
godmode/agentes/module_manager_editor.php: Added support for remote
cron modules.
* godmode/netflow/nf_item_list.php,
godmode/netflow/nf_report_item.php,
operation/netflow/nf_view.php,
include/functions_netflow.php: Added a description to report items.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7083 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-10-23 12:45:25 +02:00
* @ return string HTML code if return parameter is true .
*/
2022-08-16 18:42:51 +02:00
function html_print_extended_select_for_cron ( $hour = '*' , $minute = '*' , $mday = '*' , $month = '*' , $wday = '*' , $return = false , $disabled = false , $to = false , $advanced = false , $adv_mode_name = '' )
2019-01-30 16:18:44 +01:00
{
2022-12-05 13:39:51 +01:00
// Hours.
2019-01-30 16:18:44 +01:00
for ( $i = 0 ; $i < 24 ; $i ++ ) {
$hours [ $i ] = $i ;
}
2022-12-05 13:39:51 +01:00
// Minutes.
2019-11-18 15:28:34 +01:00
for ( $i = 0 ; $i < 60 ; $i ++ ) {
2019-01-30 16:18:44 +01:00
$minutes [ $i ] = $i ;
2019-11-18 15:28:34 +01:00
// If minute is not a multiple of 5, then add style to option in order to hide it from minute select but still is a valid value that input can adopt. We want this in case a value that is not a multiple of 5 is entered in module's data configuration.
2022-12-05 13:39:51 +01:00
if (( $i % 5 ) !== 0 ) {
2019-11-18 15:28:34 +01:00
$minutes_hidden_options [ $i ] = 'display: none;' ;
}
2019-01-30 16:18:44 +01:00
}
2022-12-05 13:39:51 +01:00
// Month days.
2019-11-20 17:20:17 +01:00
for ( $i = 1 ; $i <= 31 ; $i ++ ) {
2019-01-30 16:18:44 +01:00
$mdays [ $i ] = $i ;
}
2022-12-05 13:39:51 +01:00
// Months.
2019-01-30 16:18:44 +01:00
for ( $i = 1 ; $i <= 12 ; $i ++ ) {
$months [ $i ] = date ( 'F' , mktime ( 0 , 0 , 0 , $i , 1 ));
}
2022-12-05 13:39:51 +01:00
// Days of the week.
2019-01-30 16:18:44 +01:00
$wdays = [
__ ( 'Sunday' ),
__ ( 'Monday' ),
__ ( 'Tuesday' ),
__ ( 'Wednesday' ),
__ ( 'Thursday' ),
__ ( 'Friday' ),
__ ( 'Saturday' ),
];
2022-12-05 13:39:51 +01:00
// Print selectors.
2019-01-30 16:18:44 +01:00
$table = new stdClass ();
$table -> id = 'cron' ;
$table -> width = '100%' ;
2022-12-19 15:08:53 +01:00
$table -> class = 'cron_section' ;
2022-12-05 13:39:51 +01:00
$table -> style = [];
$table -> style [ 0 ] = 'width: 20%;' ;
$table -> style [ 1 ] = 'width: 20%;' ;
$table -> style [ 2 ] = 'width: 20%;' ;
$table -> style [ 3 ] = 'width: 20%;' ;
$table -> style [ 4 ] = 'width: 20%;' ;
$table -> data [ 0 ][ 0 ] = __ ( 'Hour' );
$table -> data [ 0 ][ 1 ] = __ ( 'Minute' );
$table -> data [ 0 ][ 2 ] = __ ( 'Month day' );
$table -> data [ 0 ][ 3 ] = __ ( 'Month' );
$table -> data [ 0 ][ 4 ] = __ ( 'Week day' );
2019-01-30 16:18:44 +01:00
2022-08-16 18:42:51 +02:00
if ( $advanced === false ) {
2022-12-05 13:39:51 +01:00
if ( $to === true ) {
$table -> data [ 1 ][ 0 ] = html_print_select ( $hours , 'hour_to' , $hour , '' , __ ( 'Any' ), '*' , true , false , false , '' , $disabled );
$table -> data [ 1 ][ 1 ] = html_print_select ( $minutes , 'minute_to' , $minute , '' , __ ( 'Any' ), '*' , true , false , false , '' , $disabled , false , $minutes_hidden_options );
$table -> data [ 1 ][ 2 ] = html_print_select ( $mdays , 'mday_to' , $mday , '' , __ ( 'Any' ), '*' , true , false , false , '' , $disabled );
$table -> data [ 1 ][ 3 ] = html_print_select ( $months , 'month_to' , $month , '' , __ ( 'Any' ), '*' , true , false , false , '' , $disabled );
$table -> data [ 1 ][ 4 ] = html_print_select ( $wdays , 'wday_to' , $wday , '' , __ ( 'Any' ), '*' , true , false , false , '' , $disabled );
2022-08-16 18:42:51 +02:00
} else {
2022-12-05 13:39:51 +01:00
$table -> data [ 1 ][ 0 ] = html_print_select ( $hours , 'hour_from' , $hour , '' , __ ( 'Any' ), '*' , true , false , false , '' , $disabled );
$table -> data [ 1 ][ 1 ] = html_print_select ( $minutes , 'minute_from' , $minute , '' , __ ( 'Any' ), '*' , true , false , false , '' , $disabled , false , $minutes_hidden_options );
$table -> data [ 1 ][ 2 ] = html_print_select ( $mdays , 'mday_from' , $mday , '' , __ ( 'Any' ), '*' , true , false , false , '' , $disabled );
$table -> data [ 1 ][ 3 ] = html_print_select ( $months , 'month_from' , $month , '' , __ ( 'Any' ), '*' , true , false , false , '' , $disabled );
$table -> data [ 1 ][ 4 ] = html_print_select ( $wdays , 'wday_from' , $wday , '' , __ ( 'Any' ), '*' , true , false , false , '' , $disabled );
2022-08-16 18:42:51 +02:00
}
2019-01-30 16:18:44 +01:00
} else {
2022-08-16 18:42:51 +02:00
if ( $adv_mode_name !== '' ) {
$adv_mode_name = '_' . $adv_mode_name ;
}
2023-03-08 15:01:41 +01:00
$table -> data [ 1 ][ 0 ] = html_print_div (
[
'class' => '' ,
'content' => html_print_extended_select_for_downtime_cron (
'cron_hour' . $adv_mode_name ,
$hours ,
$hour ,
'' ,
__ ( 'Any' ),
'*' ,
false ,
true ,
false ,
false ,
false ,
0 ,
'Valid values: [0-23], [0-23]-[0-23], *, or step value (example: */3, 10/5)'
),
],
true
2022-08-16 18:42:51 +02:00
);
2023-03-08 15:01:41 +01:00
$table -> data [ 1 ][ 1 ] = html_print_div (
[
'class' => '' ,
'content' => html_print_extended_select_for_downtime_cron (
'cron_minute' . $adv_mode_name ,
$minutes ,
$minute ,
'' ,
__ ( 'Any' ),
'*' ,
false ,
true ,
false ,
false ,
false ,
0 ,
'Valid values: [0-59], [0-59]-[0-59], *, or step value (example: */5, 10/1)'
),
],
true
2022-08-16 18:42:51 +02:00
);
2023-03-08 15:01:41 +01:00
$table -> data [ 1 ][ 2 ] = html_print_div (
[
'class' => '' ,
'content' => html_print_extended_select_for_downtime_cron (
'cron_mday' . $adv_mode_name ,
$mdays ,
$mday ,
'' ,
__ ( 'Any' ),
'*' ,
false ,
true ,
false ,
false ,
false ,
0 ,
'Valid values: [1-31], [1-31]-[1-31], *, or step value (example: */5, 7/2)'
),
],
true
2022-08-16 18:42:51 +02:00
);
2023-03-08 15:01:41 +01:00
$table -> data [ 1 ][ 3 ] = html_print_div (
[
'class' => '' ,
'content' => html_print_extended_select_for_downtime_cron (
'cron_month' . $adv_mode_name ,
$months ,
$month ,
'' ,
__ ( 'Any' ),
'*' ,
false ,
true ,
false ,
false ,
false ,
0 ,
'Valid values: [1-12], [1-12]-[1-12], *, or step value (example: */3, 9/1)'
),
],
true
2022-08-16 18:42:51 +02:00
);
2023-03-08 15:01:41 +01:00
$table -> data [ 1 ][ 4 ] = html_print_div (
[
'class' => '' ,
'content' => html_print_extended_select_for_downtime_cron (
'cron_wday' . $adv_mode_name ,
$wdays ,
$wday ,
'' ,
__ ( 'Any' ),
'*' ,
false ,
true ,
false ,
false ,
false ,
0 ,
'Valid values: [0-6], [0-6]-[0-6], *, or step value (example: */2, 3/1)'
),
],
true
2022-08-16 18:42:51 +02:00
);
2019-01-30 16:18:44 +01:00
}
return html_print_table ( $table , $return );
2012-10-23 Ramon Novoa <rnovoa@artica.es>
* include/functions_cron.php: Added to repository. Cron related
functions.
* include/functions_html.php, pandoradb.sql,
pandoradb.postgreSQL.sql, pandoradb.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
godmode/agentes/module_manager_editor_common.php,
godmode/agentes/configurar_agente.php,
godmode/agentes/module_manager_editor.php: Added support for remote
cron modules.
* godmode/netflow/nf_item_list.php,
godmode/netflow/nf_report_item.php,
operation/netflow/nf_view.php,
include/functions_netflow.php: Added a description to report items.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7083 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-10-23 12:45:25 +02:00
}
2019-01-30 16:18:44 +01:00
2020-06-22 14:06:13 +02:00
/**
* Prints an input slide .
*
* @ param string $name Name .
* @ param integer $value Value .
* @ param string $id Id .
* @ param boolean $return Return .
* @ param integer $min Min .
* @ param integer $max Max .
* @ param integer $step Step .
* @ param string $class Class .
* @ param string $oninput Oninput .
*
* @ return string HTML code for input .
*/
function html_print_input_range (
$name ,
$value ,
$id = '' ,
$return = true ,
$min = 0 ,
$max = 100 ,
$step = 1 ,
$class = '' ,
$oninput = ''
) {
$output = '<input type="range" ' ;
if ( isset ( $value ) === true ) {
$output .= ' value="' . $value . '" ' ;
}
2020-07-07 11:54:55 +02:00
$output .= ' name="' . $name . '" ' ;
2020-06-22 14:06:13 +02:00
$output .= ' id="' . $id . '" ' ;
$output .= ' min="' . $min . '" ' ;
$output .= ' max="' . $max . '" ' ;
$output .= ' step="' . $step . '" ' ;
$output .= ' class="' . $class . '" ' ;
$output .= ' oninput="' . $oninput . '" ' ;
$output .= ' />' ;
2020-07-07 11:54:55 +02:00
if ( $return === false ) {
echo $return ;
}
2020-06-22 14:06:13 +02:00
return $output ;
}
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
/**
2011-04-27 15:43:31 +02:00
* Render an input text element . Extended version , use html_print_input_text () to simplify .
2019-01-30 16:18:44 +01:00
*
* @ param string $name Input name .
* @ param string $value Input value .
* @ param string $id Input HTML id .
* @ param string $alt Do not use , invalid for text and password . Use html_print_input_image
* @ param integer $size Size of the input .
* @ param integer $maxlength Maximum length allowed .
* @ param boolean $disabled Disable the button ( optional , button enabled by default ) .
* @ param mixed $script JavaScript to attach to this . It is array the index is event to set a script , it is only string for " onkeyup " event .
* @ param mixed $attributes Attributes to add to this tag . Should be an array for correction .
* @ param boolean $return Whether to return an output string or echo now ( optional , echo by default ) .
* @ param boolean $password Whether it is a password input or not . Not password by default .
2008-12-16 11:20:33 +01:00
*
* @ return string HTML code if return parameter is true .
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
*/
2020-03-26 12:29:38 +01:00
function html_print_input_text_extended (
$name ,
$value ,
$id ,
$alt ,
$size ,
$maxlength ,
2020-07-13 12:23:46 +02:00
$readonly ,
2020-03-26 12:29:38 +01:00
$script ,
$attributes ,
$return = false ,
$password = false ,
$function = '' ,
2020-07-13 12:23:46 +02:00
$autocomplete = 'off' ,
2023-03-02 17:08:47 +01:00
$disabled = false ,
$hide_div_eye = false ,
2020-03-26 12:29:38 +01:00
) {
2023-02-20 11:49:54 +01:00
global $config ;
2019-01-30 16:18:44 +01:00
static $idcounter = 0 ;
2022-12-07 18:16:47 +01:00
if ( $maxlength === 0 ) {
2019-01-30 16:18:44 +01:00
$maxlength = 255 ;
}
2019-06-07 17:35:13 +02:00
if ( $size === false ) {
$size = '' ;
2022-12-07 18:16:47 +01:00
} else if ( $size === - 1 ) {
2019-01-30 16:18:44 +01:00
$size = 10 ;
}
++ $idcounter ;
$valid_attrs = [
'accept' ,
2020-03-26 12:29:38 +01:00
'autofocus' ,
2019-01-30 16:18:44 +01:00
'disabled' ,
'maxlength' ,
'name' ,
'readonly' ,
'placeholder' ,
'size' ,
'value' ,
'accesskey' ,
'class' ,
'dir' ,
'id' ,
'lang' ,
'style' ,
'tabindex' ,
'title' ,
'xml:lang' ,
'onfocus' ,
'onblur' ,
'onselect' ,
'onchange' ,
'onclick' ,
'ondblclick' ,
'onmousedown' ,
'onmouseup' ,
'onmouseover' ,
'onmousemove' ,
'onmouseout' ,
'onkeypress' ,
'onkeydown' ,
'onkeyup' ,
'required' ,
'autocomplete' ,
2020-04-13 15:41:00 +02:00
'form' ,
2020-10-30 13:25:33 +01:00
'list' ,
2022-01-26 12:52:36 +01:00
'pattern' ,
2019-01-30 16:18:44 +01:00
];
2021-02-01 13:54:57 +01:00
$output = '<input ' . ( $password ? 'type="password" autocomplete="' . $autocomplete . '" ' : 'type="text" autocomplete="' . $autocomplete . '"' );
2019-01-30 16:18:44 +01:00
2020-07-13 12:23:46 +02:00
if ( $readonly && ( ! is_array ( $attributes ) || ! array_key_exists ( 'readonly' , $attributes ))) {
2019-01-30 16:18:44 +01:00
$output .= 'readonly="readonly" ' ;
}
2020-07-13 12:23:46 +02:00
if ( $disabled && ( ! is_array ( $attributes ) || ! array_key_exists ( 'disabled' , $attributes ))) {
$output .= 'disabled="disabled" ' ;
}
2023-02-20 11:49:54 +01:00
$hasClass = false ;
2019-01-30 16:18:44 +01:00
if ( is_array ( $attributes )) {
foreach ( $attributes as $attribute => $attr_value ) {
2023-02-20 11:49:54 +01:00
if ( in_array ( $attribute , $valid_attrs ) === false ) {
2019-01-30 16:18:44 +01:00
continue ;
}
2023-02-20 11:49:54 +01:00
// Only for password inputs.
2023-03-02 17:08:47 +01:00
if (( $attribute === 'class' ) && ( $password === true ) && ( $hide_div_eye === false )) {
2023-02-20 11:49:54 +01:00
$attr_value .= ' show-hide-pass-background' ;
$hasClass = true ;
}
2019-01-30 16:18:44 +01:00
$output .= $attribute . '="' . $attr_value . '" ' ;
}
} else {
$output .= trim ( $attributes ) . ' ' ;
$attributes = [];
}
2023-03-02 17:08:47 +01:00
if (( $hasClass === false ) && ( $password === true ) && ( $hide_div_eye === false )) {
2023-02-20 11:49:54 +01:00
$output .= 'class="show-hide-pass-background" ' ;
}
2019-01-30 16:18:44 +01:00
if ( ! empty ( $alt )) {
$output .= 'alt="' . $alt . '" ' ;
}
2023-03-03 12:40:58 +01:00
if ( $hide_div_eye !== false ) {
echo " <script>
$ ( document ) . ready ( function () {
$ ( 'input[name=\"".$name."\"]' ) . val ( \ " " . $value . " \" )
observerInputPassword ( '".$name."' );
});
</ script > " ;
$value = '' ;
}
2020-03-26 12:29:38 +01:00
// Attributes specified by function call.
2019-01-30 16:18:44 +01:00
$attrs = [
'name' => 'unnamed' ,
'value' => '' ,
'id' => 'text-' . sprintf ( '%04d' , $idcounter ),
'size' => '' ,
'maxlength' => '' ,
];
foreach ( $attrs as $attribute => $default ) {
if ( array_key_exists ( $attribute , $attributes )) {
continue ;
} //end if
/*
* Remember , this next code have a $ $ that for example there is a var as
* $a = 'john' then $$a is a var $john .
*
* In this case is use for example for $name and $atribute = 'name' .
*
*/
// Exact operator because we want to show "0" on the value
if ( $attribute !== '' ) {
$output .= $attribute . '="' . $$attribute . '" ' ;
} else if ( $default != '' ) {
$output .= $attribute . '="' . $default . '" ' ;
}
}
if ( ! empty ( $script )) {
if ( is_string ( $script )) {
$code = $script ;
$script = [];
$script [ 'onkeyup' ] = $code ;
}
foreach ( $script as $event => $code ) {
$output .= ' ' . $event . '="' . $code . '" ' ;
}
}
$output .= $function . '/>' ;
2023-03-02 17:08:47 +01:00
if ( $password === true && $hide_div_eye === false ) {
2023-02-20 11:49:54 +01:00
$output .= html_print_div (
[
'id' => 'show-hide-' . $id ,
'class' => 'show-hide-pass' ,
'onClick' => 'show_hide_password(event, \'' . $config [ 'homeurl' ] . '\')' ,
],
true
);
}
2019-01-30 16:18:44 +01:00
if ( ! $return ) {
echo $output ;
}
return $output ;
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
}
2019-01-30 16:18:44 +01:00
2013-02-26 17:10:02 +01:00
/**
2021-03-24 12:45:25 +01:00
* Render a section < div > html element .
2013-02-26 17:10:02 +01:00
*
2021-03-24 12:45:25 +01:00
* @ param array $options Parameters :
2019-01-30 16:18:44 +01:00
* - id : string
* - style : string
2021-03-24 12:45:25 +01:00
* - class : string
* - title : string
2019-01-30 16:18:44 +01:00
* - hidden : boolean
2021-03-24 12:45:25 +01:00
* - content : string .
* @ param boolean $return Return or echo flag .
2013-02-26 17:10:02 +01:00
*
* @ return string HTML code if return parameter is true .
*/
2021-03-24 12:45:25 +01:00
function html_print_div (
array $options ,
bool $return = false
) {
2019-01-30 16:18:44 +01:00
$output = '<div' ;
2021-03-24 12:45:25 +01:00
// Valid attributes (invalid attributes get skipped).
2019-01-30 16:18:44 +01:00
$attrs = [
'id' ,
'style' ,
'class' ,
2020-06-30 12:16:51 +02:00
'title' ,
2023-02-20 11:49:54 +01:00
'onClick' ,
2019-01-30 16:18:44 +01:00
];
2023-02-20 11:49:54 +01:00
if ( isset ( $options [ 'hidden' ]) === true ) {
if ( isset ( $options [ 'style' ]) === true ) {
2019-01-30 16:18:44 +01:00
$options [ 'style' ] .= 'display:none;' ;
} else {
$options [ 'style' ] = 'display:none;' ;
}
}
foreach ( $attrs as $attribute ) {
2023-02-20 11:49:54 +01:00
if ( isset ( $options [ $attribute ]) === true ) {
2019-01-30 16:18:44 +01:00
$output .= ' ' . $attribute . '="' . io_safe_input_html ( $options [ $attribute ]) . '"' ;
}
}
$output .= '>' ;
$output .= isset ( $options [ 'content' ]) ? $options [ 'content' ] : '' ;
$output .= '</div>' ;
2023-02-20 11:49:54 +01:00
if ( $return === true ) {
2019-01-30 16:18:44 +01:00
return $output ;
} else {
echo $output ;
}
2013-02-26 17:10:02 +01:00
}
2022-01-05 11:08:49 +01:00
/**
* Render an < pre > tag for show code .
* For debug purposes , see for `hd()` function .
*
* @ param string $content Content of tag .
* @ param boolean $return Return the tag string formed .
* @ param array $attributes Attributes availables for pre tags .
*
* @ return string
*/
function html_print_code (
string $content ,
bool $return = true ,
array $attributes = []
) {
$output = '<pre' ;
if ( empty ( $attributes ) === false ) {
foreach ( $attributes as $attribute => $value ) {
$output .= ' ' . $attribute . '="' . io_safe_input_html ( $value ) . '"' ;
}
}
$output .= sprintf ( '>%s</pre>' , $content );
if ( $return === true ) {
return $output ;
} else {
echo $output ;
}
}
2020-11-06 12:38:06 +01:00
/**
2021-03-24 12:45:25 +01:00
* Render an anchor < a > html element .
2020-11-06 12:38:06 +01:00
*
2021-06-29 14:55:03 +02:00
* @ param array $options Parameters .
2021-03-24 12:45:25 +01:00
* - id : string .
* - style : string .
* - title : string .
2020-11-06 12:38:06 +01:00
* - href : string .
2021-03-24 12:45:25 +01:00
* - content : string .
2021-06-29 14:55:03 +02:00
* - onClick : string .
2020-11-06 12:38:06 +01:00
* @ param boolean $return Return or echo flag .
*
* @ return string HTML code if return parameter is true .
*/
function html_print_anchor (
array $options ,
bool $return = false
) {
$output = '<a ' ;
// Valid attributes (invalid attributes get skipped).
$attrs = [
'id' ,
'style' ,
'class' ,
'title' ,
2021-06-29 14:55:03 +02:00
'onClick' ,
2020-11-06 12:38:06 +01:00
];
$output .= ( isset ( $options [ 'href' ]) === true ) ? 'href="' . io_safe_input_html ( $options [ 'href' ]) . '"' : ui_get_full_url ();
foreach ( $attrs as $attribute ) {
2022-12-15 12:42:35 +01:00
if ( isset ( $options [ $attribute ]) === true && empty ( $options [ $attribute ]) === false ) {
2020-11-06 12:38:06 +01:00
$output .= ' ' . $attribute . '="' . io_safe_input_html ( $options [ $attribute ]) . '"' ;
}
}
$output .= '>' ;
2023-07-03 09:18:30 +02:00
$output .= ( isset ( $options [ 'text' ]) === true ) ? $options [ 'text' ] : '' ;
2020-11-06 12:38:06 +01:00
$output .= ( isset ( $options [ 'content' ]) === true ) ? io_safe_input_html ( $options [ 'content' ]) : '' ;
$output .= '</a>' ;
if ( $return === true ) {
return $output ;
} else {
echo $output ;
}
}
2008-08-21 23:07:20 +02:00
/**
2008-08-21 23:57:11 +02:00
* Render an input password element .
2008-12-16 11:20:33 +01:00
*
* The element will have an id like : " password- $name "
2019-01-30 16:18:44 +01:00
*
* @ param string $name Input name .
* @ param string $value Input value .
* @ param string $alt Alternative HTML string ( optional ) .
* @ param integer $size Size of the input ( optional ) .
* @ param integer $maxlength Maximum length allowed ( optional ) .
* @ param boolean $return Whether to return an output string or echo now ( optional , echo by default ) .
* @ param boolean $disabled Disable the button ( optional , button enabled by default ) .
2008-12-16 11:20:33 +01:00
*
* @ return string HTML code if return parameter is true .
2008-08-21 23:07:20 +02:00
*/
2019-01-30 16:18:44 +01:00
function html_print_input_password (
$name ,
$value ,
$alt = '' ,
$size = 50 ,
$maxlength = 255 ,
$return = false ,
$disabled = false ,
$required = false ,
2019-06-06 16:51:11 +02:00
$class = '' ,
2023-03-02 17:08:47 +01:00
$autocomplete = 'off' ,
$hide_div_eye = false ,
2023-04-14 12:24:39 +02:00
$div_class = ''
2019-01-30 16:18:44 +01:00
) {
if ( $maxlength == 0 ) {
$maxlength = 255 ;
}
2019-06-07 17:35:13 +02:00
if ( $size === false ) {
$size = false ;
} else if ( $size == 0 ) {
2019-01-30 16:18:44 +01:00
$size = 10 ;
}
$attr = [];
if ( $required ) {
$attr [ 'required' ] = 'required' ;
}
if ( $class ) {
2022-06-21 13:29:50 +02:00
$attr [ 'class' ] = $class . ' ' . 'password_input' ;
} else {
$attr [ 'class' ] = 'password_input' ;
2019-01-30 16:18:44 +01:00
}
2019-09-24 11:25:53 +02:00
if ( $disabled === false ) {
// Trick to avoid password completion on most browsers.
if ( $autocomplete !== 'on' ) {
$disabled = true ;
$attr [ 'onfocus' ] = " this.removeAttribute('readonly'); " ;
}
}
2023-04-14 12:24:39 +02:00
return '<div class="relative container-div-input-password ' . $div_class . '">' . html_print_input_text_extended ( $name , $value , 'password-' . $name , $alt , $size , $maxlength , $disabled , '' , $attr , $return , true , '' , $autocomplete , false , $hide_div_eye ) . '</div>' ;
2008-08-21 23:07:20 +02:00
}
2019-01-30 16:18:44 +01:00
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
/**
2008-12-16 11:20:33 +01:00
* Render an input text element .
*
* The element will have an id like : " text- $name "
2019-01-30 16:18:44 +01:00
*
2022-01-26 12:52:36 +01:00
* @ param string $name Input name .
* @ param string $value Input value .
* @ param string $alt Alternative HTML string ( invalid - not used ) .
* @ param integer $size Size of the input ( optional ) .
* @ param integer $maxlength Maximum length allowed ( optional ) .
* @ param boolean $return Whether to return an output string or echo now ( optional , echo by default ) .
* @ param boolean $disabled Disable the button ( optional , button enabled by default ) .
* @ param string | null $list Some stuff .
* @ param string | null $placeholder Some stuff .
* @ param string | null $pattern Some stuff .
2008-12-16 11:20:33 +01:00
*
* @ return string HTML code if return parameter is true .
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
*/
2020-03-26 12:29:38 +01:00
function html_print_input_text (
$name ,
$value ,
$alt = '' ,
$size = 50 ,
$maxlength = 255 ,
$return = false ,
2020-07-13 12:23:46 +02:00
$readonly = false ,
2020-03-26 12:29:38 +01:00
$required = false ,
$function = '' ,
$class = '' ,
$onChange = '' ,
2021-02-01 13:54:57 +01:00
$autocomplete = 'off' ,
2020-04-02 12:53:21 +02:00
$autofocus = false ,
2020-04-13 15:41:00 +02:00
$onKeyDown = '' ,
2020-05-14 17:42:58 +02:00
$formTo = '' ,
2020-07-13 12:23:46 +02:00
$onKeyUp = '' ,
2020-10-30 13:25:33 +01:00
$disabled = false ,
2021-09-29 20:56:39 +02:00
$list = '' ,
2022-01-26 12:52:36 +01:00
$placeholder = null ,
$pattern = null
2020-03-26 12:29:38 +01:00
) {
2019-01-30 16:18:44 +01:00
if ( $maxlength == 0 ) {
$maxlength = 255 ;
}
2019-06-07 17:35:13 +02:00
if ( $size === false ) {
$size = false ;
} else if ( $size == 0 ) {
2019-01-30 16:18:44 +01:00
$size = 10 ;
}
$attr = [];
if ( $required ) {
$attr [ 'required' ] = 'required' ;
}
if ( $class != '' ) {
2022-06-21 13:29:50 +02:00
$attr [ 'class' ] = $class . ' ' . 'text_input' ;
} else {
$attr [ 'class' ] = 'text_input' ;
2019-01-30 16:18:44 +01:00
}
if ( $onChange != '' ) {
$attr [ 'onchange' ] = $onChange ;
}
2020-04-02 12:53:21 +02:00
if ( $onKeyDown != '' ) {
$attr [ 'onkeydown' ] = $onKeyDown ;
}
2020-05-14 17:42:58 +02:00
if ( $onKeyUp != '' ) {
$attr [ 'onkeyup' ] = $onKeyUp ;
}
2020-03-26 12:29:38 +01:00
if ( $autofocus === true ) {
$attr [ 'autofocus' ] = $autofocus ;
}
2020-04-13 15:41:00 +02:00
if ( $formTo != '' ) {
$attr [ 'form' ] = $formTo ;
}
2020-10-30 13:25:33 +01:00
if ( $list != '' ) {
$attr [ 'list' ] = $list ;
}
2021-09-29 20:56:39 +02:00
if ( $list !== null ) {
$attr [ 'placeholder' ] = $placeholder ;
}
2022-01-26 12:52:36 +01:00
if ( $pattern !== null ) {
$attr [ 'pattern' ] = $pattern ;
}
2020-03-26 12:29:38 +01:00
return html_print_input_text_extended (
$name ,
$value ,
'text-' . $name ,
$alt ,
$size ,
$maxlength ,
2020-07-13 12:23:46 +02:00
$readonly ,
2020-03-26 12:29:38 +01:00
'' ,
$attr ,
$return ,
false ,
2020-07-13 12:23:46 +02:00
$function ,
2021-02-01 13:54:57 +01:00
$autocomplete ,
2020-07-13 12:23:46 +02:00
$disabled
2020-03-26 12:29:38 +01:00
);
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
}
2019-01-30 16:18:44 +01:00
2019-10-24 17:42:37 +02:00
/**
* Render an input email element .
*
* @ param array $settings Array with attributes input .
* only name is necessary .
*
* @ return string Html input .
*/
function html_print_input_email ( array $settings ) : string
{
// TODO: const.
$valid_attrs = [
'accept' ,
'disabled' ,
'maxlength' ,
'name' ,
'readonly' ,
'placeholder' ,
'size' ,
'value' ,
'accesskey' ,
'class' ,
'dir' ,
'id' ,
'lang' ,
'style' ,
'tabindex' ,
'title' ,
'xml:lang' ,
'onfocus' ,
'onblur' ,
'onselect' ,
'onchange' ,
'onclick' ,
'ondblclick' ,
'onmousedown' ,
'onmouseup' ,
'onmouseover' ,
'onmousemove' ,
'onmouseout' ,
'onkeypress' ,
'onkeydown' ,
'onkeyup' ,
'required' ,
'pattern' ,
'autocomplete' ,
];
$output = '' ;
if ( isset ( $settings ) === true && is_array ( $settings ) === true ) {
// Check Name is necessary.
if ( isset ( $settings [ 'name' ]) === true ) {
$output = '<input type="email" ' ;
// Check Max length.
if ( isset ( $settings [ 'maxlength' ]) === false ) {
$settings [ 'maxlength' ] = 255 ;
}
// Check Size.
if ( isset ( $settings [ 'size' ]) === false
|| $settings [ 'size' ] === 0
) {
$settings [ 'size' ] = 255 ;
}
2021-02-01 13:54:57 +01:00
if ( isset ( $settings [ 'autocomplete' ]) === false ) {
$settings [ 'autocomplete' ] = 'off' ;
}
2019-10-24 17:42:37 +02:00
foreach ( $settings as $attribute => $attr_value ) {
// Check valid attribute.
if ( in_array ( $attribute , $valid_attrs ) === false ) {
continue ;
}
$output .= $attribute . '="' . $attr_value . '" ' ;
}
$output .= $function . '/>' ;
}
}
return $output ;
}
2019-11-12 13:16:25 +01:00
/**
* Render an input number element .
*
* @ param array $settings Array with attributes input .
* only name is necessary .
*
* @ return string
*/
function html_print_input_number ( array $settings ) : string
{
// TODO: const.
$valid_attrs = [
'accept' ,
'disabled' ,
'maxlength' ,
'name' ,
'readonly' ,
'placeholder' ,
'size' ,
'value' ,
'accesskey' ,
'class' ,
'dir' ,
'id' ,
'lang' ,
'style' ,
'tabindex' ,
'title' ,
'xml:lang' ,
'onfocus' ,
'onblur' ,
'onselect' ,
'onchange' ,
'onclick' ,
'ondblclick' ,
'onmousedown' ,
'onmouseup' ,
'onmouseover' ,
'onmousemove' ,
'onmouseout' ,
'onkeypress' ,
'onkeydown' ,
'onkeyup' ,
'required' ,
'pattern' ,
'autocomplete' ,
2020-01-23 19:54:47 +01:00
'min' ,
'max' ,
2020-03-26 12:29:38 +01:00
'step' ,
2019-11-12 13:16:25 +01:00
];
2021-03-18 09:53:39 +01:00
global $config ;
$text_color = '' ;
2022-01-17 10:22:30 +01:00
if ( $config [ 'style' ] === 'pandora_black' && ! is_metaconsole ()) {
2021-03-18 09:53:39 +01:00
$text_color = 'style="color: white"' ;
}
2019-11-12 13:16:25 +01:00
$output = '' ;
if ( isset ( $settings ) === true && is_array ( $settings ) === true ) {
// Check Name is necessary.
if ( isset ( $settings [ 'name' ]) === true ) {
2021-03-18 09:53:39 +01:00
$output = '<input ' . $text_color . ' type="number" ' ;
2019-11-12 13:16:25 +01:00
// Check Max length.
if ( isset ( $settings [ 'maxlength' ]) === false ) {
$settings [ 'maxlength' ] = 255 ;
}
2021-02-01 13:54:57 +01:00
if ( isset ( $settings [ 'autocomplete' ]) === false ) {
$settings [ 'autocomplete' ] = 'off' ;
}
2019-11-12 13:16:25 +01:00
foreach ( $settings as $attribute => $attr_value ) {
// Check valid attribute.
if ( in_array ( $attribute , $valid_attrs ) === false ) {
continue ;
}
$output .= $attribute . '="' . $attr_value . '" ' ;
}
2022-01-11 12:08:41 +01:00
$output .= '/>' ;
2019-11-12 13:16:25 +01:00
}
}
return $output ;
}
2008-10-22 14:01:36 +02:00
/**
* Render an input image element .
2008-12-16 11:20:33 +01:00
*
* The element will have an id like : " image- $name "
2019-01-30 16:18:44 +01:00
*
* @ param string $name Input name .
* @ param string $src Image source .
* @ param string $value Input value .
* @ param string $style HTML style property .
* @ param boolean $return Whether to return an output string or echo now ( optional , echo by default ) .
2008-12-16 11:20:33 +01:00
*
* @ return string HTML code if return parameter is true .
2008-10-22 14:01:36 +02:00
*/
2019-01-30 16:18:44 +01:00
function html_print_input_image ( $name , $src , $value , $style = '' , $return = false , $options = false )
{
global $config ;
static $idcounter = 0 ;
++ $idcounter ;
// Checks if user's skin is available
$isFunctionSkins = enterprise_include_once ( 'include/functions_skins.php' );
if ( $isFunctionSkins !== ENTERPRISE_NOT_HOOK ) {
$skin_path = enterprise_hook ( 'skins_get_image_path' , [ $src ]);
if ( $skin_path ) {
$src = $skin_path ;
}
}
2023-02-06 23:10:28 +01:00
// If metaconsole is activated and image doesn't exists try to search on normal console.
if ( is_metaconsole () === true ) {
2019-01-30 16:18:44 +01:00
if ( false === @ file_get_contents ( $src , 0 , null , 0 , 1 )) {
$src = '../../' . $src ;
}
}
2023-02-06 23:10:28 +01:00
// Path to image.
2019-01-30 16:18:44 +01:00
$src = ui_get_full_url ( $src );
$output = '<input id="image-' . $name . $idcounter . '" src="' . $src . '" style="' . $style . '" name="' . $name . '" type="image"' ;
2023-02-06 23:10:28 +01:00
// Valid attributes (invalid attributes get skipped).
2019-01-30 16:18:44 +01:00
$attrs = [
'alt' ,
'accesskey' ,
'lang' ,
'tabindex' ,
'title' ,
2021-05-06 14:46:58 +02:00
'data-title' ,
'data-use_title_for_force_title' ,
2019-01-30 16:18:44 +01:00
'xml:lang' ,
'onclick' ,
'ondblclick' ,
'onmousedown' ,
'onmouseup' ,
'onmouseover' ,
'onmousemove' ,
'onmouseout' ,
'onkeypress' ,
'onkeydown' ,
'onkeyup' ,
2019-08-10 02:13:01 +02:00
'class' ,
2023-03-05 13:46:27 +01:00
'form' ,
2023-03-13 15:07:38 +01:00
'disabled' ,
2019-01-30 16:18:44 +01:00
];
2023-07-14 13:07:04 +02:00
if ( isset ( $options [ 'title' ]) && $options [ 'title' ] != '' ) {
if ( isset ( $options [ 'class' ])) {
$options [ 'class' ] .= ' forced_title' ;
} else {
$options [ 'class' ] = 'forced_title' ;
}
// New way to show the force_title (cleaner and better performance).
$output .= 'data-title="' . io_safe_input_html ( $options [ 'title' ]) . '" ' ;
$output .= 'data-use_title_for_force_title="1" ' ;
}
2019-01-30 16:18:44 +01:00
foreach ( $attrs as $attribute ) {
2023-08-03 12:51:09 +02:00
if ( $attribute !== 'title' ) {
if ( isset ( $options [ $attribute ])) {
$output .= ' ' . $attribute . '="' . io_safe_input_html ( $options [ $attribute ]) . '"' ;
}
2019-01-30 16:18:44 +01:00
}
}
$output .= ' value="' . $value . '" />' ;
if ( $return ) {
return $output ;
}
echo $output ;
2008-10-22 14:01:36 +02:00
}
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
2019-01-30 16:18:44 +01:00
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
/**
* Render an input hidden element .
2008-12-16 11:20:33 +01:00
*
* The element will have an id like : " hidden- $name "
2019-01-30 16:18:44 +01:00
*
2020-06-30 12:16:51 +02:00
* @ param string $name Input name .
* @ param string $value Input value .
* @ param boolean $return Whether to return an output string or echo now
* ( optional , echo by default ) .
* @ param string $class Set the class of input .
* @ param string $attributes String with the needed attributes to add .
* @ param string $id Specific id .
2008-12-16 11:20:33 +01:00
*
* @ return string HTML code if return parameter is true .
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
*/
2020-06-30 12:16:51 +02:00
function html_print_input_hidden (
$name ,
$value ,
$return = false ,
$class = false ,
$attributes = false ,
$id = ''
) {
2019-01-30 16:18:44 +01:00
if ( $class !== false ) {
$classText = 'class="' . $class . '"' ;
} else {
$classText = '' ;
}
2020-06-30 12:16:51 +02:00
if ( $attributes !== false ) {
$otherAttributes = $attributes ;
} else {
$otherAttributes = '' ;
}
2019-01-30 16:18:44 +01:00
$separator = '"' ;
if ( is_string ( $value )) {
if ( strstr ( $value , '"' )) {
$separator = " ' " ;
}
}
2020-06-30 12:16:51 +02:00
$idInput = 'hidden-' . $name ;
if ( empty ( $id ) === false ) {
$idInput = $id ;
}
$output = '<input id="' . $idInput . '" name="' . $name . '" type="hidden" ' . $classText . ' value=' . $separator . $value . $separator . ' ' . $otherAttributes . '/>' ;
2019-01-30 16:18:44 +01:00
if ( $return ) {
return $output ;
}
echo $output ;
2012-09-12 17:53:58 +02:00
}
2019-01-30 16:18:44 +01:00
2012-09-12 17:53:58 +02:00
/**
* Render an input hidden element . Extended version , use html_print_input_hidden () to simplify .
*
* The element will have an id like : " hidden- $name "
2019-01-30 16:18:44 +01:00
*
* @ param string $name Input name .
* @ param string $value Input value .
* @ param string $id Input value .
* @ param boolean $return Whether to return an output string or echo now ( optional , echo by default ) .
* @ param string $class Set the class of input .
2019-11-21 12:42:06 +01:00
* @ param boolean $quotes Use simple quotes or double quotes .
2012-09-12 17:53:58 +02:00
*
* @ return string HTML code if return parameter is true .
*/
2019-11-21 12:42:06 +01:00
function html_print_input_hidden_extended (
$name ,
$value ,
$id ,
$return = false ,
$class = false ,
$quotes = false
) {
2019-01-30 16:18:44 +01:00
if ( $class !== false ) {
$classText = 'class="' . $class . '"' ;
} else {
$classText = '' ;
}
if ( empty ( $id )) {
$ouput_id = 'hidden-' . $name ;
} else {
$ouput_id = $id ;
}
2019-11-21 12:42:06 +01:00
$quote = '"' ;
if ( $quotes === true ) {
$quote = " ' " ;
}
$output = '<input id=' . $quote . '' . $ouput_id . '' . $quote . ' ' ;
$output .= ' name=' . $quote . '' . $name . '' . $quote . ' ' ;
$output .= ' type=' . $quote . 'hidden' . $quote . ' ' . $classText ;
$output .= ' value=' . $quote . '' . $value . '' . $quote . '' ;
$output .= ' />' ;
2019-01-30 16:18:44 +01:00
if ( $return ) {
return $output ;
}
echo $output ;
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
}
2019-01-30 16:18:44 +01:00
2018-12-10 09:20:06 +01:00
/**
* Render a color input element .
*
* The element will have an id like : " hidden- $name "
2019-01-30 16:18:44 +01:00
*
* @ param string $name Input name .
* @ param integer $value Input value . Decimal representation of the color ' s hexadecimal value .
* @ param string $class Set the class of input .
* @ param boolean $return Whether to return an output string or echo now ( optional , echo by default ) .
2018-12-10 09:20:06 +01:00
*
* @ return string HTML code if return parameter is true .
*/
2020-01-22 12:48:31 +01:00
function html_print_input_color ( $name , $value , $id = '' , $class = false , $return = false )
2019-01-30 16:18:44 +01:00
{
$attr_type = 'type="color"' ;
2020-01-22 12:48:31 +01:00
if ( empty ( $id ) === true ) {
$attr_id = 'id="color-' . htmlspecialchars ( $name , ENT_QUOTES ) . '"' ;
} else {
$attr_id = 'id="' . $id . '"' ;
}
2019-01-30 16:18:44 +01:00
$attr_name = 'name="' . htmlspecialchars ( $name , ENT_QUOTES ) . '"' ;
$attr_value = 'value="' . htmlspecialchars ( $value , ENT_QUOTES ) . '"' ;
$attr_class = 'class="' . ( $class !== false ? htmlspecialchars ( $class , ENT_QUOTES ) : '' ) . '"' ;
$output = '<input ' . $attr_type . ' ' . $attr_id . ' ' . $attr_name . ' ' . $attr_value . ' ' . $attr_class . ' />' ;
if ( $return ) {
return $output ;
}
echo $output ;
2018-12-10 09:20:06 +01:00
}
2019-01-30 16:18:44 +01:00
2022-11-16 16:04:22 +01:00
/**
* Action buttons .
*
2023-02-23 14:30:31 +01:00
* @ param mixed $content HTML content . Usually must be buttons .
2022-11-21 14:49:07 +01:00
* @ param array $parameters Parameters for create the action buttons .
* $var [ 'type' ] => Type of action - buttons :
* 'form_action' => Fits into form size ( fixed size ) .
* 'data_table' => Fits into browser window .
* $var [ 'class' ] => Added class for action - buttons container .
* $var [ 'id' ] => Customize Id . By default `principal_action_buttons` ( Handled by JS ) .
* $var [ 'background_mask' ] => Boolean . True by default . Set a background for action buttons .
* $var [ 'background_mask_style' ] => String . Empty by default . Set a manual style .
* @ param boolean $return Return formed string if is true .
2022-11-16 16:04:22 +01:00
*
* @ return mixed .
*/
2023-02-23 14:30:31 +01:00
function html_print_action_buttons ( mixed $content , array $parameters = [], bool $return = false )
2022-11-16 16:04:22 +01:00
{
2023-02-23 14:30:31 +01:00
if ( is_array ( $content ) === true ) {
$content = implode ( '' , $content );
}
2022-11-21 14:49:07 +01:00
$typeClass = 'fixed_action_buttons ' ;
switch (( $parameters [ 'type' ] ? ? '' )) {
case 'form_action' :
case 'fixed_size' :
$typeClass .= 'fixed_action_buttons_size' ;
break ;
default :
case 'data_table' :
// For fill.
break ;
}
if ( isset ( $parameters [ 'background_mask' ]) === false || $parameters [ 'background_mask' ] !== false ) {
$backgroundId = 'backgroundMaskId' ;
$content .= html_print_div (
[
'id' => $backgroundId ,
'class' => 'action_buttons_background_mask' ,
'content' => '' ,
'style' => ( $parameters [ 'background_mask_style' ] ? ? '' ),
],
true
);
}
// Optional content.
$content .= html_print_div (
[
'class' => 'action_buttons_right_content' ,
'content' => ( $parameters [ 'right_content' ] ? ? '' ),
],
true
);
2022-11-16 16:04:22 +01:00
return html_print_div (
[
2022-11-21 14:49:07 +01:00
'id' => ( $parameters [ 'id' ] ? ? 'principal_action_buttons' ),
'class' => 'action-buttons ' . $typeClass . ' ' . ( $parameters [ 'class' ] ? ? '' ),
'content' => $content ,
2023-03-08 15:57:55 +01:00
'style' => 'z-index: 6' ,
2022-11-16 16:04:22 +01:00
],
$return
);
}
2008-12-16 11:20:33 +01:00
/**
* Render an submit input button element .
*
* The element will have an id like : " submit- $name "
2019-01-30 16:18:44 +01:00
*
* @ param string $label Input label .
* @ param string $name Input name .
* @ param boolean $disabled Whether to disable by default or not . Enabled by default .
2022-10-21 13:35:57 +02:00
* @ param mixed $attributes Additional HTML attributes .
2019-01-30 16:18:44 +01:00
* @ param boolean $return Whether to return an output string or echo now ( optional , echo by default ) .
2008-12-16 11:20:33 +01:00
*
* @ return string HTML code if return parameter is true .
*/
2019-01-30 16:18:44 +01:00
function html_print_submit_button ( $label = 'OK' , $name = '' , $disabled = false , $attributes = '' , $return = false )
{
2022-10-24 19:54:15 +02:00
if ( is_string ( $attributes ) === true ) {
2023-02-14 12:16:09 +01:00
// Convert Attributes in array for handle in the principal function.
$tmp = [];
$tmp [ 'rawAttributes' ] = $attributes ;
$attributes = $tmp ;
2019-01-30 16:18:44 +01:00
}
2022-10-25 17:11:18 +02:00
// Set the button type from here.
2022-10-24 19:54:15 +02:00
$attributes [ 'type' ] = 'submit' ;
2019-01-30 16:18:44 +01:00
2023-02-14 12:16:09 +01:00
return html_print_button (
2022-10-21 13:35:57 +02:00
$label ,
2022-10-24 19:54:15 +02:00
$name ,
$disabled ,
2022-10-25 17:11:18 +02:00
( isset ( $attributes [ 'onclick' ]) === true ) ? $attributes [ 'onclick' ] : '' ,
2022-10-24 19:54:15 +02:00
$attributes ,
2023-02-14 12:16:09 +01:00
$return
2022-10-21 13:35:57 +02:00
);
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
}
2019-01-30 16:18:44 +01:00
2008-12-16 11:20:33 +01:00
/**
* Render an submit input button element .
*
* The element will have an id like : " button- $name "
2019-01-30 16:18:44 +01:00
*
* @ param string $label Input label .
* @ param string $name Input name .
* @ param boolean $disabled Whether to disable by default or not . Enabled by default .
* @ param string $script JavaScript to attach
2022-10-21 13:35:57 +02:00
* @ param mixed $attributes Additional HTML attributes .
2019-01-30 16:18:44 +01:00
* @ param boolean $return Whether to return an output string or echo now ( optional , echo by default ) .
* @ param boolean $imageButton Set the button as a image button without text , by default is false .
2008-12-16 11:20:33 +01:00
*
* @ return string HTML code if return parameter is true .
*/
2019-01-30 16:18:44 +01:00
function html_print_button ( $label = 'OK' , $name = '' , $disabled = false , $script = '' , $attributes = '' , $return = false , $imageButton = false , $modal = false , $message = '' )
{
$output = '' ;
2022-10-24 19:54:15 +02:00
$classes = '' ;
2023-02-10 13:38:47 +01:00
$fixedId = '' ;
2023-02-16 12:35:02 +01:00
$iconStyle = '' ;
2023-07-21 13:32:12 +02:00
$minimize_arrow = false ;
2023-02-22 12:16:04 +01:00
// $spanStyle = 'margin-top: 4px;';
$spanStyle = '' ;
2022-10-21 13:35:57 +02:00
if ( empty ( $name ) === true ) {
$name = 'unnamed' ;
}
// Icon for show in button.
$iconToUse = '' ;
if ( is_array ( $attributes ) === true ) {
$attr_array = $attributes ;
$attributes = '' ;
foreach ( $attr_array as $attribute => $value ) {
if ( $attribute === 'icon' ) {
$iconToUse = $value ;
2022-10-24 19:54:15 +02:00
} else if ( $attribute === 'mode' ) {
2022-11-07 14:04:07 +01:00
if ( $value !== 'link' ) {
$buttonMode = $value ;
} else {
$iconToUse = '' ;
}
2019-01-30 16:18:44 +01:00
2022-10-24 19:54:15 +02:00
$classes .= ' ' . $value ;
} else if ( $attribute === 'type' ) {
$buttonType = $value ;
$classes .= ' ' . $value . 'Button' ;
} else if ( $attribute === 'class' ) {
$classes .= ' ' . $value ;
2023-02-10 13:38:47 +01:00
} else if ( $attribute === 'fixed_id' ) {
$fixedId = $value ;
2023-02-16 12:35:02 +01:00
} else if ( $attribute === 'icon_style' ) {
$iconStyle = $value ;
} else if ( $attribute === 'span_style' ) {
$spanStyle .= $value ;
2023-02-14 12:16:09 +01:00
} else if ( $attribute === 'rawAttributes' ) {
$buttonType = ( $attr_array [ 'type' ] ? ? 'button' );
$buttonAttributes = $value ;
break ;
2023-07-21 13:32:12 +02:00
} else if ( $attribute === 'minimize-arrow' ) {
$minimize_arrow = true ;
2022-10-21 13:35:57 +02:00
} else {
$attributes .= $attribute . '="' . $value . '" ' ;
}
}
} else if ( empty ( $attributes ) === false && is_string ( $attributes ) === true ) {
2023-02-14 12:16:09 +01:00
$buttonAttrutes = explode ( ' ' , $attributes );
2019-01-30 16:18:44 +01:00
}
2022-10-25 16:26:23 +02:00
if ( empty ( $iconToUse ) === false || ( isset ( $buttonMode ) === true && $buttonMode !== 'onlyIcon' )) {
2022-10-21 13:35:57 +02:00
$iconDiv = html_print_div (
[
2023-02-16 12:35:02 +01:00
'style' => $iconStyle ,
2022-10-21 13:35:57 +02:00
'class' => sprintf (
2022-10-24 19:54:15 +02:00
'subIcon %s %s' ,
2022-10-21 13:35:57 +02:00
$iconToUse ,
2022-10-25 16:26:23 +02:00
( empty ( $buttonMode ) === false ) ? $buttonMode : ''
2022-10-21 13:35:57 +02:00
),
],
true
);
} else {
$iconDiv = '' ;
2019-01-30 16:18:44 +01:00
}
2023-07-21 13:32:12 +02:00
if ( $minimize_arrow === true ) {
$minimezeDiv = html_print_div (
[
'id' => 'minimize_arrow_event_sound' ,
'style' => 'background-color:transparent; right: 1em; margin-left:0.5em; position:relative; display:none;' ,
'class' => 'arrow_menu_down w30p' ,
],
true
);
} else {
$minimezeDiv = '' ;
}
2023-02-15 16:28:40 +01:00
// Defined id. Is usable for span and button.
// TODO. Check if will be proper use button or submit when where appropiate.
$mainId = (( empty ( $fixedId ) === false ) ? $fixedId : 'button-' . $name );
2019-01-30 16:18:44 +01:00
2022-10-21 13:35:57 +02:00
if ( $imageButton === false ) {
2023-07-21 13:32:12 +02:00
$content = $minimezeDiv ;
$content .= '<span id="span-' . $mainId . '" style="' . $spanStyle . '" class="font_11">' . $label . '</span>' ;
2022-10-21 13:35:57 +02:00
$content .= $iconDiv ;
} else {
2023-07-21 13:32:12 +02:00
$content = $minimezeDiv ;
$content .= $iconDiv ;
2022-10-21 13:35:57 +02:00
}
2022-10-24 19:54:15 +02:00
// In case of not selected button type, in this case, will be normal button.
if ( isset ( $buttonType ) === false || ( $buttonType !== 'button' && $buttonType !== 'submit' )) {
$buttonType = 'button' ;
$classes .= ' buttonButton' ;
}
2023-03-21 18:42:31 +01:00
// if ($disabled === true) {
// $classes .= ' disabled_action_button';
// }
2023-02-14 12:16:09 +01:00
if ( empty ( $buttonAttributes ) === true ) {
$parameters = [];
$parameters [] = 'class="' . $classes . '"' ;
$parameters [] = ( empty ( $name ) === false ) ? ' name="' . $name . '"' : '' ;
2023-02-15 16:28:40 +01:00
$parameters [] = 'id="' . $mainId . '"' ;
2023-02-14 12:16:09 +01:00
$parameters [] = ( empty ( $label ) === false ) ? ' value="' . $label . '"' : '' ;
2023-03-02 19:25:31 +01:00
$parameters [] = ( empty ( $script ) === false ) ? " onClick=' " . $script . " ' " : '' ;
2023-02-14 12:16:09 +01:00
$parameters [] = ( $disabled === true ) ? ' disabled' : '' ;
$parameters [] = ( empty ( $attributes ) === false ) ? $attributes : '' ;
$buttonAttributes = implode ( ' ' , $parameters );
}
2023-02-10 13:38:47 +01:00
2022-10-21 13:35:57 +02:00
$output = sprintf (
2023-02-10 13:38:47 +01:00
'<button type="%s" %s>%s</button>' ,
2022-10-24 19:54:15 +02:00
$buttonType ,
2023-02-14 12:16:09 +01:00
$buttonAttributes ,
2022-10-21 13:35:57 +02:00
$content
);
2019-01-30 16:18:44 +01:00
2022-10-21 13:35:57 +02:00
if ( $modal !== false && enterprise_installed () === false ) {
2019-01-30 16:18:44 +01:00
$output .= "
2021-03-31 10:29:57 +02:00
< div id = '".$message."' class = 'publienterprise publicenterprise_div' title = 'Community version' >< img data - title = '".__(' Enterprise version not installed ')."' class = 'img_help forced_title' data - use_title_for_force_title = '1' src = 'images/alert_enterprise.png' ></ div >
2016-09-28 18:16:01 +02:00
" ;
2019-01-30 16:18:44 +01:00
}
2022-10-21 13:35:57 +02:00
if ( $return === true ) {
2019-01-30 16:18:44 +01:00
return $output ;
2022-10-21 13:35:57 +02:00
} else {
echo $output ;
2019-01-30 16:18:44 +01:00
}
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
}
2019-01-30 16:18:44 +01:00
2008-12-16 11:20:33 +01:00
/**
* Render an input textarea element .
*
* The element will have an id like : " textarea_ $name "
2019-01-30 16:18:44 +01:00
*
* @ param string $name Input name .
* @ param integer $rows How many rows ( height )
* @ param integer $columns How many columns ( width )
* @ param string $value Text in the textarea
* @ param string $attributes Additional attributes
* @ param boolean $return Whether to return an output string or echo now ( optional , echo by default ) . *
2009-01-08 16:52:13 +01:00
*
2008-12-16 11:20:33 +01:00
* @ return string HTML code if return parameter is true .
*/
2020-07-13 12:23:46 +02:00
function html_print_textarea (
$name ,
$rows ,
$columns ,
$value = '' ,
$attributes = '' ,
$return = false ,
$class = '' ,
2020-09-23 14:07:23 +02:00
$disable = false ,
$id = false
2020-07-13 12:23:46 +02:00
) {
2020-04-20 15:19:28 +02:00
$disabled = ( $disable ) ? 'disabled' : '' ;
2020-09-23 14:07:23 +02:00
if ( $id === false ) {
$id = 'textarea_' . $name ;
}
$output = '<textarea id="' . $id . '" name="' . $name . '" cols="' . $columns . '" rows="' . $rows . '" ' . $attributes . ' class="' . $class . '" ' . $disabled . '>' ;
2019-01-30 16:18:44 +01:00
$output .= ( $value );
$output .= '</textarea>' ;
if ( $return ) {
return $output ;
}
echo $output ;
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
}
2019-01-30 16:18:44 +01:00
2013-02-27 18:11:42 +01:00
/**
* Return a table parameters predefined
2019-01-30 16:18:44 +01:00
*
2013-02-27 18:11:42 +01:00
* @ param string model
2019-01-30 16:18:44 +01:00
* - Transparent : More basic template . No borders , all the columns with same width
2013-02-27 18:11:42 +01:00
* @ param int number of columns
2019-01-30 16:18:44 +01:00
*
* @ return object Table object
2013-02-27 18:11:42 +01:00
*/
2019-01-30 16:18:44 +01:00
function html_get_predefined_table ( $model = 'transparent' , $columns = 4 )
{
$width_percent = ( 100 / $columns );
switch ( $model ) {
case 'transparent' :
default :
$table = new stdClass ();
$table -> class = 'none' ;
$table -> cellpadding = 0 ;
$table -> cellspacing = 0 ;
$table -> head = [];
$table -> data = [];
$table -> style = array_fill ( 0 , 4 , 'text-align:center; width: ' . $width_percent . '%;' );
$table -> width = '100%' ;
}
return $table ;
2013-02-27 18:11:42 +01:00
}
2019-01-30 16:18:44 +01:00
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
/**
* Print a nicely formatted table . Code taken from moodle .
*
2009-01-12 Esteban Sanchez <estebans@artica.es>
* godmode/agentes/alert_manager.php: Complete rewritten of the alert
system when assigned alerts to an agent.
* pandoradb.sql: New tables for alert system. These are:
talert_commands, talert_actions, talert_templates,
talert_template_modules, talert_template_module_actions. No migration
tool is available yet.
* godmode/alerts/configure_alert_template.php,
godmode/alerts/configure_alert_action.php,
godmode/alerts/alert_templates.php,
godmode/alerts/configure_alert_command.php,
godmode/alerts/alert_actions.php: Added to repository. Administration
interface to new alert system.
* godmode/alerts/modify_alert.php: Deleted from repository.
* godmode/setup/setup.php: Added an example of the date format. Main
table has now percentage width.
* godmode/menu.php, operation/menu.php: Added new alert options.
Removed refr value when it's not neccesary.
* include/styles/pandora.css: Added width to textarea elements. Style
correction and cleanup. Tables doesn't have a odd-even pattern, but
the hovered row now changes its colour. New styles for alert pages.
* include/functions_custom_graphs.php: Added to repository. custom
graphs functions moved here.
* include/functions_incidents.php, include/functions_events.php: Moved
to LGPL. Style comment corrections.
* include/functions_html.php: Documentation style correction. Added
print_input_file() and print_label().
* include/functions_ui.php: Doc style correction.
* operation/reporting/graph_viewer.php: Include new function file with
custom graphs. Use generic functions.
* index.php: Unset pass from POST and REQUEST arrays.
* include/functions_db.php: Some documentation updated to new format.
Added format_array_to_update_sql() to generate SQL sentences for
updates. Style correction.
* godmode/agentes/configurar_agente.php: Variables renamed to have a
meaning.
* extensions/update_manager/main.php: Mark an string translatable.
* extensions/update_manager/lib/libupdate_manager_client.php,
godmode/alerts/configure_alert.php, include/functions.php,
godmode/agentes/module_manager.php, operation/agentes/networkmap.php,
operation/reporting/reporting_viewer.php,
godmode/agentes/manage_config.php: Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-12 15:31:01 +01:00
* @ param object Object with several properties :
2019-01-30 16:18:44 +01:00
* $table -> head - An array of heading names .
* $table -> head_colspan - An array of colspans of each head column .
* $table -> headstyle - An array of styles of each head column .
* $table -> align - An array of column alignments
* $table -> valign - An array of column alignments
* $table -> size - An array of column sizes
* $table -> wrap - An array of " nowrap " s or nothing
* $table -> style - An array of personalized style for each column .
* $table -> rowid - An array of personalized ids of each row .
* $table -> rowstyle - An array of personalized style of each row .
* $table -> rowclass - An array of personalized classes of each row ( odd - evens classes will be ignored ) .
* $table -> colspan - An array of colspans of each column .
* $table -> rowspan - An array of rowspans of each column .
* $table -> data [] - An array of arrays containing the data .
* $table -> width - A percentage of the page
* $table -> border - Border of the table .
* $table -> tablealign - Align the whole table ( float left or right )
* $table -> cellpadding - Padding on each cell
* $table -> cellspacing - Spacing between cells
* $table -> cellstyle - Style of a cell
* $table -> cellclass - Class of a cell
* $table -> class - CSS table class
* $table -> id - Table ID ( useful in JavaScript )
* $table -> headclass [] - An array of classes for each heading
* $table -> title - Title of the table is a single string that will be on top of the table in the head spanning the whole table
* $table -> titlestyle - Title style
* $table -> titleclass - Title class
* $table -> styleTable - Table style
2019-10-23 19:50:57 +02:00
* $table -> autosize - Autosize
2012-04-18 10:08:04 +02:00
* $table -> caption - Table title
2010-05-06 17:53:38 +02:00
* @ param bool Whether to return an output string or echo now
2008-12-16 11:20:33 +01:00
*
* @ return string HTML code if return parameter is true .
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
*/
2019-01-30 16:18:44 +01:00
function html_print_table ( & $table , $return = false )
{
$output = '' ;
static $table_count = 0 ;
2020-03-26 17:05:19 +01:00
if ( ! isset ( $table )) {
$table = new StdClass ();
}
2019-01-30 16:18:44 +01:00
$table_count ++ ;
if ( isset ( $table -> align )) {
foreach ( $table -> align as $key => $aa ) {
if ( $aa ) {
$align [ $key ] = ' text-align:' . $aa . ';' ;
} else {
$align [ $key ] = '' ;
}
}
}
if ( isset ( $table -> valign )) {
foreach ( $table -> valign as $key => $aa ) {
if ( $aa ) {
$valign [ $key ] = ' vertical-align:' . $aa . ';' ;
} else {
$valign [ $key ] = '' ;
}
}
}
if ( isset ( $table -> size )) {
foreach ( $table -> size as $key => $ss ) {
if ( $ss ) {
$size [ $key ] = ' width:' . $ss . ';' ;
} else {
$size [ $key ] = '' ;
}
}
}
if ( isset ( $table -> style )) {
foreach ( $table -> style as $key => $st ) {
if ( $st ) {
$style [ $key ] = ' ' . $st . ';' ;
} else {
$style [ $key ] = '' ;
}
}
}
$styleTable = '' ;
if ( isset ( $table -> styleTable )) {
$styleTable = $table -> styleTable ;
}
if ( isset ( $table -> rowid )) {
foreach ( $table -> rowid as $key => $id ) {
$rowid [ $key ] = $id ;
}
}
if ( isset ( $table -> rowstyle )) {
foreach ( $table -> rowstyle as $key => $st ) {
$rowstyle [ $key ] = ' ' . $st . ';' ;
}
}
if ( isset ( $table -> rowclass )) {
foreach ( $table -> rowclass as $key => $class ) {
$rowclass [ $key ] = $class ;
}
}
if ( isset ( $table -> colspan )) {
foreach ( $table -> colspan as $keyrow => $cspan ) {
foreach ( $cspan as $key => $span ) {
$colspan [ $keyrow ][ $key ] = ' colspan="' . $span . '"' ;
}
}
}
if ( isset ( $table -> cellstyle )) {
foreach ( $table -> cellstyle as $keyrow => $cstyle ) {
foreach ( $cstyle as $key => $cst ) {
$cellstyle [ $keyrow ][ $key ] = $cst ;
}
}
}
if ( isset ( $table -> cellclass )) {
foreach ( $table -> cellclass as $keyrow => $cclass ) {
foreach ( $cclass as $key => $ccl ) {
$cellclass [ $keyrow ][ $key ] = $ccl ;
}
}
}
if ( isset ( $table -> rowspan )) {
foreach ( $table -> rowspan as $keyrow => $rspan ) {
foreach ( $rspan as $key => $span ) {
$rowspan [ $keyrow ][ $key ] = ' rowspan="' . $span . '"' ;
}
}
}
if ( empty ( $table -> width )) {
// $table->width = '80%';
}
2019-10-23 19:50:57 +02:00
if ( isset ( $table -> autosize ) === true ) {
$table -> autosize = 'autosize = "1"' ;
} else {
$table -> autosize = '' ;
}
2019-01-30 16:18:44 +01:00
if ( empty ( $table -> border )) {
if ( empty ( $table )) {
$table = new stdClass ();
}
$table -> border = '0' ;
}
if ( empty ( $table -> tablealign ) || (( $table -> tablealign != 'left' ) && ( $table -> tablealign != 'right' ))) {
$table -> tablealign = '"' ;
} else {
$table -> tablealign = 'float:' . $table -> tablealign . ';"' ;
// Align is deprecated. Use float instead
}
if ( ! isset ( $table -> cellpadding )) {
$table -> cellpadding = '4' ;
}
if ( ! isset ( $table -> cellspacing )) {
$table -> cellspacing = '4' ;
}
if ( empty ( $table -> class )) {
$table -> class = 'databox' ;
}
if ( empty ( $table -> titlestyle )) {
$table -> titlestyle = 'text-align:center;' ;
}
$tableid = empty ( $table -> id ) ? 'table' . $table_count : $table -> id ;
if ( ! empty ( $table -> width )) {
2019-10-23 19:50:57 +02:00
$output .= '<table ' . $table -> autosize . ' style="width:' . $table -> width . '; ' . $styleTable . ' ' . $table -> tablealign ;
2019-01-30 16:18:44 +01:00
} else {
2019-10-23 19:50:57 +02:00
$output .= '<table ' . $table -> autosize . ' style="' . $styleTable . ' ' . $table -> tablealign ;
2019-01-30 16:18:44 +01:00
}
$output .= ' cellpadding="' . $table -> cellpadding . '" cellspacing="' . $table -> cellspacing . '"' ;
$output .= ' border="' . $table -> border . '" class="' . $table -> class . '" id="' . $tableid . '">' ;
$countcols = 0 ;
if ( ! empty ( $table -> caption )) {
2021-03-11 15:40:23 +01:00
$output .= '<caption class="left"><h4>' . $table -> caption . '</h4></caption>' ;
2019-01-30 16:18:44 +01:00
}
if ( ! empty ( $table -> head )) {
$countcols = count ( $table -> head );
$output .= '<thead><tr>' ;
if ( isset ( $table -> title )) {
$output .= '<th colspan="' . $countcols . '"' ;
if ( isset ( $table -> titlestyle )) {
$output .= ' style="' . $table -> titlestyle . '"' ;
}
if ( isset ( $table -> titleclass )) {
$output .= ' class="' . $table -> titleclass . '"' ;
}
$output .= '>' . $table -> title . '</th></tr><tr>' ;
}
foreach ( $table -> head as $key => $heading ) {
if ( ! isset ( $size [ $key ])) {
$size [ $key ] = '' ;
}
if ( ! isset ( $align [ $key ])) {
$align [ $key ] = '' ;
}
if ( ! isset ( $table -> headclass [ $key ])) {
$table -> headclass [ $key ] = 'header c' . $key ;
}
if ( isset ( $table -> head_colspan [ $key ])) {
$headColspan = 'colspan = "' . $table -> head_colspan [ $key ] . '"' ;
} else {
$headColspan = '' ;
}
if ( isset ( $table -> headstyle [ $key ])) {
$headStyle = ' style = "' . $table -> headstyle [ $key ] . '" ' ;
} else {
$headStyle = '' ;
}
$output .= '<th class="' . $table -> headclass [ $key ] . '" ' . $headColspan . $headStyle . ' scope="col">' . $heading . '</th>' ;
}
$output .= '</tr></thead>' . " \n " ;
}
2023-01-04 15:46:32 +01:00
$tbodyStyle = '' ;
if ( empty ( $table -> width ) === false ) {
$tbodyStyle .= 'width:' . $table -> width . ';' ;
}
$output .= '<tbody style="' . $tbodyStyle . '">' . " \n " ;
2019-01-30 16:18:44 +01:00
if ( ! empty ( $table -> data )) {
$oddeven = 1 ;
foreach ( $table -> data as $keyrow => $row ) {
if ( ! isset ( $rowstyle [ $keyrow ])) {
$rowstyle [ $keyrow ] = '' ;
}
if ( ! isset ( $rowid [ $keyrow ])) {
$rowid [ $keyrow ] = $tableid . '-' . $keyrow ;
}
$oddeven = $oddeven ? 0 : 1 ;
$class = 'datos' . ( $oddeven ? '' : '2' );
if ( isset ( $rowclass [ $keyrow ])) {
$class = $rowclass [ $keyrow ];
}
$output .= '<tr id="' . $rowid [ $keyrow ] . '" style="' . $rowstyle [ $keyrow ] . '" class="' . $class . '">' . " \n " ;
// Special separator rows
if ( $row == 'hr' and $countcols ) {
$output .= '<td colspan="' . $countcols . '"><div class="tabledivider"></div></td>' ;
continue ;
}
if ( ! is_array ( $row )) {
$row = ( array ) $row ;
}
// It's a normal row
foreach ( $row as $key => $item ) {
if ( ! isset ( $size [ $key ])) {
$size [ $key ] = '' ;
}
if ( ! isset ( $cellstyle [ $keyrow ][ $key ])) {
$cellstyle [ $keyrow ][ $key ] = '' ;
}
if ( ! isset ( $cellclass [ $keyrow ][ $key ])) {
$cellclass [ $keyrow ][ $key ] = '' ;
}
if ( ! isset ( $colspan [ $keyrow ][ $key ])) {
$colspan [ $keyrow ][ $key ] = '' ;
}
if ( ! isset ( $rowspan [ $keyrow ][ $key ])) {
$rowspan [ $keyrow ][ $key ] = '' ;
}
if ( ! isset ( $align [ $key ])) {
$align [ $key ] = '' ;
}
if ( ! isset ( $valign [ $key ])) {
$valign [ $key ] = '' ;
}
if ( ! isset ( $wrap [ $key ])) {
$wrap [ $key ] = '' ;
}
if ( ! isset ( $style [ $key ])) {
$style [ $key ] = '' ;
}
2020-06-15 16:57:19 +02:00
if ( $class === 'datos5' && $key === 1 ) {
2023-07-18 09:34:14 +02:00
$output .= '<td id="' . $tableid . '-' . $keyrow . '-' . $key . '" style="' . $cellstyle [ $keyrow ][ $key ] . $style [ $key ] . $valign [ $key ] . $align [ $key ] . $size [ $key ] . $wrap [ $key ] . $colspan [ $keyrow ][ $key ] . ' ' . $rowspan [ $keyrow ][ $key ] . ' class="' . $class . ' ' . $cellclass [ $keyrow ][ $key ] . '">' . $item . '</td>' . " \n " ;
2020-06-15 16:57:19 +02:00
} else {
2023-07-18 09:34:14 +02:00
$output .= '<td id="' . $tableid . '-' . $keyrow . '-' . $key . '" style="' . $cellstyle [ $keyrow ][ $key ] . $style [ $key ] . $valign [ $key ] . $align [ $key ] . $size [ $key ] . $wrap [ $key ] . '" ' . $colspan [ $keyrow ][ $key ] . ' ' . $rowspan [ $keyrow ][ $key ] . ' class="' . $class . ' ' . $cellclass [ $keyrow ][ $key ] . '">' . $item . '</td>' . " \n " ;
2020-06-15 16:57:19 +02:00
}
2019-01-30 16:18:44 +01:00
}
$output .= '</tr>' . " \n " ;
}
}
$output .= '</tbody></table>' . " \n " ;
if ( $return ) {
return $output ;
}
echo $output ;
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
}
2010-02-15 14:07:52 +01:00
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
/**
2019-11-07 17:26:32 +01:00
* Render a radio button input . Extended version , use html_print_input ()
* to simplify .
*
* @ param string $name Input name .
* @ param string $value Input value .
* @ param string $label Set the button to be marked ( optional , unmarked by default ) .
* @ param string $checkedvalue Checked value .
* @ param string $disabled Disable the button ( optional , button enabled by default ) .
* @ param string $script Script to execute when onClick event is triggered ( optional ) .
* @ param string $attributes Optional HTML attributes . It ' s a free string which will be inserted tag , use it carefully ( optional ) .
* @ param string $returnparam Whether to return an output string or echo now ( optional , echo by default ) .
* @ param string $modalparam Modal param .
* @ param string $message Message .
* @ param string $id Use custom id .
2008-12-16 11:20:33 +01:00
*
* @ return string HTML code if return parameter is true .
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
*/
2019-11-07 17:26:32 +01:00
function html_print_radio_button_extended (
$name ,
$value ,
$label ,
$checkedvalue ,
$disabled ,
$script ,
$attributes ,
$return = false ,
$modal = false ,
$message = 'visualmodal' ,
$id = null
) {
2019-01-30 16:18:44 +01:00
static $idcounter = 0 ;
$output = '' ;
$output = '<input type="radio" name="' . $name . '" value="' . $value . '"' ;
2019-11-07 17:26:32 +01:00
if ( empty ( $id ) === false ) {
$htmlid = $id ;
} else {
$htmlid = 'radiobtn' . sprintf ( '%04d' , ++ $idcounter );
}
2019-01-30 16:18:44 +01:00
$output .= ' id="' . $htmlid . '"' ;
if ( $value == $checkedvalue ) {
$output .= ' checked="checked"' ;
}
if ( $disabled ) {
$output .= ' disabled="disabled"' ;
}
if ( $script != '' ) {
$output .= ' onClick="' . $script . '"' ;
}
$output .= ' ' . $attributes ;
$output .= ' />' ;
2020-05-19 08:20:04 +02:00
if ( is_array ( $label )) {
2022-12-05 13:39:51 +01:00
if ( empty ( $label ) === false ) {
$output .= '<label id="label-' . $htmlid . '" for="' . $htmlid . '" title="' . $label [ 'help_tip' ] . '">' . $label [ 'label' ] . '</label>' . " \n " ;
2020-05-19 08:20:04 +02:00
}
} else {
if ( $label != '' ) {
2022-12-05 13:39:51 +01:00
$output .= '<label id="label-' . $htmlid . '" for="' . $htmlid . '">' . $label . '</label>' . " \n " ;
2020-05-19 08:20:04 +02:00
}
2019-01-30 16:18:44 +01:00
}
2022-12-05 13:39:51 +01:00
if ( $modal === true && enterprise_installed () === false ) {
2019-01-30 16:18:44 +01:00
$output .= "
2021-03-31 10:29:57 +02:00
< div id = '".$message."' class = 'publienterprise publicenterprise_div' title = 'Community version' >< img data - title = '".__(' Enterprise version not installed ')."' class = 'img_help forced_title' data - use_title_for_force_title = '1' src = 'images/alert_enterprise.png' ></ div >
2016-09-28 18:16:01 +02:00
" ;
2019-01-30 16:18:44 +01:00
}
2022-12-05 13:39:51 +01:00
if ( $return === true ) {
2019-01-30 16:18:44 +01:00
return $output ;
}
echo $output ;
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
}
2019-01-30 16:18:44 +01:00
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
/**
* Render a radio button input .
*
2009-01-12 Esteban Sanchez <estebans@artica.es>
* godmode/agentes/alert_manager.php: Complete rewritten of the alert
system when assigned alerts to an agent.
* pandoradb.sql: New tables for alert system. These are:
talert_commands, talert_actions, talert_templates,
talert_template_modules, talert_template_module_actions. No migration
tool is available yet.
* godmode/alerts/configure_alert_template.php,
godmode/alerts/configure_alert_action.php,
godmode/alerts/alert_templates.php,
godmode/alerts/configure_alert_command.php,
godmode/alerts/alert_actions.php: Added to repository. Administration
interface to new alert system.
* godmode/alerts/modify_alert.php: Deleted from repository.
* godmode/setup/setup.php: Added an example of the date format. Main
table has now percentage width.
* godmode/menu.php, operation/menu.php: Added new alert options.
Removed refr value when it's not neccesary.
* include/styles/pandora.css: Added width to textarea elements. Style
correction and cleanup. Tables doesn't have a odd-even pattern, but
the hovered row now changes its colour. New styles for alert pages.
* include/functions_custom_graphs.php: Added to repository. custom
graphs functions moved here.
* include/functions_incidents.php, include/functions_events.php: Moved
to LGPL. Style comment corrections.
* include/functions_html.php: Documentation style correction. Added
print_input_file() and print_label().
* include/functions_ui.php: Doc style correction.
* operation/reporting/graph_viewer.php: Include new function file with
custom graphs. Use generic functions.
* index.php: Unset pass from POST and REQUEST arrays.
* include/functions_db.php: Some documentation updated to new format.
Added format_array_to_update_sql() to generate SQL sentences for
updates. Style correction.
* godmode/agentes/configurar_agente.php: Variables renamed to have a
meaning.
* extensions/update_manager/main.php: Mark an string translatable.
* extensions/update_manager/lib/libupdate_manager_client.php,
godmode/alerts/configure_alert.php, include/functions.php,
godmode/agentes/module_manager.php, operation/agentes/networkmap.php,
operation/reporting/reporting_viewer.php,
godmode/agentes/manage_config.php: Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-12 15:31:01 +01:00
* @ param string Input name .
* @ param string Input value .
* @ param string Label to add after the radio button ( optional ) .
2019-01-30 16:18:44 +01:00
* @ param string Checked and selected value , the button will be selected if it matches $value ( optional ) .
2009-01-12 Esteban Sanchez <estebans@artica.es>
* godmode/agentes/alert_manager.php: Complete rewritten of the alert
system when assigned alerts to an agent.
* pandoradb.sql: New tables for alert system. These are:
talert_commands, talert_actions, talert_templates,
talert_template_modules, talert_template_module_actions. No migration
tool is available yet.
* godmode/alerts/configure_alert_template.php,
godmode/alerts/configure_alert_action.php,
godmode/alerts/alert_templates.php,
godmode/alerts/configure_alert_command.php,
godmode/alerts/alert_actions.php: Added to repository. Administration
interface to new alert system.
* godmode/alerts/modify_alert.php: Deleted from repository.
* godmode/setup/setup.php: Added an example of the date format. Main
table has now percentage width.
* godmode/menu.php, operation/menu.php: Added new alert options.
Removed refr value when it's not neccesary.
* include/styles/pandora.css: Added width to textarea elements. Style
correction and cleanup. Tables doesn't have a odd-even pattern, but
the hovered row now changes its colour. New styles for alert pages.
* include/functions_custom_graphs.php: Added to repository. custom
graphs functions moved here.
* include/functions_incidents.php, include/functions_events.php: Moved
to LGPL. Style comment corrections.
* include/functions_html.php: Documentation style correction. Added
print_input_file() and print_label().
* include/functions_ui.php: Doc style correction.
* operation/reporting/graph_viewer.php: Include new function file with
custom graphs. Use generic functions.
* index.php: Unset pass from POST and REQUEST arrays.
* include/functions_db.php: Some documentation updated to new format.
Added format_array_to_update_sql() to generate SQL sentences for
updates. Style correction.
* godmode/agentes/configurar_agente.php: Variables renamed to have a
meaning.
* extensions/update_manager/main.php: Mark an string translatable.
* extensions/update_manager/lib/libupdate_manager_client.php,
godmode/alerts/configure_alert.php, include/functions.php,
godmode/agentes/module_manager.php, operation/agentes/networkmap.php,
operation/reporting/reporting_viewer.php,
godmode/agentes/manage_config.php: Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-12 15:31:01 +01:00
* @ param bool Whether to return an output string or echo now ( optional , echo by default ) .
2008-12-16 11:20:33 +01:00
*
* @ return string HTML code if return parameter is true .
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
*/
2019-01-30 16:18:44 +01:00
function html_print_radio_button ( $name , $value , $label = '' , $checkedvalue = '' , $return = false , $disabled = false )
{
$output = html_print_radio_button_extended ( $name , $value , $label , $checkedvalue , $disabled , '' , '' , true );
if ( $return ) {
return $output ;
}
echo $output ;
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
}
2019-01-30 16:18:44 +01:00
2022-11-30 10:14:42 +01:00
/**
* Render a Switch - Radio selector buttons .
*
* @ param array $switches Switches for add ( html_print_radio_button ) .
* @ param array $attributes Special attributes .
* @ param boolean $return Return . False by default .
*
* @ return mixed .
*/
function html_print_switch_radio_button ( array $switches , array $attributes = [], bool $return = false )
{
2022-12-05 13:39:51 +01:00
// By default, the content are only the switches added.
$content = implode ( '' , $switches );
// If you want add more content, you can attach in attributes.
if ( isset ( $attributes [ 'add_content' ]) === true ) {
$content .= $attributes [ 'add_content' ];
}
2022-11-30 10:14:42 +01:00
return html_print_div (
[
'id' => ( $attributes [ 'id' ] ? ? '' ),
'class' => 'switch_radio_button ' . ( $attributes [ 'class' ] ? ? '' ),
2022-12-05 13:39:51 +01:00
'content' => $content ,
2022-11-30 10:14:42 +01:00
],
$return
);
}
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
/**
2011-04-27 15:43:31 +02:00
* Render a checkbox button input . Extended version , use html_print_checkbox () to simplify .
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
*
2022-11-10 15:06:39 +01:00
* @ param string $name Input name .
* @ param string $value Input value .
* @ param string $checked Set the button to be marked ( optional , unmarked by default ) .
* @ param boolean $disabled Disable the button ( optional , button enabled by default ) .
* @ param string $script Script to execute when onClick event is triggered ( optional ) .
2023-03-08 15:01:41 +01:00
* @ param mixed $attributes Optional HTML attributes . It ' s a free string which will be inserted into the HTML tag , use it carefully ( optional ) .
2022-11-10 15:06:39 +01:00
* @ param boolean $return Whether to return an output string or echo now ( optional , echo by default ) .
* @ param string $id Custom id .
* @ param string $customAttributes Custom Attribute for customized checkbox .
2022-11-30 10:14:42 +01:00
* @ param string $customHTML Custom HTML for customized checkbox .
2008-12-16 11:20:33 +01:00
*
* @ return string HTML code if return parameter is true .
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
*/
2019-11-22 20:49:46 +01:00
function html_print_checkbox_extended (
$name ,
$value ,
$checked ,
$disabled ,
$script ,
$attributes ,
$return = false ,
2022-11-10 15:06:39 +01:00
$id = '' ,
2022-11-30 10:14:42 +01:00
$customAttributes = '' ,
$customHTML = ''
2019-11-22 20:49:46 +01:00
) {
2019-01-30 16:18:44 +01:00
static $idcounter = [];
// If duplicate names exist, it will start numbering. Otherwise it won't
if ( isset ( $idcounter [ $name ])) {
$idcounter [ $name ] ++ ;
} else {
$idcounter [ $name ] = 0 ;
}
2023-02-15 12:48:41 +01:00
$inputClass = 'custom_checkbox_input' ;
$labelClass = 'custom_checkbox' ;
2023-03-08 15:01:41 +01:00
$labelStyle = ' ' ;
2019-01-30 16:18:44 +01:00
2023-02-15 12:48:41 +01:00
if ( is_array ( $attributes ) === true ) {
$tmpAttributes = [];
2023-05-17 10:54:43 +02:00
foreach ( $attributes as $key => $val ) {
2023-02-15 12:48:41 +01:00
switch ( $key ) {
case 'input_class' :
2023-05-17 10:54:43 +02:00
$inputClass .= ' ' . $val ;
2023-02-15 12:48:41 +01:00
break ;
2019-01-30 16:18:44 +01:00
2023-02-15 12:48:41 +01:00
case 'label_class' :
2023-05-17 10:54:43 +02:00
$labelClass .= ' ' . $val ;
2023-02-15 12:48:41 +01:00
break ;
2019-01-30 16:18:44 +01:00
2023-03-08 15:01:41 +01:00
case 'label_style' :
2023-05-17 10:54:43 +02:00
$labelStyle .= 'style="' . $val . '"' ;
2023-03-08 15:01:41 +01:00
break ;
2023-02-15 12:48:41 +01:00
default :
2023-05-17 10:54:43 +02:00
$tmpAttributes [] = $key . '="' . $val . '"' ;
2023-02-15 12:48:41 +01:00
break ;
}
}
$attributes = implode ( ' ' , $tmpAttributes );
2019-01-30 16:18:44 +01:00
}
$id_aux = preg_replace ( '/[^a-z0-9\:\;\-\_]/i' , '' , $name . ( $idcounter [ $name ] ? $idcounter [ $name ] : '' ));
2023-03-08 15:01:41 +01:00
$output = '<label class="' . $labelClass . '"' . $labelStyle . '>' ;
2023-02-15 12:48:41 +01:00
$output .= '<input class="' . $inputClass . '" name="' . $name . '" type="checkbox" value="' . $value . '" ' . ( $checked ? 'checked="checked"' : '' );
2022-11-10 15:06:39 +01:00
$output .= ( empty ( $id ) === true ) ? ' id="checkbox-' . $id_aux . '"' : ' id="' . $id . '"' ;
$output .= ( empty ( $script ) === false ) ? ' onclick="' . $script . '"' : '' ;
$output .= (( bool ) $disabled === true ) ? ' disabled="disabled"' : '' ;
2019-01-30 16:18:44 +01:00
$output .= ' ' . $attributes ;
$output .= ' />' ;
2022-11-30 10:14:42 +01:00
$output .= $customHTML ;
2022-11-10 15:06:39 +01:00
$output .= '<span class="custom_checkbox_show custom_checkbox_image" ' . $customAttributes . '></span>' ;
$output .= '</label>' ;
2019-01-30 16:18:44 +01:00
$output .= " \n " ;
if ( $return === false ) {
echo $output ;
}
return $output ;
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
}
2019-01-30 16:18:44 +01:00
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
/**
* Render a checkbox button input .
*
2022-11-10 15:06:39 +01:00
* @ param string $name Input name .
* @ param string $value Input value .
* @ param string $checked Set the button to be marked ( optional , unmarked by default ) .
* @ param boolean $return Whether to return an output string or echo now ( optional , echo by default ) .
* @ param boolean $disabled Disable the button ( optional , button enabled by default ) .
* @ param string $script Script .
* @ param string $disabled_hidden Disabled_hidden .
* @ param string $attributes Extra attributes .
* @ param string $id Custom ID .
* @ param string $customAttributes Custom Attribute for customized checkbox .
2022-11-30 10:14:42 +01:00
* @ param string $customHTML Custom HTML for customized checkbox .
2008-12-16 11:20:33 +01:00
*
* @ return string HTML code if return parameter is true .
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
*/
2019-11-22 20:49:46 +01:00
function html_print_checkbox (
$name ,
$value ,
$checked = false ,
$return = false ,
$disabled = false ,
$script = '' ,
$disabled_hidden = false ,
$attributes = '' ,
2022-11-10 15:06:39 +01:00
$id = '' ,
2022-11-30 10:14:42 +01:00
$customAttributes = '' ,
$customHTML = ''
2019-11-22 20:49:46 +01:00
) {
$output = html_print_checkbox_extended (
$name ,
$value ,
( bool ) $checked ,
$disabled ,
$script ,
$attributes ,
true ,
2022-11-10 15:06:39 +01:00
$id ,
2022-11-30 10:14:42 +01:00
$customAttributes ,
$customHTML
2019-11-22 20:49:46 +01:00
);
2019-01-30 16:18:44 +01:00
if ( ! $disabled_hidden ) {
$output .= html_print_input_hidden ( $name . '_sent' , 1 , true );
}
if ( $return === false ) {
echo $output ;
}
return $output ;
2008-06-15 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Added to repository. Implements HTML
functions.
* reporting/fgraph.php: Many style correction fixes, including those
regardings tabs and blank spaces, variable names and indentation
levels for checkings. Improved dame_fecha(). Added date support to
graphic_combined_module(), grafico_modulo_sparse(). The selection of
the graphic to show based on parameters has been replaced by a switch.
The parameters are parsed with get_parameter()
* include/functions_db.php: Style correction of tabs and blanks
spaces. Use Pandora database functions on simple querying functions
such as dame_perfil(), give_disabled_group(), dame_grupo(),
give_note_author(), dame_agente_id(), dame_agente_modulo_id() and many
more, there are a lot more to change. Function comprueba_admin()
renamed to check_admin (wrap created for old function). Added some
checks to get_db_value(), get_db_row() so the SQL is build based on
the parameter types. Added get_db_all_rows_sqlfree(),
get_db_all_rows_in_table(), get_db_all_rows_field_filter(),
get_db_all_fields_in_table(). Added date support to
return_moduledata_avg_value(), return_moduledata_max_value(),
return_moduledata_min_value(). Added function
return_moduledata_sum_value() to get the sum of the values in a
module.
* include/functions.php: If input is numeric on safe_input, do not
clean it, since it's safe by itself. Use mysql_escape_string() on
salida_sql(). Added get_report_types(), get_report_name(),
get_report_type_data_source() relatives to reports. Added also
is_module_data(), is_module_proc(), is_module_inc(),
is_module_data_string() to know if a module is from a type. Replaced
form_priority() with get_event_types() so the caller of this function
will print the select (using print_select).
* operation/events/events.php: Replaced form_priorit() with
get_event_types().
* ChangeLog: Tab style correction with previous commit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-16 12:45:08 +02:00
}
2019-01-30 16:18:44 +01:00
2019-01-17 17:28:23 +01:00
/**
2020-06-30 12:16:51 +02:00
* Render a checkbox button input switch type .
* Extended version , use html_print_checkbox_switch () to simplify .
2019-01-17 17:28:23 +01:00
*
2020-06-30 12:16:51 +02:00
* @ param string $name Input name .
* @ param integer $value Input value .
* @ param integer $checked Input checked .
* @ param boolean $disabled Disable the button ( optional ,
* button enabled by default ) .
* @ param string $script Script to execute when onClick event
* is triggered ( optional ) .
* @ param string $attributes Optional HTML attributes .
* It ' s a free string which will be .
* @ param boolean $return Whether to return an output string or echo now
* ( optional , echo by default ) .
* @ param string $id Input id .
* @ param string $classParent Class for label .
2019-01-17 17:28:23 +01:00
*
2020-06-30 12:16:51 +02:00
* @ return string Input html .
2019-01-17 17:28:23 +01:00
*/
2020-06-30 12:16:51 +02:00
function html_print_checkbox_switch_extended (
$name ,
$value ,
$checked ,
$disabled = false ,
$script = '' ,
$attributes = '' ,
$return = false ,
$id = '' ,
$classParent = ''
) {
2019-02-06 16:11:46 +01:00
static $idcounter = [];
2020-06-30 12:16:51 +02:00
// If duplicate names exist, it will start numbering. Otherwise it won't.
2019-02-06 16:11:46 +01:00
if ( isset ( $idcounter [ $name ])) {
$idcounter [ $name ] ++ ;
} else {
$idcounter [ $name ] = 0 ;
}
2020-06-30 12:16:51 +02:00
$id_aux = preg_replace (
'/[^a-z0-9\:\;\-\_]/i' ,
'' ,
$name . ( $idcounter [ $name ] ? $idcounter [ $name ] : '' )
);
2019-02-06 16:11:46 +01:00
2023-06-07 12:46:39 +02:00
$output = '<label class="p-switch pdd_0px ' . $classParent . '">' ;
2020-06-30 12:16:51 +02:00
$output .= '<input name="' . $name . '" type="checkbox" value="' . $value . '" ' . ( $checked ? 'checked="checked"' : '' );
2019-02-06 16:11:46 +01:00
if ( $id == '' ) {
$output .= ' id="checkbox-' . $id_aux . '"' ;
} else {
2021-02-04 18:19:35 +01:00
$output .= ' id="' . $id . '"' ;
2019-02-06 16:11:46 +01:00
}
if ( $script != '' ) {
$output .= ' onclick="' . $script . '"' ;
}
if ( $disabled ) {
$output .= ' disabled="disabled"' ;
}
$output .= ' ' . $attributes ;
2019-02-26 12:04:18 +01:00
$output .= ' /><span class="p-slider"></span></label>' ;
2019-02-06 16:11:46 +01:00
$output .= " \n " ;
if ( $return === false ) {
echo $output ;
}
return $output ;
2019-01-17 17:28:23 +01:00
}
2019-02-06 16:11:46 +01:00
2019-01-17 17:28:23 +01:00
/**
2019-02-26 12:04:18 +01:00
* Render a checkbox button input switch type .
2019-01-17 17:28:23 +01:00
*
* @ param string Input name .
* @ param string Input value .
* @ param string Set the button to be marked ( optional , unmarked by default ) .
* @ param bool Whether to return an output string or echo now ( optional , echo by default ) .
2019-02-06 16:11:46 +01:00
* @ param boolean $disabled Disable the button ( optional , button enabled by default ) .
2019-01-17 17:28:23 +01:00
*
* @ return string HTML code if return parameter is true .
*/
2019-02-06 16:11:46 +01:00
2023-07-17 12:32:47 +02:00
function html_print_checkbox_switch ( $name , $value , $checked = false , $return = false , $disabled = false , $script = '' , $disabled_hidden = false , $class = '' )
2019-02-06 16:11:46 +01:00
{
2023-07-17 12:32:47 +02:00
$output = html_print_checkbox_switch_extended ( $name , $value , ( bool ) $checked , $disabled , $script , '' , true , '' , $class );
2019-02-06 16:11:46 +01:00
if ( ! $disabled_hidden ) {
$output .= html_print_input_hidden ( $name . '_sent' , 1 , true );
}
if ( $return === false ) {
echo $output ;
}
return $output ;
2019-01-17 17:28:23 +01:00
}
2019-02-06 16:11:46 +01:00
2008-12-16 11:20:33 +01:00
/**
* Prints an image HTML element .
*
2019-03-07 15:10:38 +01:00
* @ param string $src Image source filename .
* @ param boolean $return Whether to return or print .
* @ param array $options Array with optional HTML options to set .
* At this moment , the following options are supported :
* align , border , hspace , ismap , vspace , style , title , height ,
* longdesc , usemap , width , id , class , lang , xml : lang , onclick ,
* ondblclick , onmousedown , onmouseup , onmouseover , onmousemove ,
* onmouseout , onkeypress , onkeydown , onkeyup , pos_tree , alt .
* @ param boolean $return_src Whether to return src field of image
* ( 'images/*.*' ) or complete html img tag ( '<img src="..." alt="...">' ) .
* @ param boolean $relative Whether to use relative path to image or not
* ( i . e . $relative = true : / pandora /< img_src > ) .
* @ param boolean $no_in_meta Do not show on metaconsole folder at first . Go
* directly to the node .
* @ param boolean $isExternalLink Do not shearch for images in Pandora .
2019-01-30 16:18:44 +01:00
*
2008-12-16 11:20:33 +01:00
* @ return string HTML code if return parameter is true .
*/
2019-01-30 16:18:44 +01:00
function html_print_image (
$src ,
$return = false ,
$options = false ,
$return_src = false ,
$relative = false ,
$no_in_meta = false ,
$isExternalLink = false
) {
global $config ;
2019-03-07 15:10:38 +01:00
// If metaconsole is in use then don't use skins.
2019-01-30 16:18:44 +01:00
if ( ! is_metaconsole ()) {
2019-03-07 15:10:38 +01:00
// Checks if user's skin is available.
2019-01-30 16:18:44 +01:00
$isFunctionSkins = enterprise_include_once ( 'include/functions_skins.php' );
if ( $isFunctionSkins !== ENTERPRISE_NOT_HOOK ) {
$skin_path = enterprise_hook ( 'skins_get_image_path' , [ $src ]);
if ( $skin_path ) {
$src = $skin_path ;
}
}
}
2019-03-07 15:10:38 +01:00
// If metaconsole is activated and image doesn't exists try to search on normal console.
2019-01-30 16:18:44 +01:00
if ( is_metaconsole ()) {
if ( ! $relative ) {
$working_dir = str_replace ( '\\' , '/' , getcwd ());
2019-03-07 15:10:38 +01:00
// Windows compatibility.
2019-01-30 16:18:44 +01:00
if ( $no_in_meta ) {
$src = '../../' . $src ;
} else if ( strstr ( $working_dir , 'enterprise/meta' ) === false ) {
if ( $src [ 0 ] !== '/' ) {
$src = '/' . $src ;
}
if ( ! is_readable ( $working_dir . '/enterprise/meta' . $src )) {
if ( $isExternalLink ) {
2019-09-05 11:58:15 +02:00
$src = ui_get_full_url ( $src , false , false , false );
2019-01-30 16:18:44 +01:00
} else {
$src = ui_get_full_url ( '../..' . $src );
}
} else {
$src = ui_get_full_url ( $src );
}
} else {
if ( $src [ 0 ] !== '/' ) {
$src = '/' . $src ;
}
if ( is_readable ( $working_dir . $src )) {
$src = ui_get_full_url ( $src );
} else if ( ! is_readable ( $src )) {
$src = ui_get_full_url ( '../../' . $src );
}
}
} else {
$src = '../../' . $src ;
}
} else {
if ( ! $relative ) {
$src_tmp = $src ;
$src = ui_get_full_url ( $src );
}
}
2019-03-07 15:10:38 +01:00
// Only return src field of image.
2019-01-30 16:18:44 +01:00
if ( $return_src ) {
if ( ! $return ) {
echo io_safe_input ( $src );
2019-03-07 15:10:38 +01:00
return null ;
2019-01-30 16:18:44 +01:00
}
return io_safe_input ( $src );
}
$output = '<img src="' . $src . '" ' ;
2019-03-07 15:10:38 +01:00
// Dont use safe_input here or the performance will dead.
2019-01-30 16:18:44 +01:00
$style = '' ;
if ( ! empty ( $options )) {
2019-03-07 15:10:38 +01:00
// Deprecated or value-less attributes.
2019-01-30 16:18:44 +01:00
if ( isset ( $options [ 'align' ])) {
$style .= 'align:' . $options [ 'align' ] . ';' ;
// Align is deprecated, use styles.
}
if ( isset ( $options [ 'border' ])) {
$style .= 'border:' . $options [ 'border' ] . 'px;' ;
2019-03-07 15:10:38 +01:00
// Border is deprecated, use styles.
2019-01-30 16:18:44 +01:00
}
if ( isset ( $options [ 'hspace' ])) {
$style .= 'margin-left:' . $options [ 'hspace' ] . 'px;' ;
2019-03-07 15:10:38 +01:00
// hspace is deprecated, use styles.
2019-01-30 16:18:44 +01:00
$style .= 'margin-right:' . $options [ 'hspace' ] . 'px;' ;
}
if ( isset ( $options [ 'ismap' ])) {
$output .= 'ismap="ismap" ' ;
2019-03-07 15:10:38 +01:00
// Defines the image as a server-side image map.
2019-01-30 16:18:44 +01:00
}
if ( isset ( $options [ 'vspace' ])) {
$style .= 'margin-top:' . $options [ 'vspace' ] . 'px;' ;
2019-03-07 15:10:38 +01:00
// hspace is deprecated, use styles.
2019-01-30 16:18:44 +01:00
$style .= 'margin-bottom:' . $options [ 'vspace' ] . 'px;' ;
}
if ( isset ( $options [ 'style' ])) {
$style .= $options [ 'style' ];
}
2019-03-07 15:10:38 +01:00
// If title is provided activate forced title.
2019-01-30 16:18:44 +01:00
if ( isset ( $options [ 'title' ]) && $options [ 'title' ] != '' ) {
if ( isset ( $options [ 'class' ])) {
$options [ 'class' ] .= ' forced_title' ;
} else {
$options [ 'class' ] = 'forced_title' ;
}
2019-03-07 15:10:38 +01:00
// New way to show the force_title (cleaner and better performance).
2019-01-30 16:18:44 +01:00
$output .= 'data-title="' . io_safe_input_html ( $options [ 'title' ]) . '" ' ;
$output .= 'data-use_title_for_force_title="1" ' ;
}
2023-05-10 12:53:03 +02:00
if ( isset ( $options [ 'main_menu_icon' ]) && $options [ 'main_menu_icon' ] != '' ) {
if ( isset ( $options [ 'class' ])) {
$options [ 'class' ] .= ' main_menu_icon' ;
} else {
$options [ 'class' ] = 'main_menu_icon' ;
}
}
2019-03-07 15:10:38 +01:00
// Valid attributes (invalid attributes get skipped).
2019-01-30 16:18:44 +01:00
$attrs = [
'height' ,
'longdesc' ,
'usemap' ,
'width' ,
'id' ,
'class' ,
'lang' ,
'xml:lang' ,
'onclick' ,
'ondblclick' ,
'onmousedown' ,
'onmouseup' ,
'onmouseover' ,
'onmousemove' ,
'onmouseout' ,
'onkeypress' ,
'onkeydown' ,
'onkeyup' ,
2021-09-02 16:12:46 +02:00
'onload' ,
2019-01-30 16:18:44 +01:00
'pos_tree' ,
];
foreach ( $attrs as $attribute ) {
if ( isset ( $options [ $attribute ])) {
$output .= $attribute . '="' . io_safe_input_html ( $options [ $attribute ]) . '" ' ;
}
}
} else {
$options = [];
}
if ( ! isset ( $options [ 'alt' ]) && isset ( $options [ 'title' ])) {
$options [ 'alt' ] = io_safe_input_html ( $options [ 'title' ]);
2019-03-07 15:10:38 +01:00
// Set alt to title if it's not set.
2019-01-30 16:18:44 +01:00
}
if ( ! empty ( $style )) {
$output .= 'style="' . $style . '" ' ;
}
if ( isset ( $options [ 'alt' ])) {
$output .= 'alt="' . io_safe_input_html ( $options [ 'alt' ]) . '" />' ;
} else {
$output .= '/>' ;
}
if ( ! $return ) {
echo $output ;
}
return $output ;
2008-12-16 11:20:33 +01:00
}
2009-01-12 Esteban Sanchez <estebans@artica.es>
* godmode/agentes/alert_manager.php: Complete rewritten of the alert
system when assigned alerts to an agent.
* pandoradb.sql: New tables for alert system. These are:
talert_commands, talert_actions, talert_templates,
talert_template_modules, talert_template_module_actions. No migration
tool is available yet.
* godmode/alerts/configure_alert_template.php,
godmode/alerts/configure_alert_action.php,
godmode/alerts/alert_templates.php,
godmode/alerts/configure_alert_command.php,
godmode/alerts/alert_actions.php: Added to repository. Administration
interface to new alert system.
* godmode/alerts/modify_alert.php: Deleted from repository.
* godmode/setup/setup.php: Added an example of the date format. Main
table has now percentage width.
* godmode/menu.php, operation/menu.php: Added new alert options.
Removed refr value when it's not neccesary.
* include/styles/pandora.css: Added width to textarea elements. Style
correction and cleanup. Tables doesn't have a odd-even pattern, but
the hovered row now changes its colour. New styles for alert pages.
* include/functions_custom_graphs.php: Added to repository. custom
graphs functions moved here.
* include/functions_incidents.php, include/functions_events.php: Moved
to LGPL. Style comment corrections.
* include/functions_html.php: Documentation style correction. Added
print_input_file() and print_label().
* include/functions_ui.php: Doc style correction.
* operation/reporting/graph_viewer.php: Include new function file with
custom graphs. Use generic functions.
* index.php: Unset pass from POST and REQUEST arrays.
* include/functions_db.php: Some documentation updated to new format.
Added format_array_to_update_sql() to generate SQL sentences for
updates. Style correction.
* godmode/agentes/configurar_agente.php: Variables renamed to have a
meaning.
* extensions/update_manager/main.php: Mark an string translatable.
* extensions/update_manager/lib/libupdate_manager_client.php,
godmode/alerts/configure_alert.php, include/functions.php,
godmode/agentes/module_manager.php, operation/agentes/networkmap.php,
operation/reporting/reporting_viewer.php,
godmode/agentes/manage_config.php: Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-12 15:31:01 +01:00
2019-01-30 16:18:44 +01:00
2022-06-13 16:23:37 +02:00
/**
* Function for print the logo in menu header .
*
* @ param boolean $menuCollapsed If true , the menu is collapsed .
* @ param boolean $return If true , the formed element is returned .
*
* @ return mixed .
*/
function html_print_header_logo_image ( bool $menuCollapsed , bool $return = false )
{
global $config ;
if ( defined ( 'PANDORA_ENTERPRISE' ) === false ) {
if ( $config [ 'style' ] === 'pandora_black' ) {
$custom_logo = 'images/custom_logo/' . HEADER_LOGO_BLACK_CLASSIC ;
$custom_logo_collapsed = 'images/custom_logo/' . HEADER_LOGO_DEFAULT_COLLAPSED ;
} else if ( $config [ 'style' ] === 'pandora' ) {
$custom_logo = 'images/custom_logo/' . HEADER_LOGO_DEFAULT_CLASSIC ;
$custom_logo_collapsed = 'images/custom_logo/' . HEADER_LOGO_DEFAULT_COLLAPSED ;
}
$logo_title = get_product_name () . ' Opensource' ;
} else {
// Handle default logos when change theme.
if ( $config [ 'style' ] === 'pandora_black' && $config [ 'custom_logo' ] === HEADER_LOGO_DEFAULT_CLASSIC ) {
$config [ 'custom_logo' ] = HEADER_LOGO_BLACK_CLASSIC ;
} else if ( $config [ 'style' ] === 'pandora' && $config [ 'custom_logo' ] === HEADER_LOGO_BLACK_CLASSIC ) {
$config [ 'custom_logo' ] = HEADER_LOGO_DEFAULT_CLASSIC ;
}
$logo_title = get_product_name () . ' Enterprise' ;
$custom_logo = 'images/custom_logo/' . $config [ 'custom_logo' ];
$custom_logo_collapsed = 'images/custom_logo/' . $config [ 'custom_logo_collapsed' ];
if ( file_exists ( ENTERPRISE_DIR . '/' . $custom_logo ) === true ) {
$custom_logo = ENTERPRISE_DIR . '/' . $custom_logo ;
}
}
if ( isset ( $config [ 'custom_logo' ]) === true ) {
$output = html_print_image (
$custom_logo ,
true ,
[
'border' => '0' ,
'width' => '215' ,
'alt' => $logo_title ,
'class' => 'logo_full' ,
'style' => ( $menuCollapsed === true ) ? 'display:none' : 'display:block' ,
]
);
}
if ( isset ( $config [ 'custom_logo_collapsed' ]) === true ) {
$output .= html_print_image (
$custom_logo_collapsed ,
true ,
[
'border' => '0' ,
2023-02-13 09:31:33 +01:00
'width' => '35' ,
2022-06-13 16:23:37 +02:00
'alt' => $logo_title ,
'class' => 'logo_icon' ,
'style' => ( $menuCollapsed === true ) ? 'display:block' : 'display:none' ,
]
);
}
if ( $return === false ) {
echo $output ;
} else {
return $output ;
}
}
2009-01-12 Esteban Sanchez <estebans@artica.es>
* godmode/agentes/alert_manager.php: Complete rewritten of the alert
system when assigned alerts to an agent.
* pandoradb.sql: New tables for alert system. These are:
talert_commands, talert_actions, talert_templates,
talert_template_modules, talert_template_module_actions. No migration
tool is available yet.
* godmode/alerts/configure_alert_template.php,
godmode/alerts/configure_alert_action.php,
godmode/alerts/alert_templates.php,
godmode/alerts/configure_alert_command.php,
godmode/alerts/alert_actions.php: Added to repository. Administration
interface to new alert system.
* godmode/alerts/modify_alert.php: Deleted from repository.
* godmode/setup/setup.php: Added an example of the date format. Main
table has now percentage width.
* godmode/menu.php, operation/menu.php: Added new alert options.
Removed refr value when it's not neccesary.
* include/styles/pandora.css: Added width to textarea elements. Style
correction and cleanup. Tables doesn't have a odd-even pattern, but
the hovered row now changes its colour. New styles for alert pages.
* include/functions_custom_graphs.php: Added to repository. custom
graphs functions moved here.
* include/functions_incidents.php, include/functions_events.php: Moved
to LGPL. Style comment corrections.
* include/functions_html.php: Documentation style correction. Added
print_input_file() and print_label().
* include/functions_ui.php: Doc style correction.
* operation/reporting/graph_viewer.php: Include new function file with
custom graphs. Use generic functions.
* index.php: Unset pass from POST and REQUEST arrays.
* include/functions_db.php: Some documentation updated to new format.
Added format_array_to_update_sql() to generate SQL sentences for
updates. Style correction.
* godmode/agentes/configurar_agente.php: Variables renamed to have a
meaning.
* extensions/update_manager/main.php: Mark an string translatable.
* extensions/update_manager/lib/libupdate_manager_client.php,
godmode/alerts/configure_alert.php, include/functions.php,
godmode/agentes/module_manager.php, operation/agentes/networkmap.php,
operation/reporting/reporting_viewer.php,
godmode/agentes/manage_config.php: Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-12 15:31:01 +01:00
/**
2011-04-27 15:43:31 +02:00
* Render an input text element . Extended version , use html_print_input_text () to simplify .
2009-01-12 Esteban Sanchez <estebans@artica.es>
* godmode/agentes/alert_manager.php: Complete rewritten of the alert
system when assigned alerts to an agent.
* pandoradb.sql: New tables for alert system. These are:
talert_commands, talert_actions, talert_templates,
talert_template_modules, talert_template_module_actions. No migration
tool is available yet.
* godmode/alerts/configure_alert_template.php,
godmode/alerts/configure_alert_action.php,
godmode/alerts/alert_templates.php,
godmode/alerts/configure_alert_command.php,
godmode/alerts/alert_actions.php: Added to repository. Administration
interface to new alert system.
* godmode/alerts/modify_alert.php: Deleted from repository.
* godmode/setup/setup.php: Added an example of the date format. Main
table has now percentage width.
* godmode/menu.php, operation/menu.php: Added new alert options.
Removed refr value when it's not neccesary.
* include/styles/pandora.css: Added width to textarea elements. Style
correction and cleanup. Tables doesn't have a odd-even pattern, but
the hovered row now changes its colour. New styles for alert pages.
* include/functions_custom_graphs.php: Added to repository. custom
graphs functions moved here.
* include/functions_incidents.php, include/functions_events.php: Moved
to LGPL. Style comment corrections.
* include/functions_html.php: Documentation style correction. Added
print_input_file() and print_label().
* include/functions_ui.php: Doc style correction.
* operation/reporting/graph_viewer.php: Include new function file with
custom graphs. Use generic functions.
* index.php: Unset pass from POST and REQUEST arrays.
* include/functions_db.php: Some documentation updated to new format.
Added format_array_to_update_sql() to generate SQL sentences for
updates. Style correction.
* godmode/agentes/configurar_agente.php: Variables renamed to have a
meaning.
* extensions/update_manager/main.php: Mark an string translatable.
* extensions/update_manager/lib/libupdate_manager_client.php,
godmode/alerts/configure_alert.php, include/functions.php,
godmode/agentes/module_manager.php, operation/agentes/networkmap.php,
operation/reporting/reporting_viewer.php,
godmode/agentes/manage_config.php: Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-12 15:31:01 +01:00
*
* @ param string Input name .
* @ param bool Whether to return an output string or echo now ( optional , echo by default ) .
2019-01-30 16:18:44 +01:00
* @ param array An array with optional HTML parameters .
* Key size : HTML size attribute .
* Key disabled : Whether to disable the input or not .
* Key class : HTML class
2009-01-12 Esteban Sanchez <estebans@artica.es>
* godmode/agentes/alert_manager.php: Complete rewritten of the alert
system when assigned alerts to an agent.
* pandoradb.sql: New tables for alert system. These are:
talert_commands, talert_actions, talert_templates,
talert_template_modules, talert_template_module_actions. No migration
tool is available yet.
* godmode/alerts/configure_alert_template.php,
godmode/alerts/configure_alert_action.php,
godmode/alerts/alert_templates.php,
godmode/alerts/configure_alert_command.php,
godmode/alerts/alert_actions.php: Added to repository. Administration
interface to new alert system.
* godmode/alerts/modify_alert.php: Deleted from repository.
* godmode/setup/setup.php: Added an example of the date format. Main
table has now percentage width.
* godmode/menu.php, operation/menu.php: Added new alert options.
Removed refr value when it's not neccesary.
* include/styles/pandora.css: Added width to textarea elements. Style
correction and cleanup. Tables doesn't have a odd-even pattern, but
the hovered row now changes its colour. New styles for alert pages.
* include/functions_custom_graphs.php: Added to repository. custom
graphs functions moved here.
* include/functions_incidents.php, include/functions_events.php: Moved
to LGPL. Style comment corrections.
* include/functions_html.php: Documentation style correction. Added
print_input_file() and print_label().
* include/functions_ui.php: Doc style correction.
* operation/reporting/graph_viewer.php: Include new function file with
custom graphs. Use generic functions.
* index.php: Unset pass from POST and REQUEST arrays.
* include/functions_db.php: Some documentation updated to new format.
Added format_array_to_update_sql() to generate SQL sentences for
updates. Style correction.
* godmode/agentes/configurar_agente.php: Variables renamed to have a
meaning.
* extensions/update_manager/main.php: Mark an string translatable.
* extensions/update_manager/lib/libupdate_manager_client.php,
godmode/alerts/configure_alert.php, include/functions.php,
godmode/agentes/module_manager.php, operation/agentes/networkmap.php,
operation/reporting/reporting_viewer.php,
godmode/agentes/manage_config.php: Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-12 15:31:01 +01:00
*/
2019-01-30 16:18:44 +01:00
function html_print_input_file ( $name , $return = false , $options = false )
{
$output = '' ;
2022-11-04 08:43:18 +01:00
// Start to build the input.
$output .= '<label class="inputFile">' ;
2019-01-30 16:18:44 +01:00
$output .= '<input type="file" value="" name="' . $name . '" id="file-' . $name . '" ' ;
if ( $options ) {
if ( isset ( $options [ 'size' ])) {
2021-11-03 17:30:54 +01:00
$output .= ' size="' . $options [ 'size' ] . '"' ;
2019-01-30 16:18:44 +01:00
}
if ( isset ( $options [ 'disabled' ])) {
2021-11-03 17:30:54 +01:00
$output .= ' disabled="disabled"' ;
2019-01-30 16:18:44 +01:00
}
if ( isset ( $options [ 'class' ])) {
2021-11-03 17:30:54 +01:00
$output .= ' class="' . $options [ 'class' ] . '"' ;
}
if ( isset ( $options [ 'required' ])) {
$output .= ' required' ;
2019-01-30 16:18:44 +01:00
}
2021-11-26 18:11:34 +01:00
if ( isset ( $options [ 'onchange' ])) {
$output .= ' onchange="' . $options [ 'onchange' ] . '"' ;
}
2022-03-09 17:27:08 +01:00
if ( isset ( $options [ 'style' ]) === true ) {
$output .= ' style="' . $options [ 'style' ] . '"' ;
}
2023-03-09 15:14:47 +01:00
if ( isset ( $options [ 'accept' ]) === true ) {
$output .= ' accept="' . $options [ 'accept' ] . '"' ;
}
2023-03-23 17:44:04 +01:00
$label = '' ;
if ( isset ( $options [ 'label' ]) === true ) {
$label = $options [ 'label' ];
}
2019-01-30 16:18:44 +01:00
}
2022-11-04 08:43:18 +01:00
// Close input.
$output .= '/>' ;
2023-03-23 17:44:04 +01:00
$output .= ( $options [ 'caption' ] ? ? __ ( 'Select a file' ));
2023-02-15 10:39:45 +01:00
2022-11-04 08:43:18 +01:00
$output .= '</label>' ;
$output .= '<span class="inputFileSpan" id="span-' . $name . '"> </span>' ;
// Add script.
$output .= '<script>' ;
$output .= 'let inputElement = document.getElementById("file-' . $name . ' " );
let inputFilename = document . getElementById ( " span-'. $name .' " );
inputElement . addEventListener ( " change " , () => {
let inputImage = document . querySelector ( " input[type=file] " ) . files [ 0 ];
2023-06-27 11:48:45 +02:00
if ( inputImage . name . length >= 45 ) {
let name = inputImage . name . substring ( 0 , 20 ) + " ... " + inputImage . name . substring (( inputImage . name . length - 17 ), inputImage . name . length );
inputFilename . innerText = name ;
} else {
inputFilename . innerText = inputImage . name ;
}
2022-11-04 08:43:18 +01:00
}); ' ;
$output .= '</script>' ;
2019-01-30 16:18:44 +01:00
if ( $return ) {
return $output ;
}
echo $output ;
2009-01-12 Esteban Sanchez <estebans@artica.es>
* godmode/agentes/alert_manager.php: Complete rewritten of the alert
system when assigned alerts to an agent.
* pandoradb.sql: New tables for alert system. These are:
talert_commands, talert_actions, talert_templates,
talert_template_modules, talert_template_module_actions. No migration
tool is available yet.
* godmode/alerts/configure_alert_template.php,
godmode/alerts/configure_alert_action.php,
godmode/alerts/alert_templates.php,
godmode/alerts/configure_alert_command.php,
godmode/alerts/alert_actions.php: Added to repository. Administration
interface to new alert system.
* godmode/alerts/modify_alert.php: Deleted from repository.
* godmode/setup/setup.php: Added an example of the date format. Main
table has now percentage width.
* godmode/menu.php, operation/menu.php: Added new alert options.
Removed refr value when it's not neccesary.
* include/styles/pandora.css: Added width to textarea elements. Style
correction and cleanup. Tables doesn't have a odd-even pattern, but
the hovered row now changes its colour. New styles for alert pages.
* include/functions_custom_graphs.php: Added to repository. custom
graphs functions moved here.
* include/functions_incidents.php, include/functions_events.php: Moved
to LGPL. Style comment corrections.
* include/functions_html.php: Documentation style correction. Added
print_input_file() and print_label().
* include/functions_ui.php: Doc style correction.
* operation/reporting/graph_viewer.php: Include new function file with
custom graphs. Use generic functions.
* index.php: Unset pass from POST and REQUEST arrays.
* include/functions_db.php: Some documentation updated to new format.
Added format_array_to_update_sql() to generate SQL sentences for
updates. Style correction.
* godmode/agentes/configurar_agente.php: Variables renamed to have a
meaning.
* extensions/update_manager/main.php: Mark an string translatable.
* extensions/update_manager/lib/libupdate_manager_client.php,
godmode/alerts/configure_alert.php, include/functions.php,
godmode/agentes/module_manager.php, operation/agentes/networkmap.php,
operation/reporting/reporting_viewer.php,
godmode/agentes/manage_config.php: Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-12 15:31:01 +01:00
}
2019-01-30 16:18:44 +01:00
2009-01-12 Esteban Sanchez <estebans@artica.es>
* godmode/agentes/alert_manager.php: Complete rewritten of the alert
system when assigned alerts to an agent.
* pandoradb.sql: New tables for alert system. These are:
talert_commands, talert_actions, talert_templates,
talert_template_modules, talert_template_module_actions. No migration
tool is available yet.
* godmode/alerts/configure_alert_template.php,
godmode/alerts/configure_alert_action.php,
godmode/alerts/alert_templates.php,
godmode/alerts/configure_alert_command.php,
godmode/alerts/alert_actions.php: Added to repository. Administration
interface to new alert system.
* godmode/alerts/modify_alert.php: Deleted from repository.
* godmode/setup/setup.php: Added an example of the date format. Main
table has now percentage width.
* godmode/menu.php, operation/menu.php: Added new alert options.
Removed refr value when it's not neccesary.
* include/styles/pandora.css: Added width to textarea elements. Style
correction and cleanup. Tables doesn't have a odd-even pattern, but
the hovered row now changes its colour. New styles for alert pages.
* include/functions_custom_graphs.php: Added to repository. custom
graphs functions moved here.
* include/functions_incidents.php, include/functions_events.php: Moved
to LGPL. Style comment corrections.
* include/functions_html.php: Documentation style correction. Added
print_input_file() and print_label().
* include/functions_ui.php: Doc style correction.
* operation/reporting/graph_viewer.php: Include new function file with
custom graphs. Use generic functions.
* index.php: Unset pass from POST and REQUEST arrays.
* include/functions_db.php: Some documentation updated to new format.
Added format_array_to_update_sql() to generate SQL sentences for
updates. Style correction.
* godmode/agentes/configurar_agente.php: Variables renamed to have a
meaning.
* extensions/update_manager/main.php: Mark an string translatable.
* extensions/update_manager/lib/libupdate_manager_client.php,
godmode/alerts/configure_alert.php, include/functions.php,
godmode/agentes/module_manager.php, operation/agentes/networkmap.php,
operation/reporting/reporting_viewer.php,
godmode/agentes/manage_config.php: Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-12 15:31:01 +01:00
/**
* Render a label for a input elemennt .
*
* @ param string Label text .
* @ param string Input id to refer .
* @ param bool Whether to return an output string or echo now ( optional , echo by default ) .
2019-01-30 16:18:44 +01:00
* @ param array An array with optional HTML parameters .
* Key html : Extra HTML to add after the label .
* Key class : HTML class
2009-01-12 Esteban Sanchez <estebans@artica.es>
* godmode/agentes/alert_manager.php: Complete rewritten of the alert
system when assigned alerts to an agent.
* pandoradb.sql: New tables for alert system. These are:
talert_commands, talert_actions, talert_templates,
talert_template_modules, talert_template_module_actions. No migration
tool is available yet.
* godmode/alerts/configure_alert_template.php,
godmode/alerts/configure_alert_action.php,
godmode/alerts/alert_templates.php,
godmode/alerts/configure_alert_command.php,
godmode/alerts/alert_actions.php: Added to repository. Administration
interface to new alert system.
* godmode/alerts/modify_alert.php: Deleted from repository.
* godmode/setup/setup.php: Added an example of the date format. Main
table has now percentage width.
* godmode/menu.php, operation/menu.php: Added new alert options.
Removed refr value when it's not neccesary.
* include/styles/pandora.css: Added width to textarea elements. Style
correction and cleanup. Tables doesn't have a odd-even pattern, but
the hovered row now changes its colour. New styles for alert pages.
* include/functions_custom_graphs.php: Added to repository. custom
graphs functions moved here.
* include/functions_incidents.php, include/functions_events.php: Moved
to LGPL. Style comment corrections.
* include/functions_html.php: Documentation style correction. Added
print_input_file() and print_label().
* include/functions_ui.php: Doc style correction.
* operation/reporting/graph_viewer.php: Include new function file with
custom graphs. Use generic functions.
* index.php: Unset pass from POST and REQUEST arrays.
* include/functions_db.php: Some documentation updated to new format.
Added format_array_to_update_sql() to generate SQL sentences for
updates. Style correction.
* godmode/agentes/configurar_agente.php: Variables renamed to have a
meaning.
* extensions/update_manager/main.php: Mark an string translatable.
* extensions/update_manager/lib/libupdate_manager_client.php,
godmode/alerts/configure_alert.php, include/functions.php,
godmode/agentes/module_manager.php, operation/agentes/networkmap.php,
operation/reporting/reporting_viewer.php,
godmode/agentes/manage_config.php: Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-12 15:31:01 +01:00
*/
2019-01-30 16:18:44 +01:00
function html_print_label ( $text , $id , $return = false , $options = false )
{
$output = '' ;
$output .= '<label id="label-' . $id . '" ' ;
if ( $options ) {
if ( isset ( $options [ 'class' ])) {
$output .= 'class="' . $options [ 'class' ] . '" ' ;
}
if ( isset ( $options [ 'style' ])) {
$output .= 'style="' . $options [ 'style' ] . '" ' ;
}
}
$output .= 'for="' . $id . '" >' ;
$output .= $text ;
$output .= '</label>' ;
if ( $options ) {
if ( isset ( $options [ 'html' ])) {
$output .= $options [ 'html' ];
}
}
if ( $return ) {
return $output ;
}
echo $output ;
2009-01-12 Esteban Sanchez <estebans@artica.es>
* godmode/agentes/alert_manager.php: Complete rewritten of the alert
system when assigned alerts to an agent.
* pandoradb.sql: New tables for alert system. These are:
talert_commands, talert_actions, talert_templates,
talert_template_modules, talert_template_module_actions. No migration
tool is available yet.
* godmode/alerts/configure_alert_template.php,
godmode/alerts/configure_alert_action.php,
godmode/alerts/alert_templates.php,
godmode/alerts/configure_alert_command.php,
godmode/alerts/alert_actions.php: Added to repository. Administration
interface to new alert system.
* godmode/alerts/modify_alert.php: Deleted from repository.
* godmode/setup/setup.php: Added an example of the date format. Main
table has now percentage width.
* godmode/menu.php, operation/menu.php: Added new alert options.
Removed refr value when it's not neccesary.
* include/styles/pandora.css: Added width to textarea elements. Style
correction and cleanup. Tables doesn't have a odd-even pattern, but
the hovered row now changes its colour. New styles for alert pages.
* include/functions_custom_graphs.php: Added to repository. custom
graphs functions moved here.
* include/functions_incidents.php, include/functions_events.php: Moved
to LGPL. Style comment corrections.
* include/functions_html.php: Documentation style correction. Added
print_input_file() and print_label().
* include/functions_ui.php: Doc style correction.
* operation/reporting/graph_viewer.php: Include new function file with
custom graphs. Use generic functions.
* index.php: Unset pass from POST and REQUEST arrays.
* include/functions_db.php: Some documentation updated to new format.
Added format_array_to_update_sql() to generate SQL sentences for
updates. Style correction.
* godmode/agentes/configurar_agente.php: Variables renamed to have a
meaning.
* extensions/update_manager/main.php: Mark an string translatable.
* extensions/update_manager/lib/libupdate_manager_client.php,
godmode/alerts/configure_alert.php, include/functions.php,
godmode/agentes/module_manager.php, operation/agentes/networkmap.php,
operation/reporting/reporting_viewer.php,
godmode/agentes/manage_config.php: Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-12 15:31:01 +01:00
}
2010-08-12 13:09:45 +02:00
2019-01-30 16:18:44 +01:00
2010-08-12 13:09:45 +02:00
/**
* Convert a html color like #FF00FF into the rgb values like (255,0,255).
*
* @ param string color in format #FFFFFF, FFFFFF, #FFF or FFF
*/
2011-04-27 15:43:31 +02:00
function html_html2rgb ( $htmlcolor )
2010-08-12 13:09:45 +02:00
{
2019-01-30 16:18:44 +01:00
if ( $htmlcolor [ 0 ] == '#' ) {
$htmlcolor = substr ( $htmlcolor , 1 );
}
if ( strlen ( $htmlcolor ) == 6 ) {
$r = hexdec ( $htmlcolor [ 0 ] . $htmlcolor [ 1 ]);
$g = hexdec ( $htmlcolor [ 2 ] . $htmlcolor [ 3 ]);
$b = hexdec ( $htmlcolor [ 4 ] . $htmlcolor [ 5 ]);
return [
$r ,
$g ,
$b ,
];
} else if ( strlen ( $htmlcolor ) == 3 ) {
$r = hexdec ( $htmlcolor [ 0 ] . $htmlcolor [ 0 ]);
$g = hexdec ( $htmlcolor [ 1 ] . $htmlcolor [ 1 ]);
$b = hexdec ( $htmlcolor [ 2 ] . $htmlcolor [ 2 ]);
return [
$r ,
$g ,
$b ,
];
} else {
return false ;
}
2010-08-12 13:09:45 +02:00
}
2010-11-03 18:45:39 +01:00
2019-01-30 16:18:44 +01:00
2022-01-26 12:17:07 +01:00
/**
* Avoid autocomplete .
*
* @ return void
*/
function html_print_avoid_autocomplete ()
{
$output = '' ;
$output .= '<input type="text" style="display:none">' ;
$output .= '<input type="password" style="display:none">' ;
return $output ;
}
/**
* Input password avoid autocomplete .
*
* @ return void
*/
function html_print_input_password_avoid_autocomplete ()
{
$output = '<input type="text" style="opacity: 0;position: absolute; width: 0px;">' ;
return $output ;
}
2010-11-03 18:45:39 +01:00
/**
* Print a magic - ajax control to select the module .
2019-01-30 16:18:44 +01:00
*
2019-06-07 17:35:13 +02:00
* @ param string $name The name of ajax control , by default is " module " .
* @ param string $default The default value to show in the ajax control .
* @ param array $id_agents The array list of id agents as array ( 1 , 2 , 3 ), by default is false and the function use all agents ( if the ACL desactive ) .
* @ param boolean $ACL Filter the agents by the ACL list of user .
* @ param string $scriptResult The source code of script to call , by default is
* empty . And the example is :
* function ( e , data , formatted ) {
* ...
* }
2019-01-30 16:18:44 +01:00
*
2019-06-07 17:35:13 +02:00
* And the formatted is the select item as string .
2019-01-30 16:18:44 +01:00
*
2019-06-07 17:35:13 +02:00
* @ param array $filter Other filter of modules .
* @ param boolean $return If it is true return a string with the output instead to echo the output .
* @ param integer $id_agent_module Id agent module .
* @ param string $size Size .
2019-01-30 16:18:44 +01:00
*
2010-11-03 18:45:39 +01:00
* @ return mixed If the $return is true , return the output as string .
*/
2019-01-30 16:18:44 +01:00
function html_print_autocomplete_modules (
$name = 'module' ,
$default = '' ,
$id_agents = false ,
$ACL = true ,
$scriptResult = '' ,
$filter = [],
$return = false ,
2019-06-07 17:35:13 +02:00
$id_agent_module = 0 ,
2023-03-07 22:45:48 +01:00
$size = '30' ,
$underInputTip = false
2019-01-30 16:18:44 +01:00
) {
global $config ;
if ( $id_agents === false ) {
2019-04-09 09:51:03 +02:00
$agents = agents_get_agents ();
2019-01-30 16:18:44 +01:00
if ( $agents === false ) {
$agents = [];
}
$id_agents = [];
foreach ( $agents as $agent ) {
$id_agents [] = $agent [ 'id_agente' ];
}
} else {
if ( $ACL ) {
2019-04-09 09:51:03 +02:00
$agents = agents_get_agents ();
2019-01-30 16:18:44 +01:00
if ( $agents === false ) {
$agents = [];
}
$id_agentsACL = [];
foreach ( $agents as $agent ) {
if ( array_search ( $agent [ 'id_agente' ], $id_agents ) !== false ) {
$id_agentsACL [] = $agent [ 'id_agente' ];
}
}
$id_agents = $id_agentsACL ;
}
}
ob_start ();
2021-03-18 10:03:52 +01:00
$text_color = '' ;
2023-08-03 08:25:38 +02:00
$module_icon = is_metaconsole () === false ? 'images/search_module.png' : '../../images/search_module.png' ;
2022-10-28 15:01:00 +02:00
if ( $config [ 'style' ] === 'pandora_black' && is_metaconsole () === false ) {
2021-03-18 10:03:52 +01:00
$text_color = 'color: white' ;
2021-03-11 15:40:23 +01:00
$module_icon = 'images/brick.menu.png' ;
}
2019-01-30 16:18:44 +01:00
html_print_input_text_extended (
$name ,
$default ,
'text-' . $name ,
'' ,
2019-06-07 17:35:13 +02:00
$size ,
2019-01-30 16:18:44 +01:00
100 ,
false ,
'' ,
2023-08-03 08:25:38 +02:00
[ 'style' => 'background: url(' . $module_icon . ') no-repeat content-box; background-position: center right 5px; ' . $text_color . '' ]
2019-01-30 16:18:44 +01:00
);
html_print_input_hidden ( $name . '_hidden' , $id_agent_module );
2022-10-28 15:01:00 +02:00
if ( is_metaconsole () === false ) {
2023-03-07 22:45:48 +01:00
if ( $underInputTip === true ) {
ui_print_input_placeholder ( __ ( 'Type at least two characters to search the module.' ), false );
} else {
ui_print_help_tip ( __ ( 'Type at least two characters to search the module.' ), false );
}
2019-09-12 12:25:31 +02:00
}
$javascript_ajax_page = ui_get_full_url ( 'ajax.php' , false , false , false );
2019-01-30 16:18:44 +01:00
?>
< script type = " text/javascript " >
function escapeHTML ( str )
{
var div = document . createElement ( 'div' );
var text = document . createTextNode ( str );
div . appendChild ( text );
return div . innerHTML ;
}
$ ( document ) . ready ( function () {
$ ( " #text-<?php echo $name ; ?> " ) . autocomplete ({
minLength : 2 ,
source : function ( request , response ) {
var term = request . term ; //Word to search
data_params = {
page : " include/ajax/module " ,
q : term ,
search_modules : 1 ,
id_agents : '<?php echo json_encode($id_agents); ?>' ,
other_filter : '<?php echo json_encode($filter); ?>'
};
jQuery . ajax ({
data : data_params ,
async : false ,
type : " POST " ,
url : action = " <?php echo $javascript_ajax_page ; ?> " ,
timeout : 10000 ,
dataType : " json " ,
success : function ( data ) {
temp = [];
$ . each ( data , function ( id , module ) {
temp . push ({
'value' : id ,
'label' : module });
});
response ( temp );
}
});
},
change : function ( event , ui ) {
if ( ! ui . item )
$ ( " input[name='<?php echo $name ; ?>_hidden'] " )
. val ( 0 );
return false ;
},
select : function ( event , ui ) {
$ ( " input[name='<?php echo $name ; ?>_hidden'] " )
. val ( ui . item . value );
$ ( " #text-<?php echo $name ; ?> " ) . val ( ui . item . label );
return false ;
}
}
);
});
</ script >
< ? php
$output = ob_get_clean ();
if ( $return ) {
return $output ;
} else {
echo $output ;
}
2010-11-03 18:45:39 +01:00
}
2018-04-30 15:34:18 +02:00
2019-01-30 16:18:44 +01:00
2018-04-30 15:34:18 +02:00
/**
* @ param string Select form name
* @ param string Current selected value
*
* @ return string HTML code
*/
2022-09-30 14:12:18 +02:00
function html_print_timezone_select ( $name , $selected = '' , $nothing = '' , $nothing_value = '' )
2019-01-30 16:18:44 +01:00
{
2019-03-20 13:26:15 +01:00
$timezones = timezone_identifiers_list ();
2022-09-30 14:12:18 +02:00
$timezones = array_combine ( $timezones , $timezones );
$timezones = ([ '' => __ ( 'none' )] + $timezones );
return html_print_select ( $timezones , $name , $selected , '' , $nothing , $nothing_value , true , false , false );
2018-04-30 15:34:18 +02:00
}
2019-01-30 16:18:44 +01:00
2018-08-13 12:41:09 +02:00
/**
* Enclose a text into a result_div
*
* @ param string Text to enclose
*
* @ return string Text inside the result_div
*/
2020-07-23 17:28:44 +02:00
function html_print_result_div ( $text )
2019-01-30 16:18:44 +01:00
{
$text = preg_replace ( '/</' , '<' , $text );
$text = preg_replace ( '/>/' , '>' , $text );
$text = preg_replace ( '/\n/i' , '<br>' , $text );
$text = preg_replace ( '/\s/i' , ' ' , $text );
2021-03-11 15:40:23 +01:00
$enclose = " <div id='result_div results_class'> " ;
2019-01-30 16:18:44 +01:00
$enclose .= $text ;
$enclose .= '</div>' ;
return $enclose ;
2018-08-13 12:41:09 +02:00
}
2019-01-30 16:18:44 +01:00
2018-08-14 10:40:56 +02:00
/**
* Print order arrows links
*
* @ param array Base tags to build url
* @ param string Order key to add to URL
* @ param string Value to sort ascendent
* @ param string Value to sort descendent
*
* @ return string HTML code to display both arrows .
*/
2019-01-30 16:18:44 +01:00
function html_print_sort_arrows ( $params , $order_tag , $up = 'up' , $down = 'down' )
{
// Build the queries
$params [ $order_tag ] = $up ;
$url_up = 'index.php?' . http_build_query ( $params , '' , '&' );
$params [ $order_tag ] = $down ;
$url_down = 'index.php?' . http_build_query ( $params , '' , '&' );
// Build the links
2019-06-03 19:13:29 +02:00
$out = ' <a href="' . $url_up . '">' ;
$out .= html_print_image ( 'images/sort_up_black.png' , true );
$out .= '</a><a href="' . $url_down . '">' ;
$out .= html_print_image ( 'images/sort_down_black.png' , true ) . '</a>' ;
2018-08-14 10:40:56 +02:00
}
2018-09-13 15:19:08 +02:00
2019-01-30 16:18:44 +01:00
2018-09-13 15:19:08 +02:00
/**
* Print an input hidden with a new csrf token generated
2021-04-09 13:30:31 +02:00
*
* @ param boolean $return If it is true return a string with the output instead to echo the output .
*
* @ return void
2018-09-13 15:19:08 +02:00
*/
2021-04-09 13:30:31 +02:00
function html_print_csrf_hidden ( bool $return = false )
2019-01-30 16:18:44 +01:00
{
2021-04-09 13:30:31 +02:00
return html_print_input_hidden ( 'csrf_code' , generate_csrf_code (), $return );
2018-09-13 15:19:08 +02:00
}
2019-01-30 16:18:44 +01:00
2018-09-13 15:19:08 +02:00
/**
* Print an error if csrf is incorrect
*/
2019-01-30 16:18:44 +01:00
function html_print_csrf_error ()
{
if ( validate_csrf_code ()) {
return false ;
}
ui_print_error_message (
__ (
'%s cannot verify the origin of the request. Try again, please.' ,
get_product_name ()
)
);
return true ;
2018-09-13 15:19:08 +02:00
}
2019-02-26 12:04:18 +01:00
/**
2019-10-23 19:50:57 +02:00
* Print an swith button .
*
* @ param array $attributes Valid params .
* name : Usefull to handle in forms .
* value : If is checked or not .
* disabled : Disabled . Cannot be pressed .
* id : Optional id for the switch .
* class : Additional classes ( string ) .
2020-06-22 14:06:13 +02:00
* value : Check or not ( boolean ) .
* disabled : Enabled or disabled ( boolean ) .
2019-10-23 19:50:57 +02:00
*
* @ return string with HTML of button .
2019-02-26 12:04:18 +01:00
*/
function html_print_switch ( $attributes = [])
{
$html_expand = '' ;
// Check the load values on status.
2022-01-11 12:08:41 +01:00
$html_expand .= ( bool ) ( $attributes [ 'value' ] ? ? false ) ? ' checked' : '' ;
$html_expand .= ( bool ) ( $attributes [ 'disabled' ] ? ? false ) ? ' disabled' : '' ;
2019-02-26 12:04:18 +01:00
// Only load the valid attributes.
$valid_attrs = [
'id' ,
'class' ,
'name' ,
'onclick' ,
2019-05-27 22:36:55 +02:00
'onchange' ,
2019-02-26 12:04:18 +01:00
];
foreach ( $valid_attrs as $va ) {
if ( ! isset ( $attributes [ $va ])) {
continue ;
}
$html_expand .= ' ' . $va . '="' . $attributes [ $va ] . '"' ;
}
2019-05-27 22:36:55 +02:00
if ( ! isset ( $attributes [ 'style' ])) {
$attributes [ 'style' ] = '' ;
}
2022-01-11 12:08:41 +01:00
$disabled_class = ( bool ) ( $attributes [ 'disabled' ] ? ? false ) ? ' p-slider-disabled' : '' ;
2020-04-02 10:37:59 +02:00
2022-01-11 12:08:41 +01:00
return " <label class='p-switch " . ( $attributes [ 'container-class' ] ? ? '' ) . " ' style=' " . ( $attributes [ 'style' ] ? ? '' ) . " '>
2019-10-23 19:50:57 +02:00
< input type = 'checkbox' " . $html_expand . " >
2020-04-02 10:37:59 +02:00
< span class = 'p-slider".$disabled_class."' ></ span >
2019-02-26 12:04:18 +01:00
</ label > " ;
}
2019-03-05 10:08:07 +01:00
/**
* Print a link with post params . The component is really a form with a button
* with some inputs hidden .
*
* @ param string $text Text to show .
* @ param array $params Params to be written like inputs hidden .
2019-03-07 15:10:38 +01:00
* @ param string $text Text of image .
2019-03-08 11:46:47 +01:00
* @ param string $style Additional style for the element .
2019-03-05 10:08:07 +01:00
*
* @ return string With HTML code .
*/
2023-03-09 00:45:41 +01:00
function html_print_link_with_params ( $text , $params = [], $type = 'text' , $style = '' , $formStyle = '' )
2019-03-05 10:08:07 +01:00
{
2023-03-09 00:45:41 +01:00
if ( empty ( $formStyle ) === false ) {
$formStyle = ' style="' . $formStyle . '"' ;
}
$html = '<form method="POST"' . $formStyle . '>' ;
2019-03-07 15:10:38 +01:00
switch ( $type ) {
case 'image' :
2019-03-08 11:46:47 +01:00
$html .= html_print_input_image ( $text , $text , $text , $style , true );
2019-03-07 15:10:38 +01:00
break ;
case 'text' :
default :
2023-03-09 00:45:41 +01:00
if ( empty ( $style ) === false ) {
2019-03-08 11:46:47 +01:00
$style = ' style="' . $style . '"' ;
}
$html .= html_print_submit_button (
$text ,
$text ,
false ,
2023-03-09 00:45:41 +01:00
[
'mode' => 'link' ,
'style' => $style ,
],
2019-03-08 11:46:47 +01:00
true
);
2019-03-07 15:10:38 +01:00
break ;
}
2019-03-05 10:08:07 +01:00
foreach ( $params as $param => $value ) {
$html .= html_print_input_hidden ( $param , $value , true );
}
$html .= '</form>' ;
return $html ;
2019-06-07 17:35:13 +02:00
}
2019-06-21 19:34:47 +02:00
/**
* Print input using functions html lib .
*
2019-07-10 23:59:09 +02:00
* @ param array $data Input definition .
* @ param string $wrapper Wrapper 'div' or 'li' .
* @ param boolean $input_only Return or print only input or also label .
2019-06-21 19:34:47 +02:00
*
* @ return string HTML code for desired input .
*/
2019-07-10 23:59:09 +02:00
function html_print_input ( $data , $wrapper = 'div' , $input_only = false )
2019-06-21 19:34:47 +02:00
{
2021-03-18 09:53:39 +01:00
global $config ;
2019-06-21 19:34:47 +02:00
if ( is_array ( $data ) === false ) {
return '' ;
}
2021-02-18 12:47:42 +01:00
enterprise_include_once ( 'include/functions_metaconsole.php' );
2021-03-31 12:12:36 +02:00
2022-03-30 14:41:47 +02:00
$style = '' ;
2022-01-17 10:22:30 +01:00
if ( $config [ 'style' ] === 'pandora_black' && ! is_metaconsole ()) {
2021-03-31 12:12:36 +02:00
$style = 'style="color: white"' ;
2021-03-18 09:53:39 +01:00
}
2022-03-31 20:11:52 +02:00
if ( isset ( $data [ 'label_class' ]) === false ) {
$data [ 'label_class' ] = '' ;
}
2019-06-21 19:34:47 +02:00
$output = '' ;
2022-01-11 12:08:41 +01:00
if (( $data [ 'label' ] ? ? false ) && $input_only === false ) {
2022-09-19 14:40:31 +02:00
$output = '<' . $wrapper . ' id="' . $wrapper . '-' . ( $data [ 'name' ] ? ? '' ) . '" ' ;
2022-03-30 14:41:47 +02:00
$output .= ' class="' . ( $data [ 'input_class' ] ? ? '' ) . '">' ;
$output .= '<label ' . $style . ' class="' . ( $data [ 'label_class' ] ? ? '' ) . '">' ;
$output .= ( $data [ 'label' ] ? ? '' );
2019-06-21 19:34:47 +02:00
$output .= '</label>' ;
if ( ! $data [ 'return' ]) {
echo $output ;
}
}
2020-11-03 17:15:01 +01:00
// If wrapper has attributes.
// TODO. There is possible improve this handle of attributes.
if ( isset ( $data [ 'wrapper_attributes' ])) {
$wrapper_attributes = $data [ 'wrapper_attributes' ];
} else {
$wrapper_attributes = '' ;
}
2020-01-09 12:07:19 +01:00
if ( isset ( $data [ 'wrapper' ]) === true ) {
2020-11-03 17:15:01 +01:00
$output = '<' . $data [ 'wrapper' ] . ' ' . $wrapper_attributes . ' id="wr_' . $data [ 'name' ] . '" ' ;
2022-09-19 14:40:31 +02:00
$output .= ' class="' . ( $data [ 'input_class' ] ? ? '' ) . '">' ;
2020-01-09 12:07:19 +01:00
}
2022-01-11 14:30:59 +01:00
switch (( $data [ 'type' ] ? ? null )) {
2019-06-21 19:34:47 +02:00
case 'text' :
$output .= html_print_input_text (
$data [ 'name' ],
2022-03-30 14:41:47 +02:00
( $data [ 'value' ] ? ? '' ),
2019-06-21 19:34:47 +02:00
(( isset ( $data [ 'alt' ]) === true ) ? $data [ 'alt' ] : '' ),
(( isset ( $data [ 'size' ]) === true ) ? $data [ 'size' ] : 50 ),
(( isset ( $data [ 'maxlength' ]) === true ) ? $data [ 'maxlength' ] : 255 ),
(( isset ( $data [ 'return' ]) === true ) ? $data [ 'return' ] : true ),
(( isset ( $data [ 'disabled' ]) === true ) ? $data [ 'disabled' ] : false ),
(( isset ( $data [ 'required' ]) === true ) ? $data [ 'required' ] : false ),
(( isset ( $data [ 'function' ]) === true ) ? $data [ 'function' ] : '' ),
(( isset ( $data [ 'class' ]) === true ) ? $data [ 'class' ] : '' ),
(( isset ( $data [ 'onChange' ]) === true ) ? $data [ 'onChange' ] : '' ),
2021-02-01 13:54:57 +01:00
(( isset ( $data [ 'autocomplete' ]) === true ) ? $data [ 'autocomplete' ] : 'off' ),
2020-05-14 17:42:58 +02:00
(( isset ( $data [ 'autofocus' ]) === true ) ? $data [ 'autofocus' ] : false ),
2020-04-13 15:41:00 +02:00
(( isset ( $data [ 'onKeyDown' ]) === true ) ? $data [ 'onKeyDown' ] : '' ),
2020-05-14 17:42:58 +02:00
(( isset ( $data [ 'form' ]) === true ) ? $data [ 'form' ] : '' ),
2020-10-30 13:25:33 +01:00
(( isset ( $data [ 'onKeyUp' ]) === true ) ? $data [ 'onKeyUp' ] : '' ),
(( isset ( $data [ 'disabled' ]) === true ) ? $data [ 'disabled' ] : false ),
2021-09-29 20:56:39 +02:00
(( isset ( $data [ 'list' ]) === true ) ? $data [ 'list' ] : '' ),
2022-01-26 12:52:36 +01:00
(( isset ( $data [ 'placeholder' ]) === true ) ? $data [ 'placeholder' ] : '' ),
(( isset ( $data [ 'pattern' ]) === true ) ? $data [ 'pattern' ] : null )
2019-06-21 19:34:47 +02:00
);
break ;
2020-06-22 14:06:13 +02:00
case 'range' :
$output .= html_print_input_range (
$data [ 'name' ],
$data [ 'value' ],
( isset ( $data [ 'id' ]) ? $data [ 'id' ] : '' ),
( isset ( $data [ 'return' ]) ? $data [ 'return' ] : true ),
( isset ( $data [ 'min' ]) ? $data [ 'min' ] : 0 ),
( isset ( $data [ 'max' ]) ? $data [ 'max' ] : 100 ),
( isset ( $data [ 'step' ]) ? $data [ 'step' ] : 1 ),
( isset ( $data [ 'class' ]) ? $data [ 'class' ] : '' ),
( isset ( $data [ 'oninput' ]) ? $data [ 'oninput' ] : '' )
);
break ;
2019-06-21 19:34:47 +02:00
case 'image' :
$output .= html_print_input_image (
2022-05-13 12:54:58 +02:00
(( isset ( $data [ 'name' ]) === true ) ? $data [ 'name' ] : '' ),
2019-06-21 19:34:47 +02:00
$data [ 'src' ],
$data [ 'value' ],
(( isset ( $data [ 'style' ]) === true ) ? $data [ 'style' ] : '' ),
(( isset ( $data [ 'return' ]) === true ) ? $data [ 'return' ] : false ),
(( isset ( $data [ 'options' ]) === true ) ? $data [ 'options' ] : false )
);
break ;
case 'text_extended' :
$output .= html_print_input_text_extended (
2022-01-11 14:30:59 +01:00
( $data [ 'name' ] ? ? null ),
( $data [ 'value' ] ? ? null ),
( $data [ 'id' ] ? ? null ),
( $data [ 'alt' ] ? ? null ),
( $data [ 'size' ] ? ? null ),
( $data [ 'maxlength' ] ? ? null ),
( $data [ 'disabled' ] ? ? null ),
( $data [ 'script' ] ? ? null ),
( $data [ 'attributes' ] ? ? null ),
2019-06-21 19:34:47 +02:00
(( isset ( $data [ 'return' ]) === true ) ? $data [ 'return' ] : false ),
(( isset ( $data [ 'password' ]) === true ) ? $data [ 'password' ] : false ),
2023-07-12 13:15:46 +02:00
(( isset ( $data [ 'function' ]) === true ) ? $data [ 'function' ] : '' ),
(( isset ( $data [ 'autocomplete' ]) === true ) ? $data [ 'autocomplete' ] : 'off' ),
(( isset ( $data [ 'disabled' ]) === true ) ? $data [ 'disabled' ] : false ),
(( isset ( $data [ 'hide_div_eye' ]) === true ) ? $data [ 'hide_div_eye' ] : false ),
2019-06-21 19:34:47 +02:00
);
break ;
case 'password' :
$output .= html_print_input_password (
$data [ 'name' ],
$data [ 'value' ],
(( isset ( $data [ 'alt' ]) === true ) ? $data [ 'alt' ] : '' ),
(( isset ( $data [ 'size' ]) === true ) ? $data [ 'size' ] : 50 ),
(( isset ( $data [ 'maxlength' ]) === true ) ? $data [ 'maxlength' ] : 255 ),
(( isset ( $data [ 'return' ]) === true ) ? $data [ 'return' ] : false ),
(( isset ( $data [ 'disabled' ]) === true ) ? $data [ 'disabled' ] : false ),
(( isset ( $data [ 'required' ]) === true ) ? $data [ 'required' ] : false ),
2019-08-10 02:13:01 +02:00
(( isset ( $data [ 'class' ]) === true ) ? $data [ 'class' ] : '' ),
(( isset ( $data [ 'autocomplete' ]) === true ) ? $data [ 'autocomplete' ] : 'off' )
2019-06-21 19:34:47 +02:00
);
break ;
2019-10-24 17:42:37 +02:00
case 'email' :
$output .= html_print_input_email ( $data );
break ;
2019-11-12 13:16:25 +01:00
case 'number' :
$output .= html_print_input_number ( $data );
break ;
2019-06-21 19:34:47 +02:00
case 'hidden' :
$output .= html_print_input_hidden (
$data [ 'name' ],
$data [ 'value' ],
(( isset ( $data [ 'return' ]) === true ) ? $data [ 'return' ] : false ),
2020-06-30 12:16:51 +02:00
(( isset ( $data [ 'class' ]) === true ) ? $data [ 'class' ] : false ),
false ,
(( isset ( $data [ 'id' ]) === true ) ? $data [ 'id' ] : '' )
2019-06-21 19:34:47 +02:00
);
break ;
case 'hidden_extended' :
$output .= html_print_input_hidden_extended (
$data [ 'name' ],
$data [ 'value' ],
$data [ 'id' ],
(( isset ( $data [ 'return' ]) === true ) ? $data [ 'return' ] : false ),
2019-11-21 12:42:06 +01:00
(( isset ( $data [ 'class' ]) === true ) ? $data [ 'class' ] : false ),
(( isset ( $data [ 'quotes' ]) === true ) ? $data [ 'quotes' ] : false )
2019-06-21 19:34:47 +02:00
);
break ;
case 'color' :
$output .= html_print_input_color (
$data [ 'name' ],
$data [ 'value' ],
2022-09-19 14:40:31 +02:00
( $data [ 'id' ] ? ? '' ),
2019-06-21 19:34:47 +02:00
(( isset ( $data [ 'class' ]) === true ) ? $data [ 'class' ] : false ),
(( isset ( $data [ 'return' ]) === true ) ? $data [ 'return' ] : false )
);
break ;
case 'file' :
$output .= html_print_input_file (
$data [ 'name' ],
(( isset ( $data [ 'return' ]) === true ) ? $data [ 'return' ] : false ),
(( isset ( $data [ 'options' ]) === true ) ? $data [ 'options' ] : false )
);
break ;
case 'select' :
$output .= html_print_select (
$data [ 'fields' ],
$data [ 'name' ],
(( isset ( $data [ 'selected' ]) === true ) ? $data [ 'selected' ] : '' ),
(( isset ( $data [ 'script' ]) === true ) ? $data [ 'script' ] : '' ),
(( isset ( $data [ 'nothing' ]) === true ) ? $data [ 'nothing' ] : '' ),
(( isset ( $data [ 'nothing_value' ]) === true ) ? $data [ 'nothing_value' ] : 0 ),
(( isset ( $data [ 'return' ]) === true ) ? $data [ 'return' ] : false ),
(( isset ( $data [ 'multiple' ]) === true ) ? $data [ 'multiple' ] : false ),
(( isset ( $data [ 'sort' ]) === true ) ? $data [ 'sort' ] : true ),
(( isset ( $data [ 'class' ]) === true ) ? $data [ 'class' ] : '' ),
(( isset ( $data [ 'disabled' ]) === true ) ? $data [ 'disabled' ] : false ),
(( isset ( $data [ 'style' ]) === true ) ? $data [ 'style' ] : false ),
(( isset ( $data [ 'option_style' ]) === true ) ? $data [ 'option_style' ] : false ),
(( isset ( $data [ 'size' ]) === true ) ? $data [ 'size' ] : false ),
(( isset ( $data [ 'modal' ]) === true ) ? $data [ 'modal' ] : false ),
(( isset ( $data [ 'message' ]) === true ) ? $data [ 'message' ] : '' ),
2022-02-08 13:56:19 +01:00
(( isset ( $data [ 'select_all' ]) === true ) ? $data [ 'select_all' ] : false ),
(( isset ( $data [ 'simple_multiple_options' ]) === true ) ? $data [ 'simple_multiple_options' ] : false ),
(( isset ( $data [ 'required' ]) === true ) ? $data [ 'required' ] : false ),
(( isset ( $data [ 'truncate_size' ]) === true ) ? $data [ 'truncate_size' ] : false ),
(( isset ( $data [ 'select2_enable' ]) === true ) ? $data [ 'select2_enable' ] : true ),
(( isset ( $data [ 'select2_multiple_enable' ]) === true ) ? $data [ 'select2_multiple_enable' ] : false ),
2023-05-08 10:35:59 +02:00
(( isset ( $data [ 'select2_multiple_enable_all' ]) === true ) ? $data [ 'select2_multiple_enable_all' ] : false ),
(( isset ( $data [ 'form' ]) === true ) ? $data [ 'form' ] : '' ),
(( isset ( $data [ 'order' ]) === true ) ? $data [ 'order' ] : false )
2019-06-21 19:34:47 +02:00
);
break ;
case 'select_from_sql' :
$output .= html_print_select_from_sql (
$data [ 'sql' ],
$data [ 'name' ],
(( isset ( $data [ 'selected' ]) === true ) ? $data [ 'selected' ] : '' ),
(( isset ( $data [ 'script' ]) === true ) ? $data [ 'script' ] : '' ),
(( isset ( $data [ 'nothing' ]) === true ) ? $data [ 'nothing' ] : '' ),
(( isset ( $data [ 'nothing_value' ]) === true ) ? $data [ 'nothing_value' ] : '0' ),
(( isset ( $data [ 'return' ]) === true ) ? $data [ 'return' ] : false ),
(( isset ( $data [ 'multiple' ]) === true ) ? $data [ 'multiple' ] : false ),
(( isset ( $data [ 'sort' ]) === true ) ? $data [ 'sort' ] : true ),
(( isset ( $data [ 'disabled' ]) === true ) ? $data [ 'disabled' ] : false ),
(( isset ( $data [ 'style' ]) === true ) ? $data [ 'style' ] : false ),
(( isset ( $data [ 'size' ]) === true ) ? $data [ 'size' ] : false ),
2020-04-07 18:50:56 +02:00
(( isset ( $data [ 'trucate_size' ]) === true ) ? $data [ 'trucate_size' ] : GENERIC_SIZE_TEXT ),
2020-10-26 13:37:05 +01:00
(( isset ( $data [ 'class' ]) === true ) ? $data [ 'class' ] : '' ),
(( isset ( $data [ 'required' ]) === true ) ? $data [ 'required' ] : false )
2019-06-21 19:34:47 +02:00
);
break ;
case 'select_groups' :
$output .= html_print_select_groups (
(( isset ( $data [ 'id_user' ]) === true ) ? $data [ 'id_user' ] : false ),
(( isset ( $data [ 'privilege' ]) === true ) ? $data [ 'privilege' ] : 'AR' ),
(( isset ( $data [ 'returnAllGroup' ]) === true ) ? $data [ 'returnAllGroup' ] : true ),
$data [ 'name' ],
(( isset ( $data [ 'selected' ]) === true ) ? $data [ 'selected' ] : '' ),
(( isset ( $data [ 'script' ]) === true ) ? $data [ 'script' ] : '' ),
(( isset ( $data [ 'nothing' ]) === true ) ? $data [ 'nothing' ] : '' ),
(( isset ( $data [ 'nothing_value' ]) === true ) ? $data [ 'nothing_value' ] : 0 ),
(( isset ( $data [ 'return' ]) === true ) ? $data [ 'return' ] : false ),
(( isset ( $data [ 'multiple' ]) === true ) ? $data [ 'multiple' ] : false ),
(( isset ( $data [ 'sort' ]) === true ) ? $data [ 'sort' ] : true ),
(( isset ( $data [ 'class' ]) === true ) ? $data [ 'class' ] : '' ),
(( isset ( $data [ 'disabled' ]) === true ) ? $data [ 'disabled' ] : false ),
(( isset ( $data [ 'style' ]) === true ) ? $data [ 'style' ] : false ),
(( isset ( $data [ 'option_style' ]) === true ) ? $data [ 'option_style' ] : false ),
(( isset ( $data [ 'id_group' ]) === true ) ? $data [ 'id_group' ] : false ),
(( isset ( $data [ 'keys_field' ]) === true ) ? $data [ 'keys_field' ] : 'id_grupo' ),
(( isset ( $data [ 'strict_user' ]) === true ) ? $data [ 'strict_user' ] : false ),
(( isset ( $data [ 'delete_groups' ]) === true ) ? $data [ 'delete_groups' ] : false ),
(( isset ( $data [ 'include_groups' ]) === true ) ? $data [ 'include_groups' ] : false ),
(( isset ( $data [ 'size' ]) === true ) ? $data [ 'size' ] : false ),
2020-09-29 15:48:20 +02:00
(( isset ( $data [ 'simple_multiple_options' ]) === true ) ? $data [ 'simple_multiple_options' ] : false ),
(( isset ( $data [ 'required' ]) === true ) ? $data [ 'required' ] : false )
2019-06-21 19:34:47 +02:00
);
break ;
2021-04-06 18:51:14 +02:00
case 'select_search' :
$output .= html_print_select_search (
$data [ 'fields' ],
$data [ 'name' ],
(( isset ( $data [ 'selected' ]) === true ) ? $data [ 'selected' ] : '' ),
(( isset ( $data [ 'script' ]) === true ) ? $data [ 'script' ] : '' ),
(( isset ( $data [ 'nothing' ]) === true ) ? $data [ 'nothing' ] : '' ),
(( isset ( $data [ 'nothing_value' ]) === true ) ? $data [ 'nothing_value' ] : 0 ),
(( isset ( $data [ 'return' ]) === true ) ? $data [ 'return' ] : false ),
(( isset ( $data [ 'multiple' ]) === true ) ? $data [ 'multiple' ] : false ),
(( isset ( $data [ 'sort' ]) === true ) ? $data [ 'sort' ] : true ),
(( isset ( $data [ 'class' ]) === true ) ? $data [ 'class' ] : '' ),
(( isset ( $data [ 'disabled' ]) === true ) ? $data [ 'disabled' ] : false ),
(( isset ( $data [ 'style' ]) === true ) ? $data [ 'style' ] : false ),
(( isset ( $data [ 'option_style' ]) === true ) ? $data [ 'option_style' ] : false ),
(( isset ( $data [ 'size' ]) === true ) ? $data [ 'size' ] : false ),
(( isset ( $data [ 'modal' ]) === true ) ? $data [ 'modal' ] : false ),
(( isset ( $data [ 'message' ]) === true ) ? $data [ 'message' ] : '' ),
(( isset ( $data [ 'dropdownAutoWidth' ]) === true ) ? $data [ 'dropdownAutoWidth' ] : false )
);
break ;
2020-07-03 17:52:44 +02:00
case 'select_metaconsole_nodes' :
$output .= html_print_select_from_sql (
'SELECT `id`, `server_name` FROM `tmetaconsole_setup`' ,
$data [ 'name' ],
(( isset ( $data [ 'selected' ]) === true ) ? $data [ 'selected' ] : '' ),
(( isset ( $data [ 'script' ]) === true ) ? $data [ 'script' ] : '' ),
(( isset ( $data [ 'nothing' ]) === true ) ? $data [ 'nothing' ] : '' ),
(( isset ( $data [ 'nothing_value' ]) === true ) ? $data [ 'nothing_value' ] : '0' ),
(( isset ( $data [ 'return' ]) === true ) ? $data [ 'return' ] : false ),
(( isset ( $data [ 'multiple' ]) === true ) ? $data [ 'multiple' ] : false ),
(( isset ( $data [ 'sort' ]) === true ) ? $data [ 'sort' ] : true ),
(( isset ( $data [ 'disabled' ]) === true ) ? $data [ 'disabled' ] : false ),
(( isset ( $data [ 'style' ]) === true ) ? $data [ 'style' ] : false ),
(( isset ( $data [ 'size' ]) === true ) ? $data [ 'size' ] : false ),
(( isset ( $data [ 'trucate_size' ]) === true ) ? $data [ 'trucate_size' ] : GENERIC_SIZE_TEXT ),
(( isset ( $data [ 'class' ]) === true ) ? $data [ 'class' ] : '' )
);
break ;
2020-06-30 12:16:51 +02:00
case 'select_for_unit' :
$output .= html_print_extended_select_for_unit (
$data [ 'name' ],
(( isset ( $data [ 'selected' ]) === true ) ? $data [ 'selected' ] : '' ),
(( isset ( $data [ 'script' ]) === true ) ? $data [ 'script' ] : '' ),
(( isset ( $data [ 'nothing' ]) === true ) ? $data [ 'nothing' ] : '' ),
(( isset ( $data [ 'nothing_value' ]) === true ) ? $data [ 'nothing_value' ] : '0' ),
(( isset ( $data [ 'size' ]) === true ) ? $data [ 'size' ] : false ),
(( isset ( $data [ 'return' ]) === true ) ? $data [ 'return' ] : false ),
(( isset ( $data [ 'select_style' ]) === true ) ? $data [ 'select_style' ] : false ),
(( isset ( $data [ 'unique_name' ]) === true ) ? $data [ 'unique_name' ] : true ),
(( isset ( $data [ 'disabled' ]) === true ) ? $data [ 'disabled' ] : false ),
2020-07-03 17:52:44 +02:00
(( isset ( $data [ 'no_change' ]) === true ) ? $data [ 'no_change' ] : 0 )
2020-06-30 12:16:51 +02:00
);
2019-06-21 19:34:47 +02:00
case 'submit' :
2023-03-09 11:25:43 +01:00
$width = ( isset ( $data [ 'width' ]) === true ) ? 'width: ' . $data [ 'width' ] : '' ;
2019-11-12 13:16:25 +01:00
$output .= '<' . $wrapper . ' class="action-buttons" style="' . $width . '">' . html_print_submit_button (
2019-06-21 19:34:47 +02:00
(( isset ( $data [ 'label' ]) === true ) ? $data [ 'label' ] : 'OK' ),
(( isset ( $data [ 'name' ]) === true ) ? $data [ 'name' ] : '' ),
(( isset ( $data [ 'disabled' ]) === true ) ? $data [ 'disabled' ] : false ),
(( isset ( $data [ 'attributes' ]) === true ) ? $data [ 'attributes' ] : '' ),
(( isset ( $data [ 'return' ]) === true ) ? $data [ 'return' ] : false )
2019-07-10 23:59:09 +02:00
) . '</' . $wrapper . '>' ;
2019-06-21 19:34:47 +02:00
break ;
case 'checkbox' :
$output .= html_print_checkbox (
$data [ 'name' ],
2022-01-11 14:30:59 +01:00
( $data [ 'value' ] ? ? null ),
2019-06-21 19:34:47 +02:00
(( isset ( $data [ 'checked' ]) === true ) ? $data [ 'checked' ] : false ),
(( isset ( $data [ 'return' ]) === true ) ? $data [ 'return' ] : false ),
(( isset ( $data [ 'disabled' ]) === true ) ? $data [ 'disabled' ] : false ),
(( isset ( $data [ 'script' ]) === true ) ? $data [ 'script' ] : '' ),
2019-11-22 20:49:46 +01:00
(( isset ( $data [ 'disabled_hidden' ]) === true ) ? $data [ 'disabled_hidden' ] : false ),
(( isset ( $data [ 'attributes' ]) === true ) ? $data [ 'attributes' ] : '' ),
(( isset ( $data [ 'id' ]) === true ) ? $data [ 'id' ] : '' )
2019-06-21 19:34:47 +02:00
);
break ;
case 'switch' :
$output .= html_print_switch ( $data );
break ;
case 'interval' :
$output .= html_print_extended_select_for_time (
$data [ 'name' ],
2020-06-24 18:01:34 +02:00
(( isset ( $data [ 'value' ]) === true ) ? $data [ 'value' ] : $data [ 'selected' ]),
2019-06-21 19:34:47 +02:00
(( isset ( $data [ 'script' ]) === true ) ? $data [ 'script' ] : '' ),
(( isset ( $data [ 'nothing' ]) === true ) ? $data [ 'nothing' ] : '' ),
(( isset ( $data [ 'nothing_value' ]) === true ) ? $data [ 'nothing_value' ] : 0 ),
(( isset ( $data [ 'size' ]) === true ) ? $data [ 'size' ] : false ),
(( isset ( $data [ 'return' ]) === true ) ? $data [ 'return' ] : false ),
(( isset ( $data [ 'style' ]) === true ) ? $data [ 'selected' ] : false ),
2021-07-07 12:09:47 +02:00
(( isset ( $data [ 'unique' ]) === true ) ? $data [ 'unique' ] : false ),
(( isset ( $data [ 'class' ]) === true ) ? $data [ 'class' ] : '' ),
(( isset ( $data [ 'readonly' ]) === true ) ? $data [ 'readonly' ] : false ),
(( isset ( $data [ 'custom_fields' ]) === true ) ? $data [ 'custom_fields' ] : false ),
(( isset ( $data [ 'style_icon' ]) === true ) ? $data [ 'style_icon' ] : '' )
2019-06-21 19:34:47 +02:00
);
break ;
case 'textarea' :
$output .= html_print_textarea (
$data [ 'name' ],
$data [ 'rows' ],
$data [ 'columns' ],
(( isset ( $data [ 'value' ]) === true ) ? $data [ 'value' ] : '' ),
(( isset ( $data [ 'attributes' ]) === true ) ? $data [ 'attributes' ] : '' ),
(( isset ( $data [ 'return' ]) === true ) ? $data [ 'return' ] : false ),
2020-07-13 14:06:52 +02:00
(( isset ( $data [ 'class' ]) === true ) ? $data [ 'class' ] : '' ),
2020-09-23 14:07:23 +02:00
(( isset ( $data [ 'disabled' ]) === true ) ? $data [ 'disabled' ] : false ),
(( isset ( $data [ 'id' ]) === true ) ? $data [ 'id' ] : false )
2019-06-21 19:34:47 +02:00
);
2019-07-10 23:59:09 +02:00
break ;
case 'button' :
$output .= html_print_button (
(( isset ( $data [ 'label' ]) === true ) ? $data [ 'label' ] : 'OK' ),
(( isset ( $data [ 'name' ]) === true ) ? $data [ 'name' ] : '' ),
(( isset ( $data [ 'disabled' ]) === true ) ? $data [ 'disabled' ] : false ),
(( isset ( $data [ 'script' ]) === true ) ? $data [ 'script' ] : '' ),
(( isset ( $data [ 'attributes' ]) === true ) ? $data [ 'attributes' ] : '' ),
(( isset ( $data [ 'return' ]) === true ) ? $data [ 'return' ] : false ),
(( isset ( $data [ 'imageButton' ]) === true ) ? $data [ 'imageButton' ] : false ),
(( isset ( $data [ 'modal' ]) === true ) ? $data [ 'modal' ] : false ),
(( isset ( $data [ 'message' ]) === true ) ? $data [ 'message' ] : '' )
);
break ;
2019-06-21 19:34:47 +02:00
2019-11-07 17:26:32 +01:00
case 'radio_button' :
$output .= html_print_radio_button_extended (
$data [ 'name' ],
$data [ 'value' ],
$data [ 'label' ],
(( isset ( $data [ 'checkedvalue' ]) === true ) ? $data [ 'checkedvalue' ] : 1 ),
(( isset ( $data [ 'disabled' ]) === true ) ? $data [ 'disabled' ] : '' ),
(( isset ( $data [ 'script' ]) === true ) ? $data [ 'script' ] : '' ),
(( isset ( $data [ 'attributes' ]) === true ) ? $data [ 'attributes' ] : true ),
(( isset ( $data [ 'return' ]) === true ) ? $data [ 'return' ] : false ),
(( isset ( $data [ 'modal' ]) === true ) ? $data [ 'modal' ] : false ),
(( isset ( $data [ 'message' ]) === true ) ? $data [ 'message' ] : 'visualmodal' ),
(( isset ( $data [ 'id' ]) === true ) ? $data [ 'id' ] : null )
);
2019-11-07 19:39:50 +01:00
break ;
case 'email' :
$output .= html_print_input_email ( $data );
break ;
2019-11-07 17:26:32 +01:00
2019-11-12 13:16:25 +01:00
case 'multicheck' :
$output .= html_print_input_multicheck ( $data );
break ;
2020-06-22 14:06:13 +02:00
case 'agent_autocomplete' :
// Direct assignment of parameters.
$output .= ui_print_agent_autocomplete_input ( $data );
break ;
2019-12-18 17:36:01 +01:00
case 'autocomplete_agent' :
2019-12-19 20:42:29 +01:00
$agent_name = '' ;
if ( isset ( $data [ 'id_agent_hidden' ]) === true
&& empty ( $data [ 'id_agent_hidden' ]) === false
) {
2019-12-18 17:36:01 +01:00
if ( is_metaconsole () === true ) {
2019-12-19 20:42:29 +01:00
$connection = metaconsole_get_connection_by_id (
$data [ 'server_id_hidden' ]
2019-12-18 17:36:01 +01:00
);
2019-12-19 20:42:29 +01:00
$agent_name = '' ;
if ( metaconsole_load_external_db ( $connection ) == NOERR ) {
$agent_name = db_get_value_filter (
'alias' ,
'tagente' ,
[ 'id_agente' => $data [ 'id_agent_hidden' ]]
);
}
2019-12-18 17:36:01 +01:00
2019-12-19 20:42:29 +01:00
// Append server name.
if ( ! empty ( $agent_name )) {
$agent_name .= ' (' . $connection [ 'server_name' ] . ')' ;
}
2019-12-18 17:36:01 +01:00
2019-12-19 20:42:29 +01:00
// Restore db connection.
metaconsole_restore_db ();
2019-12-18 17:36:01 +01:00
} else {
2019-12-19 20:42:29 +01:00
$agent_name = agents_get_alias ( $data [ 'id_agent_hidden' ]);
2019-12-18 17:36:01 +01:00
}
}
$params = [];
2020-07-01 20:50:07 +02:00
$params [ 'disabled' ] = $data [ 'disabled' ];
2019-12-18 17:36:01 +01:00
$params [ 'return' ] = $data [ 'return' ];
$params [ 'show_helptip' ] = false ;
$params [ 'input_name' ] = $data [ 'name' ];
$params [ 'value' ] = $agent_name ;
$params [ 'javascript_is_function_select' ] = true ;
2019-12-19 20:42:29 +01:00
2020-02-13 09:55:49 +01:00
if ( isset ( $data [ 'get_only_string_modules' ]) === true
&& $data [ 'get_only_string_modules' ] === true
) {
$params [ 'get_only_string_modules' ] = $data [ 'get_only_string_modules' ];
}
2019-12-19 20:42:29 +01:00
if ( isset ( $data [ 'module_input' ]) === true
&& $data [ 'module_input' ] === true
) {
$params [ 'selectbox_id' ] = $data [ 'module_name' ];
$params [ 'add_none_module' ] = $data [ 'module_none' ];
}
2020-03-26 12:29:38 +01:00
if ( isset ( $data [ 'size' ]) === true ) {
$params [ 'size' ] = $data [ 'size' ];
}
if ( isset ( $data [ 'from_wux' ]) === true
&& $data [ 'from_wux' ] === true
) {
$params [ 'from_wux' ] = 1 ;
}
2019-12-18 17:36:01 +01:00
$params [ 'use_hidden_input_idagent' ] = true ;
$params [ 'hidden_input_idagent_id' ] = 'hidden-' . $data [ 'name_agent_hidden' ];
2019-12-19 20:42:29 +01:00
if ( is_metaconsole ()) {
2019-12-18 17:36:01 +01:00
$params [ 'use_input_id_server' ] = true ;
2019-12-19 20:42:29 +01:00
$params [ 'input_id_server_id' ] = 'hidden-' . $data [ 'name_server_hidden' ];
2019-12-18 17:36:01 +01:00
$params [ 'metaconsole_enabled' ] = true ;
2019-12-19 20:42:29 +01:00
}
2019-12-18 17:36:01 +01:00
$output .= html_print_input_hidden (
$data [ 'name_agent_hidden' ],
$data [ 'id_agent_hidden' ],
$data [ 'return' ]
);
2019-12-19 20:42:29 +01:00
2019-12-18 17:36:01 +01:00
$output .= html_print_input_hidden (
$data [ 'name_server_hidden' ],
$data [ 'server_id_hidden' ],
$data [ 'return' ]
);
2019-12-19 20:42:29 +01:00
2019-12-18 17:36:01 +01:00
$output .= ui_print_agent_autocomplete_input ( $params );
break ;
2019-12-19 20:42:29 +01:00
case 'autocomplete_module' :
// Module.
2020-01-23 17:52:59 +01:00
if (( $data [ 'agent_id' ] === false
|| empty ( $data [ 'agent_id' ]) === true )
&& ( isset ( $data [ 'selected' ]) === false
|| $data [ 'selected' ] === 0 )
) {
2019-12-19 20:42:29 +01:00
$fields = [
0 => __ ( 'Select an Agent first' ),
];
} else {
2020-07-07 19:10:24 +02:00
$string_filter = '' ;
2020-02-13 09:55:49 +01:00
if ( $data [ 'get_only_string_modules' ] === true ) {
$string_filter = 'AND id_tipo_modulo IN (17,23,3,10,33,36)' ;
}
2020-03-26 12:29:38 +01:00
if ( $data [ 'from_wux' ] === true ) {
2021-01-21 14:42:43 +01:00
$string_filter = ' AND id_tipo_modulo = 25' ;
}
if ( isset ( $data [ 'filter_modules' ]) && ! empty ( $data [ 'filter_modules' ])) {
$string_filter = ' AND id_agente_modulo IN (' . implode ( ',' , $data [ 'filter_modules' ]) . ')' ;
2020-03-26 12:29:38 +01:00
}
2019-12-19 20:42:29 +01:00
$sql = sprintf (
' SELECT id_agente_modulo , nombre
FROM tagente_modulo
WHERE id_agente = % d
2020-02-13 09:55:49 +01:00
AND delete_pending = 0 % s ' ,
$data [ 'agent_id' ],
$string_filter
2019-12-19 20:42:29 +01:00
);
if ( is_metaconsole () === true ) {
2020-01-23 17:52:59 +01:00
$connection = metaconsole_get_connection_by_id (
2019-12-19 20:42:29 +01:00
$data [ 'metaconsole_id' ]
);
if ( metaconsole_load_external_db ( $connection ) == NOERR ) {
$modules_agent = db_get_all_rows_sql ( $sql );
if ( $modules_agent === false ) {
$modules_agent = [];
}
}
// Restore db connection.
metaconsole_restore_db ();
} else {
$modules_agent = db_get_all_rows_sql ( $sql );
}
$fields = [];
if ( isset ( $modules_agent ) === true
&& is_array ( $modules_agent ) === true
) {
$fields = array_reduce (
$modules_agent ,
function ( $carry , $item ) {
$carry [ $item [ 'id_agente_modulo' ]] = $item [ 'nombre' ];
return $carry ;
},
[]
);
}
}
$output .= html_print_select (
$fields ,
$data [ 'name' ],
(( isset ( $data [ 'selected' ]) === true ) ? $data [ 'selected' ] : '' ),
(( isset ( $data [ 'script' ]) === true ) ? $data [ 'script' ] : '' ),
(( isset ( $data [ 'nothing' ]) === true ) ? $data [ 'nothing' ] : '' ),
(( isset ( $data [ 'nothing_value' ]) === true ) ? $data [ 'nothing_value' ] : 0 ),
(( isset ( $data [ 'return' ]) === true ) ? $data [ 'return' ] : false ),
(( isset ( $data [ 'multiple' ]) === true ) ? $data [ 'multiple' ] : false ),
(( isset ( $data [ 'sort' ]) === true ) ? $data [ 'sort' ] : true ),
(( isset ( $data [ 'class' ]) === true ) ? $data [ 'class' ] : '' ),
(( isset ( $data [ 'disabled' ]) === true ) ? $data [ 'disabled' ] : false ),
(( isset ( $data [ 'style' ]) === true ) ? $data [ 'style' ] : false ),
(( isset ( $data [ 'option_style' ]) === true ) ? $data [ 'option_style' ] : false ),
(( isset ( $data [ 'size' ]) === true ) ? $data [ 'size' ] : false ),
(( isset ( $data [ 'modal' ]) === true ) ? $data [ 'modal' ] : false ),
(( isset ( $data [ 'message' ]) === true ) ? $data [ 'message' ] : '' ),
(( isset ( $data [ 'select_all' ]) === true ) ? $data [ 'select_all' ] : false )
);
break ;
2020-05-14 17:42:58 +02:00
case 'select_multiple_filtered' :
$output .= html_print_select_multiple_filtered (
$data [ 'available' ],
$data [ 'selected' ],
(( isset ( $data [ 'name' ]) === true ) ? $data [ 'name' ] : null ),
(( isset ( $data [ 'class' ]) === true ) ? $data [ 'class' ] : '' ),
(( isset ( $data [ 'return' ]) === true ) ? $data [ 'return' ] : true ),
(( isset ( $data [ 'group_filter' ]) === true ) ? $data [ 'group_filter' ] : []),
(( isset ( $data [ 'texts' ]) === true ) ? $data [ 'texts' ] : []),
(( isset ( $data [ 'sections' ]) === true ) ? $data [ 'sections' ] : [])
);
break ;
2020-07-07 19:10:24 +02:00
case 'select_multiple_modules_filtered' :
$output .= html_print_select_multiple_modules_filtered ( $data );
break ;
2020-10-30 13:25:33 +01:00
case 'datalist' :
$output .= html_print_datalist (
$data [ 'name' ],
$data [ 'value' ],
(( isset ( $data [ 'return' ]) === true ) ? $data [ 'return' ] : true )
);
break ;
2022-05-19 18:00:49 +02:00
case 'select_multiple_modules_filtered_select2' :
$output .= '<li class="agents_select2">' ;
$output .= html_print_label ( __ ( 'Agents' ), '' , true );
$output .= html_print_select (
$data [ 'agent_values' ],
$data [ 'agent_name' ],
$data [ 'agent_ids' ],
'agent_multiple_change(this, \'' . base64_encode ( json_encode ( $data )) . '\')' ,
'' ,
0 ,
true ,
true ,
true ,
'' ,
false ,
'min-width: 150px; max-height: 100px' ,
false ,
false ,
false ,
'' ,
false ,
false ,
false ,
false ,
true ,
true ,
true
);
$output .= '</li>' ;
// $output .= html_print_input_hidden(
// 'id_agents2-multiple-text',
// json_encode($agents_select)
// );
$selection = [
0 => __ ( 'Show common modules' ),
1 => __ ( 'Show all modules' ),
];
$output .= '<li>' ;
$output .= html_print_label ( __ ( 'Type' ), '' , true );
$output .= html_print_select (
$selection ,
$data [ 'selectionModulesNameId' ],
$data [ 'selectionModules' ],
'selection_multiple_change(\'' . base64_encode ( json_encode ( $data )) . '\')' ,
'' ,
0 ,
true ,
false ,
true ,
'' ,
false ,
'min-width: 180px'
);
$output .= '</li>' ;
$all_modules = [];
if ( empty ( $data [ 'agent_ids' ]) === false ) {
$all_modules = get_modules_agents (
0 ,
$data [ 'agent_ids' ],
$data [ 'selectionModules' ],
2022-10-10 11:20:03 +02:00
true ,
false ,
( isset ( $data [ 'notStringModules' ]) === true && $data [ 'notStringModules' ] === true ) ? true : false
2022-05-19 18:00:49 +02:00
);
}
$output .= '<li class="modules_select2">' ;
$output .= html_print_label ( __ ( 'Modules' ), '' , true );
$output .= html_print_select (
$all_modules ,
$data [ 'modules_name' ],
$data [ 'modules_ids' ],
'' ,
'' ,
0 ,
true ,
true ,
true ,
'' ,
false ,
'min-width: 150px; max-width: 500px; max-height: 100px' ,
false ,
false ,
false ,
'' ,
false ,
false ,
false ,
false ,
true ,
true ,
true
);
$output .= '</li>' ;
// $output .= html_print_input_hidden(
// 'module-multiple-text',
// json_encode($agents_select)
// );
break ;
2023-05-08 10:35:59 +02:00
case 'select_add_elements' :
if ( empty ( $data [ 'selected' ]) === false ) {
foreach ( $data [ 'selected' ] as $key => $value ) {
unset ( $data [ 'fields' ][ $key ]);
}
}
2023-07-06 09:20:21 +02:00
$output .= '<div>' ;
2023-05-08 10:35:59 +02:00
$output .= html_print_select (
(( isset ( $data [ 'selected' ]) === true ) ? $data [ 'selected' ] : '' ),
$data [ 'name' ],
'' ,
(( isset ( $data [ 'script' ]) === true ) ? $data [ 'script' ] : '' ),
(( isset ( $data [ 'nothing' ]) === true ) ? $data [ 'nothing' ] : '' ),
(( isset ( $data [ 'nothing_value' ]) === true ) ? $data [ 'nothing_value' ] : 0 ),
(( isset ( $data [ 'return' ]) === true ) ? $data [ 'return' ] : false ),
(( isset ( $data [ 'multiple' ]) === true ) ? $data [ 'multiple' ] : false ),
(( isset ( $data [ 'sort' ]) === true ) ? $data [ 'sort' ] : true ),
(( isset ( $data [ 'class' ]) === true ) ? $data [ 'class' ] : '' ),
(( isset ( $data [ 'disabled' ]) === true ) ? $data [ 'disabled' ] : false ),
(( isset ( $data [ 'style' ]) === true ) ? $data [ 'style' ] : false ),
(( isset ( $data [ 'option_style' ]) === true ) ? $data [ 'option_style' ] : false ),
(( isset ( $data [ 'size' ]) === true ) ? $data [ 'size' ] : false ),
(( isset ( $data [ 'modal' ]) === true ) ? $data [ 'modal' ] : false ),
(( isset ( $data [ 'message' ]) === true ) ? $data [ 'message' ] : '' ),
(( isset ( $data [ 'select_all' ]) === true ) ? $data [ 'select_all' ] : false ),
(( isset ( $data [ 'simple_multiple_options' ]) === true ) ? $data [ 'simple_multiple_options' ] : false ),
(( isset ( $data [ 'required' ]) === true ) ? $data [ 'required' ] : false ),
(( isset ( $data [ 'truncate_size' ]) === true ) ? $data [ 'truncate_size' ] : false ),
(( isset ( $data [ 'select2_enable' ]) === true ) ? $data [ 'select2_enable' ] : true ),
(( isset ( $data [ 'select2_multiple_enable' ]) === true ) ? $data [ 'select2_multiple_enable' ] : false ),
(( isset ( $data [ 'select2_multiple_enable_all' ]) === true ) ? $data [ 'select2_multiple_enable_all' ] : false ),
(( isset ( $data [ 'form' ]) === true ) ? $data [ 'form' ] : '' ),
(( isset ( $data [ 'order' ]) === true ) ? $data [ 'order' ] : false )
);
2023-07-06 09:20:21 +02:00
$output .= '<div class="flex justify-content-between mrgn_top_5px">' ;
2023-05-08 10:35:59 +02:00
$output .= html_print_button (
__ ( 'Add' ),
'add_column' ,
false ,
'addElement("' . $data [ 'name' ] . '", "modal_' . $data [ 'name' ] . '")' ,
[
'style' => 'max-width: fit-content; min-width: auto; height: 30px; border: 0px;' ,
'class' => 'sub' ,
'icon' => 'plus' ,
],
true ,
false ,
false ,
''
);
$output .= html_print_button (
__ ( 'Remove' ),
'remove_column' ,
false ,
'removeElement("' . $data [ 'name' ] . '", "modal_' . $data [ 'name' ] . '")' ,
[
'style' => 'max-width: fit-content; min-width: auto; height: 30px; border: 0px;' ,
'class' => 'sub' ,
'icon' => 'delete' ,
],
true ,
false ,
false ,
''
);
$output .= '<div id="modal_' . $data [ 'name' ] . '" class="modal-select-add-elements" style="display: none;">' ;
$output .= html_print_select (
$data [ 'fields' ],
$data [ 'name' ] . '_select_modal' ,
'' ,
'' ,
'' ,
0 ,
true ,
true ,
true ,
'' ,
false ,
'width: 80%'
);
$output .= '</div>' ;
$output .= '</div>' ;
$output .= '</div>' ;
?>
< ? php
break ;
2023-07-12 15:54:04 +02:00
case 'datetime' :
$date = ( empty ( $data [ 'value' ]) === true ) ? '' : date ( 'Y-m-d' , $data [ 'value' ]);
$time = ( empty ( $data [ 'value' ]) === true ) ? '' : date ( 'H:i:s' , $data [ 'value' ]);
ui_require_css_file ( 'datepicker' );
ui_include_time_picker ();
ui_require_jquery_file (
'ui.datepicker-' . get_user_language (),
'include/javascript/i18n/'
);
$inputDate = html_print_input_text (
$data [ 'name' ] . '_date' ,
$date ,
'' ,
false ,
10 ,
true ,
false ,
false ,
'' ,
'' ,
'' ,
'off'
);
$inputTime = html_print_input_text (
$data [ 'name' ] . '_time' ,
$time ,
'' ,
false ,
10 ,
true ,
false ,
false ,
'' ,
'' ,
'' ,
'off'
);
$output .= html_print_div (
[
'content' => sprintf (
'<div class="datetime-adv-opt">%s<span>:</span>%s</div>' ,
$inputDate ,
$inputTime
),
],
true
);
break ;
2019-06-21 19:34:47 +02:00
default :
// Ignore.
break ;
}
2020-01-09 12:07:19 +01:00
if ( isset ( $data [ 'wrapper' ]) === true ) {
$output .= '</' . $data [ 'wrapper' ] . '>' ;
}
2022-01-11 12:08:41 +01:00
if (( $data [ 'label' ] ? ? false ) && $input_only === false ) {
2019-07-10 23:59:09 +02:00
$output .= '</' . $wrapper . '>' ;
2019-06-21 19:34:47 +02:00
if ( ! $data [ 'return' ]) {
2019-07-10 23:59:09 +02:00
echo '</' . $wrapper . '>' ;
2019-06-21 19:34:47 +02:00
}
}
return $output ;
}
2019-09-17 13:38:17 +02:00
2019-11-12 13:16:25 +01:00
/**
* Print all checkbox in the same row .
*
* @ param array $data Array with attributes input .
* only name is necessary .
*
* @ return string
*/
function html_print_input_multicheck ( array $data ) : string
{
$html = '' ;
if ( isset ( $data [ 'data' ]) === true && is_array ( $data [ 'data' ]) === true ) {
foreach ( $data [ 'data' ] as $key => $value ) {
$html .= $value ;
$html .= html_print_checkbox (
'days_week_' . $key ,
1 ,
$data [ 'checked' ][ $key ],
true
);
}
}
return $html ;
}
2019-09-17 13:38:17 +02:00
/**
* Print an autocomplete input filled out with Integria IMS users .
*
2021-05-10 11:17:14 +02:00
* @ param string $name The name of ajax control , by default is " users " .
* @ param string $default The default value to show in the ajax control .
* @ param boolean $return If it is true return a string with the output instead to echo the output .
* @ param string $size Size .
* @ param boolean $disable Disable the button ( optional , button enabled by default ) .
* @ param boolean $required Attribute required .
* @ param string $class Text inpunt class .
2019-09-17 13:38:17 +02:00
*
* @ return mixed If the $return is true , return the output as string .
*/
function html_print_autocomplete_users_from_integria (
$name = 'users' ,
$default = '' ,
$return = false ,
2019-09-23 12:48:20 +02:00
$size = '30' ,
$disable = false ,
2021-05-10 11:17:14 +02:00
$required = false ,
$class = null
2019-09-17 13:38:17 +02:00
) {
global $config ;
2021-04-09 12:00:11 +02:00
$user_icon = 'images/user_green.png' ;
2022-01-17 10:22:30 +01:00
if ( $config [ 'style' ] === 'pandora_black' && ! is_metaconsole ()) {
2021-04-09 12:00:11 +02:00
$user_icon = 'images/header_user.png' ;
}
2019-09-17 13:38:17 +02:00
ob_start ();
2021-04-09 12:00:11 +02:00
$attrs = [ 'style' => 'background: url(' . $user_icon . ') no-repeat right;' ];
2019-09-23 12:48:20 +02:00
if ( $required ) {
$attrs [ 'required' ] = 'required' ;
}
2021-05-10 11:17:14 +02:00
if ( empty ( $class ) === false ) {
$attrs [ 'class' ] = $class ;
}
2023-03-22 14:08:03 +01:00
ui_print_help_tip ( __ ( 'Type at least two characters to search the user.' ), false );
2019-09-17 13:38:17 +02:00
html_print_input_text_extended (
$name ,
$default ,
'text-' . $name ,
'' ,
$size ,
100 ,
2019-09-23 12:48:20 +02:00
$disable ,
2019-09-17 13:38:17 +02:00
'' ,
2019-09-23 12:48:20 +02:00
$attrs
2019-09-17 13:38:17 +02:00
);
html_print_input_hidden ( $name . '_hidden' , $id_agent_module );
2019-09-23 12:48:20 +02:00
2019-09-17 13:38:17 +02:00
$javascript_ajax_page = ui_get_full_url ( 'ajax.php' , false , false , false , false );
?>
< script type = " text/javascript " >
function escapeHTML ( str )
{
var div = document . createElement ( 'div' );
var text = document . createTextNode ( str );
div . appendChild ( text );
return div . innerHTML ;
}
$ ( document ) . ready ( function () {
$ ( " #text-<?php echo $name ; ?> " ) . autocomplete ({
minLength : 2 ,
source : function ( request , response ) {
var term = request . term ; //Word to search
data_params = {
page : " include/ajax/integria_incidents.ajax " ,
search_term : term ,
get_users : 1 ,
};
jQuery . ajax ({
data : data_params ,
async : false ,
type : " POST " ,
url : action = " <?php echo $javascript_ajax_page ; ?> " ,
timeout : 10000 ,
dataType : " json " ,
success : function ( data ) {
temp = [];
$ . each ( data , function ( id , module ) {
temp . push ({
'value' : id ,
'label' : module });
});
response ( temp );
}
});
},
change : function ( event , ui ) {
if ( ! ui . item )
$ ( " input[name='<?php echo $name ; ?>_hidden'] " )
. val ( 0 );
return false ;
},
select : function ( event , ui ) {
$ ( " input[name='<?php echo $name ; ?>_hidden'] " )
. val ( ui . item . value );
$ ( " #text-<?php echo $name ; ?> " ) . val ( ui . item . label );
return false ;
}
}
);
});
</ script >
< ? php
$output = ob_get_clean ();
if ( $return ) {
return $output ;
} else {
echo $output ;
}
2019-09-17 12:59:29 +02:00
}
2019-12-17 10:57:19 +01:00
function html_print_tabs ( array $tabs )
{
2021-03-18 10:35:19 +01:00
global $config ;
$bg_color = '' ;
2022-01-17 10:22:30 +01:00
if ( $config [ 'style' ] === 'pandora_black' && ! is_metaconsole ()) {
2021-03-18 10:35:19 +01:00
$bg_color = 'style="background-color: #222"' ;
}
2019-12-17 10:57:19 +01:00
$result = '<div id="html-tabs">' ;
2021-03-18 10:35:19 +01:00
$result .= '<ul class="" ' . $bg_color . '>' ;
2019-12-17 10:57:19 +01:00
foreach ( $tabs as $key => $value ) {
$result .= " <li><a href=' " . $value [ 'href' ] . " ' id=' " . $value [ 'id' ] . " '> " ;
$result .= html_print_image (
'images/' . $value [ 'img' ],
2023-03-21 18:42:31 +01:00
true ,
[ 'class' => 'main_menu_icon invert_filter' ]
2019-12-17 10:57:19 +01:00
);
$result .= '<span>' . $value [ 'name' ] . '</span>' ;
$result .= '</a></li>' ;
}
$result .= '</ul>' ;
$result .= '</div>' ;
return $result ;
}
2020-10-30 13:25:33 +01:00
/**
* Create a datalist .
*
* @ param string $id Use custom id .
2021-09-20 12:16:08 +02:00
* @ param array $values Input values .
2020-10-30 13:25:33 +01:00
* @ param string $returnparam Whether to return an output string or echo now ( optional , echo by default ) .
*
* @ return string HTML code if return parameter is true .
*/
function html_print_datalist (
$id ,
$values ,
$return = false
) {
$result = '<datalist id="' . $id . '">' ;
foreach ( $values as $key => $value ) {
$result .= '<option value="' . $value . '">' ;
}
$result .= '</datalist>' ;
if ( $return ) {
return $result ;
} else {
echo $result ;
}
}
2021-04-06 18:51:14 +02:00
/**
* Print or return selector with search bar .
*
* @ param string $fields Select fields
* @ param boolean $name Name of input field .
* @ param array $selected Array with dropdown values . Example :
* $fields [ " value " ] = " label " .
* @ param string $script Javascript onChange code .
* @ param mixed $nothing Label when nothing is selected .
* @ param array $nothing_value Value when nothing is selected .
* @ param string $return Return string or dump to output .
* @ param boolean $multiple Enable multiple select .
* @ param mixed $sort Sort values or not ( default false ) .
* @ param boolean $class CSS classes to apply .
* @ param boolean $disabled Disabled or enabled .
* @ param boolean $style CSS inline style .
* @ param string $option_style CSS inline style in array format .
* @ param string $size Style , size ( width ) of element .
* @ param boolean $simple_multiple_options Discovery simple multiple inputs .
* @ param boolean $required Required input .
* @ param boolean $dropdownAutoWidth Set dropdown auto width .
*
* @ return string HTML code if return parameter is true .
*/
function html_print_select_search (
$fields = [],
$name = null ,
$selected = '' ,
$script = '' ,
$nothing = '' ,
$nothing_value = 0 ,
$return = false ,
$multiple = false ,
$sort = false ,
$class = '' ,
$disabled = false ,
$style = false ,
$option_style = false ,
$size = false ,
$simple_multiple_options = false ,
$required = false ,
$dropdownAutoWidth = false
) {
2021-04-09 12:00:11 +02:00
global $config ;
2021-04-06 18:51:14 +02:00
$output = '' ;
2021-04-09 12:00:11 +02:00
$select2_css = 'select2.min' ;
2022-01-17 10:22:30 +01:00
if ( $config [ 'style' ] === 'pandora_black' && ! is_metaconsole ()) {
2021-04-09 12:00:11 +02:00
$select2_css = 'select2_dark.min' ;
}
ui_require_css_file ( $select2_css );
2021-04-06 18:51:14 +02:00
ui_require_javascript_file ( 'select2.min' );
if ( $name === null ) {
static $idcounter = [];
if ( isset ( $idcounter [ $name ]) === true ) {
$idcounter [ $name ] ++ ;
} else {
$idcounter [ $name ] = 0 ;
}
$name = 'select' . $idcounter [ $name ];
}
if ( empty ( $nothing ) === false ) {
$fields [ $nothing_value ] = $nothing ;
}
$output .= html_print_select (
$fields ,
$name ,
$selected ,
$script ,
$nothing ,
$nothing_value ,
$return ,
$multiple ,
$sort ,
$class ,
$disabled ,
$style ,
$option_style ,
$size ,
false ,
'' ,
false ,
$simple_multiple_options ,
$required
);
if ( empty ( $size ) === true ) {
$size = '100%' ;
}
ob_start ();
?>
< style type = " text/css " >
. select2 - search__field {
background : url ( '<?php echo ui_get_full_url(' images / zoom . png '); ?>' ) no - repeat ;
background - position : right 10 px center ;
background - size : 1 em ;
}
</ style >
< script type = " text/javascript " >
$ ( document ) . ready ( function () {
$ ( 'select[name="<?php echo $name; ?>"]' ) . each (
function () {
$ ( this ) . select2 ({
multiple : < ? php echo ( $multiple ) ? 'true' : 'false' ; ?> ,
placeholder : " <?php echo __('Please select...'); ?> " ,
debug : 0 ,
width : '<?php echo $size; ?>' ,
dropdownAutoWidth : '<?php echo $dropdownAutoWidth; ?>' ,
templateResult : function ( node ) {
if ( ! node . id ) {
return node . text ;
}
return $ ( '<span style="padding-left:' + ( 5 * node . level ) + 'px;">' + node . text + '</span>' );
}
});
}
);
< ? php
if ( empty ( $fields ) === true ) {
?>
$ ( 'select[name="<?php echo $name; ?>"]' ) . val ( null ) . trigger ( " change " );
$ ( 'select[name="<?php echo $name; ?>"] option[value=""]' ) . each ( function () {
$ ( this ) . remove ();
});
< ? php
}
?>
});
</ script >
< ? php
$output .= ob_get_clean ();
if ( $return ) {
return $output ;
} else {
echo $output ;
}
2021-04-19 12:59:52 +02:00
}
2022-02-03 12:56:36 +01:00
/**
* Print html select for agents secondary .
*
* @ param integer $agent Agent .
* @ param integer $id_agente Id Agent .
* @ param array $options Array options .
*
* @ return string Html output .
*/
function html_print_select_agent_secondary ( $agent , $id_agente , $options = [])
{
ui_require_css_file ( 'agent_manager' );
ui_require_javascript_file ( 'pandora_agents' );
if ( empty ( $options ) === '' || isset ( $options [ 'id_form' ]) === false ) {
$options [ 'id_form' ] = 'form_agent' ;
}
2022-02-03 13:52:40 +01:00
if ( empty ( $options ) === '' || isset ( $options [ 'extra_id' ]) === false ) {
2022-02-03 12:56:36 +01:00
$options [ 'extra_id' ] = '' ;
}
2022-02-03 13:52:40 +01:00
if ( empty ( $options ) === '' || isset ( $options [ 'only_select' ]) === false ) {
$options [ 'only_select' ] = false ;
}
2022-02-03 12:56:36 +01:00
$secondary_groups_selected = enterprise_hook (
'agents_get_secondary_groups' ,
[ $id_agente ]
);
2023-04-12 08:21:26 +02:00
if ( $options [ 'selected_post' ] !== null ) {
$secondary_groups_selected [ 'plain' ] = $options [ 'selected_post' ];
}
$name = 'secondary_groups_selected[]' . $options [ 'extra_id' ];
2022-02-03 13:52:40 +01:00
if ( $options [ 'only_select' ] === true ) {
$name = 'secondary_groups' . $options [ 'extra_id' ] . '[]' ;
}
2022-02-03 12:56:36 +01:00
$adv_secondary_groups_left = html_print_select_groups (
// Id_user.
// Use the current user to select the groups.
false ,
// Privilege.
// ACL permission.
'AR' ,
// ReturnAllGroup.
// Not all group.
false ,
// Name.
// HTML id.
2022-02-03 13:52:40 +01:00
$name ,
2022-02-03 12:56:36 +01:00
// Selected.
// No select any by default.
2023-04-12 08:21:26 +02:00
$secondary_groups_selected [ 'plain' ],
2022-02-03 12:56:36 +01:00
// Script.
// Javascript onChange code.
'' ,
// Nothing.
// Do not user no selected value.
false ,
// Nothing_value.
// Do not use no selected value.
0 ,
// Return.
// Return HTML (not echo).
true ,
// Multiple.
// Multiple selection.
true ,
// Sort.
// Sorting by default.
true ,
// Class.
// CSS classnames (default).
'' ,
// Disabled.
// Not disabled (default).
false ,
// Style.
// Inline styles (default).
2022-11-15 08:05:04 +01:00
'' ,
2022-02-03 12:56:36 +01:00
// Option_style.
// Option style select (default).
false ,
// Id_group.
// Do not truncate the users tree (default).
false ,
// Keys_field.
// Key to get as value (default).
'id_grupo' ,
// Strict_user.
// Not strict user (default).
false ,
// Delete_groups.
// Do not show the primary group in this selection.
array_merge (
( empty ( $secondary_groups_selected [ 'plain' ]) === false ) ? $secondary_groups_selected [ 'plain' ] : [],
[ $agent [ 'id_grupo' ]]
)
// Include_groups.
// Size.
// Simple_multiple_options.
);
2022-02-03 13:52:40 +01:00
if ( $options [ 'only_select' ] === false ) {
$dictionary = base64_encode (
json_encode (
[
'primary_group' => __ ( 'Primary group cannot be secondary too.' ),
'strNone' => __ ( 'None' ),
]
)
);
2022-11-15 08:05:04 +01:00
/*
$adv_secondary_groups_arrows = html_print_input_image (
2022-02-03 13:52:40 +01:00
'add_secondary' ,
'images/darrowright_green.png' ,
1 ,
'' ,
true ,
2022-02-03 12:56:36 +01:00
[
2022-02-03 13:52:40 +01:00
'id' => 'right_autorefreshlist' . $options [ 'extra_id' ],
'title' => __ ( 'Add secondary groups' ),
'onclick' => 'agent_manager_add_secondary_groups(event, ' . $id_agente . ',\'' . $options [ 'extra_id' ] . '\', \'' . $options [ 'id_form' ] . '\', \'' . $dictionary . '\');' ,
2022-02-03 12:56:36 +01:00
]
2022-11-15 08:05:04 +01:00
);
2022-02-03 12:56:36 +01:00
2022-11-15 08:05:04 +01:00
$adv_secondary_groups_arrows .= html_print_input_image (
2022-02-03 13:52:40 +01:00
'remove_secondary' ,
'images/darrowleft_green.png' ,
1 ,
'' ,
true ,
[
'id' => 'left_autorefreshlist' . $options [ 'extra_id' ],
'title' => __ ( 'Remove secondary groups' ),
'onclick' => 'agent_manager_remove_secondary_groups(event, ' . $id_agente . ',\'' . $options [ 'extra_id' ] . '\', \'' . $options [ 'id_form' ] . '\', \'' . $dictionary . '\');' ,
]
2022-11-15 08:05:04 +01:00
);
2022-02-03 12:56:36 +01:00
2022-11-15 08:05:04 +01:00
$adv_secondary_groups_right .= html_print_select (
// Values.
2022-02-03 13:52:40 +01:00
$secondary_groups_selected [ 'for_select' ],
// HTML id.
'secondary_groups_selected' . $options [ 'extra_id' ],
// Selected.
'' ,
// Javascript onChange code.
'' ,
// Nothing selected.
false ,
// Nothing selected.
0 ,
// Return HTML (not echo).
true ,
// Multiple selection.
true ,
// Sort.
true ,
// Class.
'' ,
// Disabled.
false ,
// Style.
'min-width:170px;'
2022-11-15 08:05:04 +01:00
);
*/
2022-02-03 13:52:40 +01:00
$output = '' ;
if ( isset ( $options [ 'container' ]) === true
&& $options [ 'container' ] === true
) {
$output = '<div class="secondary_groups_list">' ;
}
2022-02-03 12:56:36 +01:00
2022-02-03 13:52:40 +01:00
$output .= '<div class="sg_source">' ;
$output .= $adv_secondary_groups_left ;
$output .= '</div>' ;
2022-11-15 08:05:04 +01:00
/*
$output .= '<div class="secondary_group_arrows">' ;
$output .= $adv_secondary_groups_arrows ;
$output .= '</div>' ;
$output .= '<div class="sg_target">' ;
$output .= $adv_secondary_groups_right ;
$output .= '</div>' ;
*/
2022-02-03 13:52:40 +01:00
if ( isset ( $options [ 'container' ]) === true
&& $options [ 'container' ] === true
) {
$output .= '</div>' ;
}
} else {
$output .= $adv_secondary_groups_left ;
2022-02-03 12:56:36 +01:00
}
return $output ;
}
2022-06-30 13:41:56 +02:00
/**
* Prints a simple 'Go Back' button .
*
* @ param string $url Destination Url .
* @ param array $options Options .
* `button_class` : Class for button . 'w100p' by default .
* `title` : Title of the button . 'Go Back' by default .
* `action_class` : Class of icon of button . 'cancel' by default .
* @ param boolean $return If true , return a formed HTML element .
*
* @ return mixed
*/
function html_print_go_back_button ( string $url , array $options = [], bool $return = false )
{
$output = html_print_div (
[
'class' => ( $options [ 'button_class' ] ? ? 'w100p' ),
'content' => html_print_button (
( $options [ 'title' ] ? ? __ ( 'Go back' )),
'go_back' ,
false ,
2023-03-06 16:21:10 +01:00
'window.location.href = "' . $url . '"' ,
2022-10-28 15:01:00 +02:00
[
2022-12-15 12:42:35 +01:00
'icon' => ( $options [ 'action_class' ] ? ? 'back' ),
2022-10-28 15:01:00 +02:00
'mode' => 'secondary' ,
],
2022-06-30 13:41:56 +02:00
true
),
2023-02-06 23:10:28 +01:00
'style' => ( $options [ 'style' ] ? ? 'z-index: 10001' ),
2022-06-30 13:41:56 +02:00
],
$return
);
return $output ;
}
2022-08-16 18:42:51 +02:00
/**
* Render select box for numeric values and text box for complex values .
*
* @ param string $name Select form name .
* @ param string $fields Fields to populate select box .
* @ param mixed $selected Current selected value . It can be a single value or an array of selected values ( in combination with multiple ) .
* @ param string $script Javascript onChange ( select ) code .
* @ param string $nothing Label when nothing is selected .
* @ param mixed $nothing_value Value when nothing is selected .
* @ param integer $size Size of the input .
* @ param boolean $return Whether to return an output string or echo now ( optional , echo by default ) .
* @ param boolean $select_style Wherter to assign to combo a unique name ( to have more than one on same page , like dashboard ) .
* @ param boolean $unique_name Uunique name value .
* @ param boolean $disabled Input renders as disabled .
* @ param boolean $no_change No change value .
* @ param boolean $text_help Tooltip .
* @ return string HTML code if return parameter is true .
*/
function html_print_extended_select_for_downtime_cron (
$name ,
$fields ,
$selected = '' ,
$script = '' ,
$nothing = '' ,
$nothing_value = '0' ,
$size = false ,
$return = false ,
$select_style = false ,
$unique_name = true ,
$disabled = false ,
$no_change = 0 ,
$text_help = ''
) {
global $config ;
if ( $unique_name === true ) {
$uniq_name = uniqid ( $name );
} else {
$uniq_name = $name ;
}
ob_start ();
echo '<div id="' . $uniq_name . '_default" class="w100p inline_line">' ;
html_print_select (
$fields ,
$uniq_name . '_select' ,
$selected ,
'' . $script ,
$nothing ,
$nothing_value ,
false ,
false ,
false ,
'' ,
$disabled ,
'font-size: xx-small;' . $select_style
);
2023-03-08 15:01:41 +01:00
echo ' <a style="margin: 7px" href="javascript:">' . html_print_image (
2023-02-27 16:33:46 +01:00
'images/edit.svg' ,
2022-08-16 18:42:51 +02:00
true ,
[
2023-02-27 16:33:46 +01:00
'class' => $uniq_name . '_toggler main_menu_icon invert_filter' ,
2022-08-16 18:42:51 +02:00
'alt' => __ ( 'Custom' ),
'title' => __ ( 'Custom' ),
2023-03-08 15:01:41 +01:00
// 'style' => 'margin: 7px;',
2022-08-16 18:42:51 +02:00
]
) . '</a>' ;
echo '</div>' ;
echo '<div id="' . $uniq_name . '_manual" class="w100p inline_line">' ;
2023-03-08 15:01:41 +01:00
html_print_input_text ( $uniq_name . '_text' , $selected , '' , 20 , 20 , false , false , false , '' , 'w100p' );
2022-08-16 18:42:51 +02:00
html_print_input_hidden ( $name , $selected , false , $uniq_name );
2023-03-08 15:01:41 +01:00
echo ' <a href="javascript:">' . html_print_image (
2023-02-27 16:33:46 +01:00
'images/logs@svg.svg' ,
2022-08-16 18:42:51 +02:00
true ,
[
2023-02-27 16:33:46 +01:00
'class' => $uniq_name . '_toggler main_menu_icon invert_filter' ,
2022-08-16 18:42:51 +02:00
'alt' => __ ( 'List' ),
'title' => __ ( 'List' ),
2023-03-08 15:01:41 +01:00
'style' => 'margin: 7px;' ,
2022-08-16 18:42:51 +02:00
]
) . '</a>' ;
2023-03-08 15:01:41 +01:00
echo ( $text_help !== '' ) ? ui_print_help_tip ( __ ( $text_help ), true , '' , false , 'margin: 13px 0 0 5px;' ) : '' ;
2022-08-16 18:42:51 +02:00
echo '</div>' ;
$select_init_func = ( is_numeric ( $selected ) === true || $selected === '*' ) ? 'post_process_select_init' : 'post_process_select_init_inv' ;
echo " <script type='text/javascript'>
$ ( document ) . ready ( function () {
" . $select_init_func . " ( '$uniq_name' , '$selected' );
post_process_select_events_unit ( '$uniq_name' , '$selected' );
});
2023-03-08 15:01:41 +01:00
2022-08-16 18:42:51 +02:00
</ script > " ;
$returnString = ob_get_clean ();
if ( $return ) {
return $returnString ;
} else {
echo $returnString ;
}
}
2023-02-09 10:12:59 +01:00
/**
* Ellipse string to x characters .
*
* @ param string $string String to ellipsis .
* @ param integer $characters Characters size to show .
* @ return string String ellipsed .
*/
function html_ellipsis_characters (
string $string ,
int $characters ,
bool $return = false
) {
$out = $string ;
if ( strlen ( $string ) > $characters ) {
$out = substr ( $string , 0 , $characters ) . '...' ;
}
if ( $return === true ) {
return $out ;
} else {
echo $out ;
}
2023-03-10 09:38:55 +01:00
}
2022-12-02 14:25:22 +01:00
/**
2023-02-07 15:39:53 +01:00
* Return formed subtitle with the new Pandora ' s style .
2022-12-02 14:25:22 +01:00
*
2023-02-07 15:39:53 +01:00
* @ param string $caption Caption of title .
* @ param array $options Available options .
* - `id` : string
* - `style` : string
* - `class` : string . `section_table_title` by default .
* - `wrapper` : string . Must be a valid tag .
* - `wrapper_attributes` : string . Valid attributes for a wrapper .
2022-12-02 14:25:22 +01:00
*
2023-02-22 14:19:57 +01:00
* @ return array
2022-12-02 14:25:22 +01:00
*/
2023-02-07 15:39:53 +01:00
function html_print_subtitle_table ( string $caption , array $options = [])
2022-12-02 14:25:22 +01:00
{
if ( isset ( $options [ 'wrapper' ]) === true ) {
$startWrapper = '<' . $options [ 'wrapper' ] . ' ' . ( $options [ 'wrapper_attributes' ] ? ? '' ) . '>' ;
$endWrapper = '</' . $options [ 'wrapper' ] . '>' ;
$caption = $startWrapper . $caption . $endWrapper ;
}
2023-02-07 15:39:53 +01:00
$output = [];
$output [ 0 ] = html_print_div ([ 'class' => 'section_table_title_line' ], true );
$output [ 1 ] = html_print_div (
2022-12-02 14:25:22 +01:00
[
'id' => ( $options [ 'id' ] ? ? '' ),
'class' => ( $options [ 'class' ] ? ? 'section_table_title' ),
'style' => ( $options [ 'style' ] ? ? '' ),
'content' => $caption ,
],
2023-02-07 15:39:53 +01:00
true
2022-12-02 14:25:22 +01:00
);
2023-02-07 15:33:29 +01:00
return $output ;
}
2022-12-15 12:42:35 +01:00
/**
* Prints a menu button .
*
* @ param array $options Available options .
* - `id` : Id for the anchor .
* - `style` : Anchor inline styles .
* - `href` : Route to go .
* - `class` : Class for the anchor .
* - `image` : Path of the image .
* - `image_class` : Class for image . `invert_filter main_menu_icon` by default .
* - `title` : Alt Title for the image .
* - `disabled` : If true , the button does nothing .
* - `disabled_title` : If filled , add to the button and additional information .
* - `disabled_allow_onclick` : If true , the button will do onclick .
* - `onClick` : onClick action for anchor .
* - `content` : Alternative content .
* @ param boolean $return If true , returns a string with formed menu button .
*
* @ return string .
*/
function html_print_menu_button ( array $options , bool $return = false )
{
// Disabled.
if ( isset ( $options [ 'disabled' ]) === true && $options [ 'disabled' ] === true ) {
$options [ 'href' ] = '#' ;
$options [ 'title' ] .= ( $options [ 'disabled_title' ] ? ? '' );
$options [ 'image_class' ] = ( isset ( $options [ 'image_class' ]) === true ) ? $options [ 'image_class' ] . ' alpha50' : 'alpha50 main_menu_icon' ;
if ( isset ( $options [ 'disabled_allow_onclick' ]) === false || $options [ 'disabled_allow_onclick' ] !== true ) {
$options [ 'onClick' ] = '' ;
}
}
// Attach the image. Otherwise, add additional content if user desires.
if ( isset ( $options [ 'image' ]) === true ) {
$content = html_print_image (
$options [ 'image' ],
true ,
[
'title' => ( $options [ 'title' ] ? ? '' ),
'class' => ( $options [ 'image_class' ] ? ? 'invert_filter main_menu_icon' ),
]
);
} else {
$content = ( $options [ 'content' ] ? ? '' );
}
return html_print_anchor (
[
'id' => ( $options [ 'id' ] ? ? '' ),
'href' => ( $options [ 'href' ] ? ? '' ),
'class' => ( $options [ 'class' ] ? ? '' ),
'style' => ( $options [ 'style' ] ? ? '' ),
'onClick' => ( $options [ 'onClick' ] ? ? '' ),
2023-07-03 09:18:30 +02:00
'text' => ( $options [ 'text' ] ? ? '' ),
2022-12-15 12:42:35 +01:00
'content' => $content ,
],
$return
);
2023-02-23 10:24:03 +01:00
}
2023-02-23 12:34:41 +01:00
function html_print_label_input_block (
? string $label ,
$calbackFn ,
? array $options = []
) : string {
$label_class = '' ;
2023-03-02 15:24:54 +01:00
$divAttributes = [];
2023-02-23 12:34:41 +01:00
if ( empty ( $options ) === false ) {
if ( isset ( $options [ 'div_class' ]) === true ) {
2023-03-02 15:24:54 +01:00
$divAttributes [] = 'class="' . $options [ 'div_class' ] . '"' ;
2023-02-23 12:34:41 +01:00
}
2023-03-02 15:24:54 +01:00
if ( isset ( $options [ 'div_id' ]) === true ) {
$divAttributes [] = 'id="' . $options [ 'div_id' ] . '"' ;
2023-02-23 12:34:41 +01:00
}
2023-02-27 16:33:54 +01:00
2023-03-02 15:24:54 +01:00
if ( isset ( $options [ 'div_style' ]) === true ) {
$divAttributes [] = 'style="' . $options [ 'div_style' ] . '"' ;
}
if ( isset ( $options [ 'label_class' ]) === true ) {
$label_class = $options [ 'label_class' ];
2023-02-27 16:33:54 +01:00
}
2023-02-23 12:34:41 +01:00
}
2023-03-02 15:24:54 +01:00
$content = ( empty ( $divAttributes ) === false ) ? implode ( ' ' , $divAttributes ) : '' ;
$output = '<div ' . $content . '>' ;
2023-02-23 10:24:03 +01:00
if ( $label !== null ) {
2023-02-23 12:34:41 +01:00
$output .= '<label class="' . $label_class . '">' . $label . '</label>' ;
2023-02-23 10:24:03 +01:00
}
$output .= $calbackFn ;
$output .= '</div>' ;
2023-03-03 14:16:06 +01:00
return $output ;
}
function html_print_go_top ()
{
$output = '</div>' ;
2023-04-03 08:43:24 +02:00
$output .= '<div onclick="topFunction()" id="top_btn" class="forced_title" data-title="' . __ ( 'Go to top' ) . '" data-use_title_for_force_title="1">' ;
$output .= '<svg viewBox="0 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" class="forced_title" data-title="' . __ ( 'Go to top' ) . '" data-use_title_for_force_title="1">' ;
// $output .= '<title>'.__('Go to top').'</title>';
2023-03-03 14:16:06 +01:00
$output .= '<desc>Created with Sketch.</desc>' ;
2023-04-03 08:43:24 +02:00
$output .= '<g id="Dark-/-20-/-arrow" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" class="forced_title" data-title="' . __ ( 'Go to top' ) . '" data-use_title_for_force_title="1">' ;
$output .= '<path d="M3.41005051,6.39052429 C3.91472805,5.90987901 4.70885153,5.8729063 5.25805922,6.27960615 L5.38994949,6.39052429 L10,10.78 L14.6100505,6.39052429 C15.1147281,5.90987901 15.9088515,5.8729063 16.4580592,6.27960615 L16.5899495,6.39052429 C17.094627,6.87116957 17.1334484,7.62747765 16.7064135,8.15053259 L16.5899495,8.27614237 L10.9899495,13.6094757 C10.4852719,14.090121 9.69114847,14.1270937 9.14194078,13.7203939 L9.01005051,13.6094757 L3.41005051,8.27614237 C2.8633165,7.75544332 2.8633165,6.91122335 3.41005051,6.39052429 Z" id="Path-8" fill="#14524f" fill-rule="nonzero" transform="translate(10.000000, 10.000000) rotate(90.000000) translate(-10.000000, -10.000000) " class="forced_title" data-title="' . __ ( 'Go to top' ) . '" data-use_title_for_force_title="1"></path>' ;
2023-03-03 14:16:06 +01:00
$output .= '</g>' ;
$output .= '</svg>' ;
$output .= '</div>' ;
2023-02-23 10:24:03 +01:00
return $output ;
2023-04-19 19:21:38 +02:00
}
2023-05-05 11:32:23 +02:00
2023-04-19 19:21:38 +02:00
/**
* Render a code picker fragment with default Pandora styles .
*
* @ param string $id ,
2023-05-05 11:32:23 +02:00
* @ param string $content Content .
* @ param string $classes Classes for code picker .
* @ param boolean $single_line If true , code picker will be displayed as a single line of code .
* @ param boolean $return Return output if set to true .
2023-04-19 19:21:38 +02:00
*
* @ return string
*/
function html_print_code_picker (
string $id ,
string $content = '' ,
string $classes = '' ,
bool $single_line = false ,
bool $return = false
) {
$single_line_class = '' ;
if ( $single_line === true ) {
$single_line_class = 'single-line ' ;
}
$output = '<div class="code-fragment ' . $single_line_class . $classes . '">' ;
$output .= '<pre style="margin: 0;"><code class="code-font" id="' . $id . '" style="display: block; white-space: pre-wrap;">' . $content . '</code></pre>' ;
$output .= '</div>' ;
if ( $return === true ) {
return $output ;
} else {
echo $output ;
}
}
2023-05-23 16:54:40 +02:00
function html_print_wizard_diagnosis (
$title ,
$id_button ,
$description = '' ,
$status = true ,
$return = false ,
) {
$button = '' ;
if ( $status === true ) {
$status = 'Connected' ;
$img = '/images/configuration@svg.svg' ;
} else {
$status = 'Disconnected' ;
$img = '/images/change-active.svg' ;
}
$button = html_print_image (
$img ,
true ,
[
'class' => 'main_menu_icon invert_filter float-right mrgn_right_10px' ,
'id' => $id_button ,
]
);
$output = '<div class="rectangle rectangle_' . $status . ' " >
< span class = " status '. $status .' " > '.__($status).$button.' </ span >
< div class = " title " > '.html_print_image(' / images / circle_title . svg ', true, [' class ' => ' invert_filter ']).' < span > '.$title.' </ span ></ div >
< div class = " description " >
< span > '.$description.' </ span >
</ div >
</ div > ' ;
if ( $return === true ) {
return $output ;
} else {
echo $output ;
}
}