diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 0fc8e05f0e..fb6593a0d7 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,13 @@ +2012-06-13 Miguel de Dios + + * include/functions_config.php, include/functions_ui.php, + include/functions.php, include/constants.php, + mobile/operation/agents/monitor_status.php, + godmode/setup/setup_visuals.php: started to working into the set + a standar truncate string in all code of Pandora Console. + + MERGED FROM 4.0.2 + 2012-06-13 Miguel de Dios * include/functions_config.php, diff --git a/pandora_console/godmode/setup/setup_visuals.php b/pandora_console/godmode/setup/setup_visuals.php index 51c54452fe..bad43aff0b 100644 --- a/pandora_console/godmode/setup/setup_visuals.php +++ b/pandora_console/godmode/setup/setup_visuals.php @@ -115,6 +115,21 @@ $table->data[15][1] = html_print_select ($values, 'refr', $config["refr"], '', ' $table->data[16][0] = __('Default interval for refresh on Visual Console') . ui_print_help_tip(__('This interval will affect to Visual Console pages'), true); $table->data[16][1] = html_print_select ($values, 'vc_refr', $config["vc_refr"], '', 'N/A', 0, true, false, false); +$table->data[17][0] = __('Agent size text') . ui_print_help_tip(__('When the agent name have a lot of characters, in some places in Pandora Console it is necesary truncate to N characters.'), true); +$table->data[17][1] = __('Small:') . html_print_input_text ('agent_size_text_small', $config["agent_size_text_small"], '', 3, 3, true); +$table->data[17][1] .= ' ' . __('Normal:') . html_print_input_text ('agent_size_text_medium', $config["agent_size_text_medium"], '', 3, 3, true); + +$table->data[18][0] = __('Module size text') . ui_print_help_tip(__('When the module name have a lot of characters, in some places in Pandora Console it is necesary truncate to N characters.'), true); +$table->data[18][1] = __('Small:') . html_print_input_text ('module_size_text_small', $config["module_size_text_small"], '', 3, 3, true); +$table->data[18][1] .= ' ' . __('Normal:') . html_print_input_text ('module_size_text_medium', $config["module_size_text_medium"], '', 3, 3, true); + +$table->data[19][0] = __('Description size text') . ui_print_help_tip(__('When the description name have a lot of characters, in some places in Pandora Console it is necesary truncate to N characters.'), true); +$table->data[19][1] = html_print_input_text ('description_size_text', $config["description_size_text"], '', 3, 3, true); + +$table->data[20][0] = __('Item title size text') . ui_print_help_tip(__('When the item title name have a lot of characters, in some places in Pandora Console it is necesary truncate to N characters.'), true); +$table->data[20][1] = html_print_input_text ('item_title_size_text', $config["item_title_size_text"], '', 3, 3, true); + + echo '
'; html_print_input_hidden ('update_config', 1); html_print_table ($table); diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index 9a3fcd4c04..1dba8f5b53 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -91,4 +91,8 @@ define('COL_NORMAL','#8ae234'); define('COL_NOTINIT','#ef2929'); define('COL_UNKNOWN','#aaaaaa'); define('COL_ALERTFIRED','#ff8800'); + +/* The styles */ +/* Size of text in characters for truncate */ +define('GENERIC_SIZE_TEXT', 25); ?> diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index f70abce946..2f4ee4c321 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -823,10 +823,8 @@ function get_event_types () { $types['error'] = __('Error'); $types['configuration_change'] = __('Configuration change '); - if (isset($config['text_char_long'])) { - foreach ($types as $key => $type) { - $types[$key] = ui_print_truncate_text($type, $config['text_char_long'], false, true, false); - } + foreach ($types as $key => $type) { + $types[$key] = ui_print_truncate_text($type, GENERIC_SIZE_TEXT, false, true, false); } return $types; @@ -849,10 +847,8 @@ function get_priorities () { $priorities[6] = __('Major'); $priorities[4] = __('Critical'); - if (isset($config['text_char_long'])) { - foreach ($priorities as $key => $priority) { - $priorities[$key] = ui_print_truncate_text($priority, $config['text_char_long'], false, true, false); - } + foreach ($priorities as $key => $priority) { + $priorities[$key] = ui_print_truncate_text($priority, GENERIC_SIZE_TEXT, false, true, false); } return $priorities; diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index f83b847413..1f5055fa90 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -204,7 +204,13 @@ function config_update_config () { config_update_value ('font_size', get_parameter('font_size', $config['font_size'])); config_update_value ('refr', get_parameter('refr', $config['refr'])); config_update_value ('vc_refr', get_parameter('vc_refr', $config['vc_refr'])); - + + config_update_value ('agent_size_text_small', get_parameter('agent_size_text_small', $config['agent_size_text_small'])); + config_update_value ('agent_size_text_medium', get_parameter('agent_size_text_medium', $config['agent_size_text_medium'])); + config_update_value ('module_size_text_small', get_parameter('module_size_text_small', $config['module_size_text_small'])); + config_update_value ('module_size_text_medium', get_parameter('module_size_text_medium', $config['module_size_text_medium'])); + config_update_value ('description_size_text', get_parameter('description_size_text', $config['description_size_text'])); + config_update_value ('item_title_size_text', get_parameter('item_title_size_text', $config['item_title_size_text'])); enterprise_include_once('include/functions_policies.php'); $enterprise = enterprise_include_once ('include/functions_skins.php'); @@ -640,6 +646,30 @@ function config_process_config () { config_update_value ('refr', ''); } + if (!isset($config['agent_size_text_small'])) { + config_update_value ('agent_size_text_small', 15); + } + + if (!isset($config['agent_size_text_medium'])) { + config_update_value ('agent_size_text_medium', 50); + } + + if (!isset($config['module_size_text_small'])) { + config_update_value ('module_size_text_small', 15); + } + + if (!isset($config['module_size_text_medium'])) { + config_update_value ('module_size_text_medium', 50); + } + + if (!isset($config['description_size_text'])) { + config_update_value ('description_size_text', 50); + } + + if (!isset($config['item_title_size_text'])) { + config_update_value ('item_title_size_text', 40); + } + /* Finally, check if any value was overwritten in a form */ config_update_config(); } diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 671cdfba91..3dec433d08 100644 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -32,7 +32,7 @@ require_once($config['homedir'] . '/include/functions_html.php'); * true the html artifal to show the tooltip with rest of text. * * @param string $text The text to truncate. - * @param integer $numChars Number chars (-3 for char "[...]") max the text. + * @param mixed $numChars Number chars (-3 for char "[...]") max the text. Or the strings "agent_small", "agent_medium", "module_small", "module_medium", "description" or "generic" for to take the values from user config. * @param boolean $showTextInAToopTip Flag to show the tooltip. * @param boolean $return Flag to return as string or not. * @param boolean $showTextInTitle Flag to show the text on title. @@ -41,7 +41,35 @@ require_once($config['homedir'] . '/include/functions_html.php'); * * @return string Truncated text. */ -function ui_print_truncate_text($text, $numChars = 25, $showTextInAToopTip = true, $return = true, $showTextInTitle = true, $suffix = '[…]', $style = false) { +function ui_print_truncate_text($text, $numChars = GENERIC_SIZE_TEXT, $showTextInAToopTip = true, $return = true, $showTextInTitle = true, $suffix = '[…]', $style = false) { + global $config; + + if (is_string($numChars)) { + switch ($numChars) { + case 'agent_small': + $numChars = $config['agent_size_text_small']; + break; + case 'agent_medium': + $numChars = $config['agent_size_text_medium']; + break; + case 'module_small': + $numChars = $config['module_size_text_small']; + break; + case 'module_medium': + $numChars = $config['module_size_text_medium']; + break; + case 'description': + $numChars = $config['description_size_text']; + break; + case 'item_title': + $numChars = $config['item_title_size_text']; + break; + default: + $numChars = (int)$numChars; + break; + } + } + if ($numChars == 0) { if ($return == true) { return $text; @@ -62,7 +90,7 @@ function ui_print_truncate_text($text, $numChars = 25, $showTextInAToopTip = tru $truncateText = $truncateText . $truncateText2; if ($showTextInTitle) { - if ($style !== false){ + if ($style !== false) { $truncateText = ''.$truncateText.''; } else { @@ -70,9 +98,9 @@ function ui_print_truncate_text($text, $numChars = 25, $showTextInAToopTip = tru } } if ($showTextInAToopTip) { - if ($style !== false){ + if ($style !== false) { $truncateText = $truncateText . ' ' . $text . ''; - } + } else { $truncateText = $truncateText . ' ' . $text . ''; } @@ -551,7 +579,7 @@ function ui_print_os_icon ($id_os, $name = true, $return = false, $apply_skin = * * @return string HTML with agent name and link */ -function ui_print_agent_name ($id_agent, $return = false, $cutoff = 0, $style = '', $cutname = false) { +function ui_print_agent_name ($id_agent, $return = false, $cutoff = 'agent_medium', $style = '', $cutname = false) { $agent_name = (string) agents_get_name ($id_agent); $agent_name_full = $agent_name; if ($cutname) { diff --git a/pandora_console/mobile/operation/agents/monitor_status.php b/pandora_console/mobile/operation/agents/monitor_status.php index 109d9d92f5..09ecacec12 100644 --- a/pandora_console/mobile/operation/agents/monitor_status.php +++ b/pandora_console/mobile/operation/agents/monitor_status.php @@ -55,7 +55,7 @@ class MonitorStatus { $fields[4] = __('Not normal'); //default $fields[5] = __('Not init'); foreach ($fields as $key => $field) { - $fields[$key] = ui_print_truncate_text($field, $config['text_char_long'], false, true, false); + $fields[$key] = ui_print_truncate_text($field, GENERIC_SIZE_TEXT, false, true, false); } $table->data[0][3] = html_print_select ($fields, "status", $status, '', '', -1, true); $table->data[1][0] = '' . __('M') . ''; @@ -216,13 +216,15 @@ class MonitorStatus { $data[] = str_replace('' . ui_print_truncate_text($row['agent_name'], 25, true, true) . ''; + $data[] = '' . + ui_print_truncate_text($row['agent_name'], 25, true, true) . ''; $data[] = '' . ui_print_truncate_text($row['module_name'], 25, true, true) . ''; if (is_numeric($row["datos"])) $data[] = format_numeric($row["datos"]); else - $data[] = "".substr(io_safe_output($row["datos"]),0,12).""; + $data[] = "" . + substr(io_safe_output($row["datos"]),0,12).""; $data[] = ui_print_timestamp ($row["utimestamp"], true, array('units' => 'tiny'));