diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 768bba2c4a..829972d29f 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,11 @@ +2010-04-29 Miguel de Dios + + * include/functions_ui.php: added the function "printTruncateText" for + facilitate trunc texts, and add the eye candy the tooltip. + + * godmode/reporting/reporting_builder.list_items.php: used the new function + "printTruncateText". + 2010-04-29 Ramon Novoa * include/functions_reporting.php: Added TTO, TTR, MTBF and MTTR diff --git a/pandora_console/godmode/reporting/reporting_builder.list_items.php b/pandora_console/godmode/reporting/reporting_builder.list_items.php index 4f7b1113e4..5f9135161c 100644 --- a/pandora_console/godmode/reporting/reporting_builder.list_items.php +++ b/pandora_console/godmode/reporting/reporting_builder.list_items.php @@ -215,12 +215,7 @@ foreach ($items as $item) { $row[5] = '-'; } else { - if (strlen($item['description']) > 25) { - $row[5] = substr($item['description'], 0, 25) . '…' . ' ' . $item['description'] . ''; - } - else { - $row[5] = substr($item['description'], 0, 25); - } + $row[5] = printTruncateText($item['description'], 25, true, true); } // if ($item['id_gs'] == null) { diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 20a51d5685..4dee48f4af 100644 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -19,6 +19,36 @@ * @subpackage UI */ +/** + * Truncate a text to num chars (pass as parameter) and if flag show tooltip is + * true the html artifal to show the tooltip with rest of text. + * + * @param string $text The text to truncate. + * @param integer $numChars Number chars (-1 for char "...") max the text. + * @param boolean $showTextInAToopTip Flag to show the tooltip. + * @param boolean $return Flag to return as string or not. + */ +function printTruncateText($text, $numChars = 25, $showTextInAToopTip = true, $return = true) { + if (strlen($text) > ($numChars - 1)) { + if ($showTextInAToopTip) { + $truncateText = substr($text, 0, ($numChars - 1)) . '…' . ' ' . $text . ''; + } + else { + $truncateText = substr($text, 0, ($numChars - 1)) . '…'; + } + } + else { + $truncateText = $text; + } + + if ($return == true) { + return $truncateText; + } + else { + echo $truncateText; + } +} + /** * Prints a generic message between tags. *