summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2010-01-13 13:10:31 +0000
committeralecpl <alec@alec.pl>2010-01-13 13:10:31 +0000
commitcea5bc82ee658ecf7dbc5c806fc7445ad8c2a81d (patch)
tree8a6ac3de52ee35abeec684724a7e0eb30e093b45 /program
parentecbd5b5d53a9d9d8d24c84dcf2ebf7682f77107d (diff)
- fix abbreviate_string() (#1486420)
Diffstat (limited to 'program')
-rw-r--r--program/include/rcube_shared.inc7
1 files changed, 4 insertions, 3 deletions
diff --git a/program/include/rcube_shared.inc b/program/include/rcube_shared.inc
index bfd6740db..99d8b16df 100644
--- a/program/include/rcube_shared.inc
+++ b/program/include/rcube_shared.inc
@@ -408,12 +408,13 @@ function get_offset_time($offset_str, $factor=1)
function abbreviate_string($str, $maxlength, $place_holder='...')
{
$length = mb_strlen($str);
- $first_part_length = floor($maxlength/2) - mb_strlen($place_holder);
if ($length > $maxlength)
{
- $second_starting_location = $length - $maxlength + $first_part_length + 1;
- $str = mb_substr($str, 0, $first_part_length) . $place_holder . mb_substr($str, $second_starting_location, $length);
+ $place_holder_length = mb_strlen($place_holder);
+ $first_part_length = floor(($maxlength - $place_holder_length)/2);
+ $second_starting_location = $length - $maxlength + $first_part_length + $place_holder_length;
+ $str = mb_substr($str, 0, $first_part_length) . $place_holder . mb_substr($str, $second_starting_location);
}
return $str;