Unified sizes of the checkbox switch

Former-commit-id: f6f8eca748f67fdf1e4a98256c3ca590b61328ac
This commit is contained in:
manuel 2019-02-26 12:04:18 +01:00
parent b7cc25314d
commit 875d7ecaba
6 changed files with 87 additions and 1151 deletions

View File

@ -582,7 +582,7 @@ $table_other->data[3][1] = html_print_input_text(
); );
$table_other->data[5][0] = __('Use realtime statistics'); $table_other->data[5][0] = __('Use realtime statistics');
$table_other->data[5][1] = html_print_checkbox_toogle_switch( $table_other->data[5][1] = html_print_checkbox_switch(
'realtimestats', 'realtimestats',
1, 1,
$config['realtimestats'], $config['realtimestats'],
@ -604,7 +604,7 @@ $table_other->data[6][1] = html_print_input_text(
); );
$table_other->data[7][0] = __('Use agent access graph').ui_print_help_icon('agent_access', true); $table_other->data[7][0] = __('Use agent access graph').ui_print_help_icon('agent_access', true);
$table_other->data[7][1] = html_print_checkbox_toogle_switch('agentaccess', 1, $config['agentaccess'], true); $table_other->data[7][1] = html_print_checkbox_switch('agentaccess', 1, $config['agentaccess'], true);
$table_other->data[8][0] = __('Max. recommended number of files in attachment directory'); $table_other->data[8][0] = __('Max. recommended number of files in attachment directory');
$table_other->data[8][0] .= ui_print_help_tip( $table_other->data[8][0] .= ui_print_help_tip(
@ -621,7 +621,7 @@ $table_other->data[8][1] = html_print_input_text(
); );
$table_other->data[9][0] = __('Delete not init modules'); $table_other->data[9][0] = __('Delete not init modules');
$table_other->data[9][1] = html_print_checkbox_toogle_switch('delete_notinit', 1, $config['delete_notinit'], true); $table_other->data[9][1] = html_print_checkbox_switch('delete_notinit', 1, $config['delete_notinit'], true);
$table_other->data[10][0] = __('Big Operation Step to purge old data'); $table_other->data[10][0] = __('Big Operation Step to purge old data');
$table_other->data[10][0] .= ui_print_help_tip( $table_other->data[10][0] .= ui_print_help_tip(

View File

@ -44,14 +44,14 @@ if (is_ajax()) {
// Fallback to local authentication // Fallback to local authentication
$row = []; $row = [];
$row['name'] = __('Fallback to local authentication').ui_print_help_tip(__('Enable this option if you want to fallback to local authentication when remote (ldap etc...) authentication failed.'), true); $row['name'] = __('Fallback to local authentication').ui_print_help_tip(__('Enable this option if you want to fallback to local authentication when remote (ldap etc...) authentication failed.'), true);
$row['control'] = html_print_checkbox_toogle_switch('fallback_local_auth', 1, $config['fallback_local_auth'], true); $row['control'] = html_print_checkbox_switch('fallback_local_auth', 1, $config['fallback_local_auth'], true);
$table->data['fallback_local_auth'] = $row; $table->data['fallback_local_auth'] = $row;
if (enterprise_installed()) { if (enterprise_installed()) {
// Autocreate remote users // Autocreate remote users
$row = []; $row = [];
$row['name'] = __('Autocreate remote users'); $row['name'] = __('Autocreate remote users');
$row['control'] = html_print_checkbox_toogle_switch_extended('autocreate_remote_users', 1, $config['autocreate_remote_users'], false, '', '', true).'  '; $row['control'] = html_print_checkbox_switch_extended('autocreate_remote_users', 1, $config['autocreate_remote_users'], false, '', '', true).'  ';
$table->data['autocreate_remote_users'] = $row; $table->data['autocreate_remote_users'] = $row;
add_enterprise_auth_autocreate_profiles($table, $type_auth); add_enterprise_auth_autocreate_profiles($table, $type_auth);
@ -89,7 +89,7 @@ if (is_ajax()) {
// Start TLS // Start TLS
$row = []; $row = [];
$row['name'] = __('Start TLS'); $row['name'] = __('Start TLS');
$row['control'] = html_print_checkbox_toogle_switch('ldap_start_tls', 1, $config['ldap_start_tls'], true); $row['control'] = html_print_checkbox_switch('ldap_start_tls', 1, $config['ldap_start_tls'], true);
$table->data['ldap_start_tls'] = $row; $table->data['ldap_start_tls'] = $row;
// Base DN // Base DN
@ -135,7 +135,7 @@ if (is_ajax()) {
$row = []; $row = [];
$row['name'] = __('Double authentication').ui_print_help_tip(__('If this option is enabled, the users can use double authentication with their accounts'), true); $row['name'] = __('Double authentication').ui_print_help_tip(__('If this option is enabled, the users can use double authentication with their accounts'), true);
$row['control'] = html_print_input_hidden('double_auth_enabled', 0); $row['control'] = html_print_input_hidden('double_auth_enabled', 0);
$row['control'] .= html_print_checkbox_toogle_switch('double_auth_enabled', 1, $config['double_auth_enabled'], true); $row['control'] .= html_print_checkbox_switch('double_auth_enabled', 1, $config['double_auth_enabled'], true);
$table->data['double_auth_enabled'] = $row; $table->data['double_auth_enabled'] = $row;
// Session timeout // Session timeout

View File

@ -82,17 +82,17 @@ $sources['sql'] = __('Database');
$table->data[9][1] = html_print_select($sources, 'timesource', $config['timesource'], '', '', '', true); $table->data[9][1] = html_print_select($sources, 'timesource', $config['timesource'], '', '', '', true);
$table->data[10][0] = __('Automatic check for updates'); $table->data[10][0] = __('Automatic check for updates');
$table->data[10][1] = html_print_checkbox_toogle_switch('autoupdate', 1, $config['autoupdate'], true); $table->data[10][1] = html_print_checkbox_switch('autoupdate', 1, $config['autoupdate'], true);
echo "<div id='dialog' title='".__('Enforce https Information')."' style='display:none;'>"; echo "<div id='dialog' title='".__('Enforce https Information')."' style='display:none;'>";
echo "<p style='text-align: center;'>".__('If SSL is not properly configured you will lose access to ').get_product_name().__(' Console').'</p>'; echo "<p style='text-align: center;'>".__('If SSL is not properly configured you will lose access to ').get_product_name().__(' Console').'</p>';
echo '</div>'; echo '</div>';
$table->data[11][0] = __('Enforce https'); $table->data[11][0] = __('Enforce https');
$table->data[11][1] = html_print_checkbox_toogle_switch_extended('https', 1, $config['https'], false, '', '', true); $table->data[11][1] = html_print_checkbox_switch_extended('https', 1, $config['https'], false, '', '', true);
$table->data[12][0] = __('Use cert of SSL'); $table->data[12][0] = __('Use cert of SSL');
$table->data[12][1] = html_print_checkbox_toogle_switch_extended('use_cert', 1, $config['use_cert'], false, '', '', true); $table->data[12][1] = html_print_checkbox_switch_extended('use_cert', 1, $config['use_cert'], false, '', '', true);
$table->rowstyle[13] = 'display: none;'; $table->rowstyle[13] = 'display: none;';
$table->data[13][0] = __('Path of SSL Cert.').ui_print_help_tip(__('Path where you put your cert and name of this cert. Remember your cert only in .pem extension.'), true); $table->data[13][0] = __('Path of SSL Cert.').ui_print_help_tip(__('Path where you put your cert and name of this cert. Remember your cert only in .pem extension.'), true);
@ -114,7 +114,7 @@ $table->data[16][0] = __('API password').ui_print_help_tip(__('Please be careful
$table->data[16][1] = html_print_input_password('api_password', io_output_password($config['api_password']), '', 25, 255, true); $table->data[16][1] = html_print_input_password('api_password', io_output_password($config['api_password']), '', 25, 255, true);
$table->data[17][0] = __('Enable GIS features'); $table->data[17][0] = __('Enable GIS features');
$table->data[17][1] = html_print_checkbox_toogle_switch('activate_gis', 1, $config['activate_gis'], true); $table->data[17][1] = html_print_checkbox_switch('activate_gis', 1, $config['activate_gis'], true);
$table->data[19][0] = __('Enable Netflow'); $table->data[19][0] = __('Enable Netflow');
$rbt_disabled = false; $rbt_disabled = false;
@ -123,7 +123,7 @@ if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
$table->data[19][0] .= ui_print_help_tip(__('Not supported in Windows systems'), true); $table->data[19][0] .= ui_print_help_tip(__('Not supported in Windows systems'), true);
} }
$table->data[19][1] = html_print_checkbox_toogle_switch_extended('activate_netflow', 1, $config['activate_netflow'], $rbt_disabled, '', '', true); $table->data[19][1] = html_print_checkbox_switch_extended('activate_netflow', 1, $config['activate_netflow'], $rbt_disabled, '', '', true);
$zone_name = [ $zone_name = [
@ -202,15 +202,15 @@ $table->data[28][1] = html_print_input_text('public_url', $config['public_url'],
$table->data[29][0] = __('Referer security'); $table->data[29][0] = __('Referer security');
$table->data[29][0] .= ui_print_help_tip(__("If enabled, actively checks if the user comes from %s's URL", get_product_name()), true); $table->data[29][0] .= ui_print_help_tip(__("If enabled, actively checks if the user comes from %s's URL", get_product_name()), true);
$table->data[29][1] = html_print_checkbox_toogle_switch('referer_security', 1, $config['referer_security'], true); $table->data[29][1] = html_print_checkbox_switch('referer_security', 1, $config['referer_security'], true);
$table->data[30][0] = __('Event storm protection'); $table->data[30][0] = __('Event storm protection');
$table->data[30][0] .= ui_print_help_tip(__('If set to yes no events or alerts will be generated, but agents will continue receiving data.'), true); $table->data[30][0] .= ui_print_help_tip(__('If set to yes no events or alerts will be generated, but agents will continue receiving data.'), true);
$table->data[30][1] = html_print_checkbox_toogle_switch('event_storm_protection', 1, $config['event_storm_protection'], true); $table->data[30][1] = html_print_checkbox_switch('event_storm_protection', 1, $config['event_storm_protection'], true);
$table->data[31][0] = __('Command Snapshot').ui_print_help_tip(__('The string modules with several lines show as command output'), true); $table->data[31][0] = __('Command Snapshot').ui_print_help_tip(__('The string modules with several lines show as command output'), true);
$table->data[31][1] = html_print_checkbox_toogle_switch('command_snapshot', 1, $config['command_snapshot'], true); $table->data[31][1] = html_print_checkbox_switch('command_snapshot', 1, $config['command_snapshot'], true);
$table->data[32][0] = __('Server logs directory').ui_print_help_tip(__('Directory where the server logs are stored.'), true); $table->data[32][0] = __('Server logs directory').ui_print_help_tip(__('Directory where the server logs are stored.'), true);
$table->data[32][1] = html_print_input_text( $table->data[32][1] = html_print_input_text(
@ -250,7 +250,7 @@ $table->data['tutorial_mode'][1] = html_print_select(
$config['past_planned_downtimes'] = isset($config['past_planned_downtimes']) ? $config['past_planned_downtimes'] : 1; $config['past_planned_downtimes'] = isset($config['past_planned_downtimes']) ? $config['past_planned_downtimes'] : 1;
$table->data[34][0] = __('Allow create planned downtimes in the past').ui_print_help_tip(__('The planned downtimes created in the past will affect the SLA reports'), true); $table->data[34][0] = __('Allow create planned downtimes in the past').ui_print_help_tip(__('The planned downtimes created in the past will affect the SLA reports'), true);
$table->data[34][1] = html_print_checkbox_toogle_switch('past_planned_downtimes', 1, $config['past_planned_downtimes'], true); $table->data[34][1] = html_print_checkbox_switch('past_planned_downtimes', 1, $config['past_planned_downtimes'], true);
$table->data[35][0] = __('Limit for bulk operations').ui_print_help_tip(__('Your PHP environment is set to 1000 max_input_vars. This parameter should have the same value or lower.', ini_get('max_input_vars')), true); $table->data[35][0] = __('Limit for bulk operations').ui_print_help_tip(__('Your PHP environment is set to 1000 max_input_vars. This parameter should have the same value or lower.', ini_get('max_input_vars')), true);
$table->data[35][1] = html_print_input_text( $table->data[35][1] = html_print_input_text(
@ -263,7 +263,7 @@ $table->data[35][1] = html_print_input_text(
); );
$table->data[36][0] = __('Include agents manually disabled'); $table->data[36][0] = __('Include agents manually disabled');
$table->data[36][1] = html_print_checkbox_toogle_switch('include_agents', 1, $config['include_agents'], true); $table->data[36][1] = html_print_checkbox_switch('include_agents', 1, $config['include_agents'], true);
$table->data[37][0] = __('Audit log directory').ui_print_help_tip(__('Directory where audit log is stored.'), true); $table->data[37][0] = __('Audit log directory').ui_print_help_tip(__('Directory where audit log is stored.'), true);
$table->data[37][1] = html_print_input_text('auditdir', io_safe_output($config['auditdir']), '', 30, 100, true); $table->data[37][1] = html_print_input_text('auditdir', io_safe_output($config['auditdir']), '', 30, 100, true);

View File

@ -75,7 +75,7 @@ $table_behaviour->data[$row][1] = html_print_select($values, 'vc_refr', $config[
$row++; $row++;
$table_behaviour->data[$row][0] = __('Paginated module view'); $table_behaviour->data[$row][0] = __('Paginated module view');
$table_behaviour->data[$row][1] = html_print_checkbox_toogle_switch( $table_behaviour->data[$row][1] = html_print_checkbox_switch(
'paginate_module', 'paginate_module',
1, 1,
$config['paginate_module'], $config['paginate_module'],
@ -84,7 +84,7 @@ $table_behaviour->data[$row][1] = html_print_checkbox_toogle_switch(
$row++; $row++;
$table_behaviour->data[$row][0] = __('Display data of proc modules in other format'); $table_behaviour->data[$row][0] = __('Display data of proc modules in other format');
$table_behaviour->data[$row][1] = html_print_checkbox_toogle_switch( $table_behaviour->data[$row][1] = html_print_checkbox_switch(
'render_proc', 'render_proc',
1, 1,
$config['render_proc'], $config['render_proc'],
@ -102,7 +102,7 @@ $row++;
// Daniel maya 02/06/2016 Display menu with click --INI // Daniel maya 02/06/2016 Display menu with click --INI
$table_behaviour->data[$row][0] = __('Click to display lateral menus').ui_print_help_tip(__('When enabled, the lateral menus are shown when left clicking them, instead of hovering over them'), true); $table_behaviour->data[$row][0] = __('Click to display lateral menus').ui_print_help_tip(__('When enabled, the lateral menus are shown when left clicking them, instead of hovering over them'), true);
$table_behaviour->data[$row][1] = html_print_checkbox_toogle_switch( $table_behaviour->data[$row][1] = html_print_checkbox_switch(
'click_display', 'click_display',
1, 1,
$config['click_display'], $config['click_display'],
@ -121,7 +121,7 @@ if (enterprise_installed()) {
} }
$table_behaviour->data[$row][0] = __('Classic menu mode').ui_print_help_tip(__('Text menu options always visible, don\'t hide'), true); $table_behaviour->data[$row][0] = __('Classic menu mode').ui_print_help_tip(__('Text menu options always visible, don\'t hide'), true);
$table_behaviour->data[$row][1] = html_print_checkbox_toogle_switch( $table_behaviour->data[$row][1] = html_print_checkbox_switch(
'classic_menu', 'classic_menu',
1, 1,
$config['classic_menu'], $config['classic_menu'],
@ -491,7 +491,7 @@ if (enterprise_installed()) {
if (enterprise_installed()) { if (enterprise_installed()) {
$table_styles->data[$row][0] = __('Disable logo in graphs'); $table_styles->data[$row][0] = __('Disable logo in graphs');
$table_styles->data[$row][1] = html_print_checkbox_toogle_switch( $table_styles->data[$row][1] = html_print_checkbox_switch(
'fixed_graph', 'fixed_graph',
1, 1,
$config['fixed_graph'], $config['fixed_graph'],
@ -507,7 +507,7 @@ if (enterprise_installed()) {
*/ */
$table_styles->data[$row][0] = __('Disable helps'); $table_styles->data[$row][0] = __('Disable helps');
$table_styles->data[$row][1] = html_print_checkbox_toogle_switch( $table_styles->data[$row][1] = html_print_checkbox_switch(
'disable_help', 'disable_help',
1, 1,
$config['disable_help'], $config['disable_help'],
@ -516,7 +516,7 @@ $table_styles->data[$row][1] = html_print_checkbox_toogle_switch(
$row++; $row++;
$table_styles->data[$row][0] = __('Fixed header'); $table_styles->data[$row][0] = __('Fixed header');
$table_styles->data[$row][1] = html_print_checkbox_toogle_switch( $table_styles->data[$row][1] = html_print_checkbox_switch(
'fixed_header', 'fixed_header',
1, 1,
$config['fixed_header'], $config['fixed_header'],
@ -525,7 +525,7 @@ $table_styles->data[$row][1] = html_print_checkbox_toogle_switch(
$row++; $row++;
$table_styles->data[$row][0] = __('Fixed menu'); $table_styles->data[$row][0] = __('Fixed menu');
$table_styles->data[$row][1] = html_print_checkbox_toogle_switch( $table_styles->data[$row][1] = html_print_checkbox_switch(
'fixed_menu', 'fixed_menu',
1, 1,
$config['fixed_menu'], $config['fixed_menu'],
@ -535,7 +535,7 @@ $row++;
// For 5.1 Autohidden menu feature // For 5.1 Autohidden menu feature
$table_styles->data['autohidden'][0] = __('Autohidden menu'); $table_styles->data['autohidden'][0] = __('Autohidden menu');
$table_styles->data['autohidden'][1] = html_print_checkbox_toogle_switch( $table_styles->data['autohidden'][1] = html_print_checkbox_switch(
'autohidden_menu', 'autohidden_menu',
1, 1,
$config['autohidden_menu'], $config['autohidden_menu'],
@ -543,7 +543,7 @@ $table_styles->data['autohidden'][1] = html_print_checkbox_toogle_switch(
); );
$table_styles->data[$row][0] = __('Visual effects and animation'); $table_styles->data[$row][0] = __('Visual effects and animation');
$table_styles->data[$row][1] = html_print_checkbox_toogle_switch( $table_styles->data[$row][1] = html_print_checkbox_switch(
'visual_animation', 'visual_animation',
1, 1,
$config['visual_animation'], $config['visual_animation'],
@ -567,7 +567,7 @@ $table_gis->size[0] = '50%';
$table_gis->data = []; $table_gis->data = [];
$table_gis->data[$row][0] = __('GIS Labels').ui_print_help_tip(__('This enabling this, you get a label with agent name in GIS maps. If you have lots of agents in the map, will be unreadable. Disabled by default.'), true); $table_gis->data[$row][0] = __('GIS Labels').ui_print_help_tip(__('This enabling this, you get a label with agent name in GIS maps. If you have lots of agents in the map, will be unreadable. Disabled by default.'), true);
$table_gis->data[$row][1] = html_print_checkbox_toogle_switch( $table_gis->data[$row][1] = html_print_checkbox_switch(
'gis_label', 'gis_label',
1, 1,
$config['gis_label'], $config['gis_label'],
@ -680,7 +680,7 @@ $table_font->data[$row][1] = html_print_input_text(
$row++; $row++;
$table_font->data[$row][0] = __('Show unit along with value in reports').ui_print_help_tip(__('This enabling this, max, min and avg values will be shown with units.'), true); $table_font->data[$row][0] = __('Show unit along with value in reports').ui_print_help_tip(__('This enabling this, max, min and avg values will be shown with units.'), true);
$table_font->data[$row][1] = html_print_checkbox_toogle_switch( $table_font->data[$row][1] = html_print_checkbox_switch(
'simple_module_value', 'simple_module_value',
1, 1,
$config['simple_module_value'], $config['simple_module_value'],
@ -778,7 +778,7 @@ $table_chars->data[$row][1] = html_print_input_text(
$row++; $row++;
$table_chars->data[$row][0] = __('Use round corners'); $table_chars->data[$row][0] = __('Use round corners');
$table_chars->data[$row][1] = html_print_checkbox_toogle_switch( $table_chars->data[$row][1] = html_print_checkbox_switch(
'round_corner', 'round_corner',
1, 1,
$config['round_corner'], $config['round_corner'],
@ -947,7 +947,7 @@ $table_other->data[$row][0] = __('Show report info with description').ui_print_h
__('Custom report description info. It will be applied to all reports and templates by default.'), __('Custom report description info. It will be applied to all reports and templates by default.'),
true true
); );
$table_other->data[$row][1] = html_print_checkbox_toogle_switch( $table_other->data[$row][1] = html_print_checkbox_switch(
'custom_report_info', 'custom_report_info',
1, 1,
$config['custom_report_info'], $config['custom_report_info'],
@ -1061,7 +1061,7 @@ $table_other->data['custom_report_front-footer'][1] = html_print_textarea(
$table_other->data[$row][0] = __('Show QR Code icon in the header'); $table_other->data[$row][0] = __('Show QR Code icon in the header');
$table_other->data[$row][1] = html_print_checkbox_toogle_switch( $table_other->data[$row][1] = html_print_checkbox_switch(
'show_qr_code_header', 'show_qr_code_header',
1, 1,
$config['show_qr_code_header'], $config['show_qr_code_header'],
@ -1099,7 +1099,7 @@ $table_other->data[$row][0] .= ui_print_help_tip(
__('Show the group name instead the group icon.'), __('Show the group name instead the group icon.'),
true true
); );
$table_other->data[$row][1] = html_print_checkbox_toogle_switch( $table_other->data[$row][1] = html_print_checkbox_switch(
'show_group_name', 'show_group_name',
1, 1,
$config['show_group_name'], $config['show_group_name'],

View File

@ -20,19 +20,19 @@
if (!isset($config)) { if (!isset($config)) {
$working_dir = getcwd(); $working_dir = getcwd();
$working_dir = str_replace('\\', '/', $working_dir); $working_dir = str_replace('\\', '/', $working_dir);
// Windows compatibility // Windows compatibility.
$levels = substr_count($working_dir, '/'); $levels = substr_count($working_dir, '/');
for ($i = 0; $i < $levels; $i++) { for ($i = 0; $i < $levels; $i++) {
if (file_exists(str_repeat('../', $i).'config.php')) { if (file_exists(str_repeat('../', $i).'config.php')) {
include_once str_repeat('../', $i).'config.php'; include_once str_repeat('../', $i).'config.php';
break; break;
// Skip config.php loading after load the first one // Skip config.php loading after load the first one.
} else if (file_exists(str_repeat('../', $i).'include/config.php')) { } else if (file_exists(str_repeat('../', $i).'include/config.php')) {
// For path from the enterprise structure dirs. // For path from the enterprise structure dirs.
include_once str_repeat('../', $i).'include/config.php'; include_once str_repeat('../', $i).'include/config.php';
break; break;
// Skip config.php loading after load the first one // Skip config.php loading after load the first one.
} }
} }
} else { } else {
@ -2307,7 +2307,7 @@ function html_print_checkbox($name, $value, $checked=false, $return=false, $disa
/** /**
* Render a checkbox button input toogle switch type. Extended version, use html_print_checkbox_toogle_switch() to simplify. * Render a checkbox button input switch type. Extended version, use html_print_checkbox_switch() to simplify.
* *
* @param string Input name. * @param string Input name.
* @param string Input value. * @param string Input value.
@ -2321,7 +2321,7 @@ function html_print_checkbox($name, $value, $checked=false, $return=false, $disa
*/ */
function html_print_checkbox_toogle_switch_extended($name, $value, $checked, $disabled, $script, $attributes, $return=false, $id='') function html_print_checkbox_switch_extended($name, $value, $checked, $disabled, $script, $attributes, $return=false, $id='')
{ {
static $idcounter = []; static $idcounter = [];
@ -2334,7 +2334,7 @@ function html_print_checkbox_toogle_switch_extended($name, $value, $checked, $di
$id_aux = preg_replace('/[^a-z0-9\:\;\-\_]/i', '', $name.($idcounter[$name] ? $idcounter[$name] : '')); $id_aux = preg_replace('/[^a-z0-9\:\;\-\_]/i', '', $name.($idcounter[$name] ? $idcounter[$name] : ''));
$output = '<label class="toogle_switch"><input name="'.$name.'" type="checkbox" value="'.$value.'" '.($checked ? 'checked="checked"' : ''); $output = '<label class="p-switch"><input name="'.$name.'" type="checkbox" value="'.$value.'" '.($checked ? 'checked="checked"' : '');
if ($id == '') { if ($id == '') {
$output .= ' id="checkbox-'.$id_aux.'"'; $output .= ' id="checkbox-'.$id_aux.'"';
} else { } else {
@ -2350,7 +2350,7 @@ function html_print_checkbox_toogle_switch_extended($name, $value, $checked, $di
} }
$output .= ' '.$attributes; $output .= ' '.$attributes;
$output .= ' /><span class="slider"></span></label>'; $output .= ' /><span class="p-slider"></span></label>';
$output .= "\n"; $output .= "\n";
if ($return === false) { if ($return === false) {
@ -2362,7 +2362,7 @@ function html_print_checkbox_toogle_switch_extended($name, $value, $checked, $di
/** /**
* Render a checkbox button input toogle switch type. * Render a checkbox button input switch type.
* *
* @param string Input name. * @param string Input name.
* @param string Input value. * @param string Input value.
@ -2374,9 +2374,9 @@ function html_print_checkbox_toogle_switch_extended($name, $value, $checked, $di
*/ */
function html_print_checkbox_toogle_switch($name, $value, $checked=false, $return=false, $disabled=false, $script='', $disabled_hidden=false) function html_print_checkbox_switch($name, $value, $checked=false, $return=false, $disabled=false, $script='', $disabled_hidden=false)
{ {
$output = html_print_checkbox_toogle_switch_extended($name, $value, (bool) $checked, $disabled, $script, '', true); $output = html_print_checkbox_switch_extended($name, $value, (bool) $checked, $disabled, $script, '', true);
if (!$disabled_hidden) { if (!$disabled_hidden) {
$output .= html_print_input_hidden($name.'_sent', 1, true); $output .= html_print_input_hidden($name.'_sent', 1, true);
} }
@ -3073,3 +3073,44 @@ function html_print_csrf_error()
); );
return true; return true;
} }
/**
* Print an swith button
*
* @param array $atributes. 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).
* @return string with HTML of button
*/
function html_print_switch($attributes=[])
{
$html_expand = '';
// Check the load values on status.
$html_expand .= (bool) $attributes['value'] ? ' checked' : '';
$html_expand .= (bool) $attributes['disabled'] ? ' disabled' : '';
// Only load the valid attributes.
$valid_attrs = [
'id',
'class',
'name',
'onclick',
];
foreach ($valid_attrs as $va) {
if (!isset($attributes[$va])) {
continue;
}
$html_expand .= ' '.$va.'="'.$attributes[$va].'"';
}
return "<label class='p-switch'>
<input type='checkbox' $html_expand>
<span class='p-slider'></span>
</label>";
}

File diff suppressed because it is too large Load Diff