From 5b432002338cea8a29090eceec0a0b6e2977c6f1 Mon Sep 17 00:00:00 2001 From: Nate Jones Date: Mon, 4 Aug 2014 19:33:26 +0000 Subject: [PATCH] Dialplan Edit: Truncate initially displayed Data values with ellipsis (pre edit). --- app/dialplan/dialplan_edit.php | 2 +- resources/functions.php | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/dialplan/dialplan_edit.php b/app/dialplan/dialplan_edit.php index bbc7731336..017f262032 100644 --- a/app/dialplan/dialplan_edit.php +++ b/app/dialplan/dialplan_edit.php @@ -682,7 +682,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { unset ($prep_statement, $sql); } $dialplan_detail_data_mod = ($gateway_name != '') ? str_replace($gateway_uuid, $gateway_name, $dialplan_detail_data) : $dialplan_detail_data; - echo " \n"; + echo " \n"; } echo " \n"; echo "\n"; diff --git a/resources/functions.php b/resources/functions.php index 0ea7383b51..4acbd5d72c 100644 --- a/resources/functions.php +++ b/resources/functions.php @@ -999,4 +999,22 @@ if(!function_exists('validate_email')) { } } } + +// ellipsisnicely truncate long text +if(!function_exists('ellipsis')) { + function ellipsis($string, $max_characters, $preserve_word = true) { + if ($max_characters+$x >= strlen($string)) { return $string; } + if ($preserve_word) { + for ($x = 0; $x < strlen($string); $x++) { + if ($string{$max_characters+$x} == " ") { + return substr($string,0,$max_characters+$x)." ..."; + } + else { continue; } + } + } + else { + return substr($string,0,$max_characters)." ..."; + } + } +} ?>