summaryrefslogtreecommitdiff
path: root/roundcubemail/program/include
diff options
context:
space:
mode:
authoralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2010-01-13 13:10:31 +0000
committeralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2010-01-13 13:10:31 +0000
commitc88f9f14e150f59332d9ce19364a9a490c3009b6 (patch)
tree2f9c0a547ec3923facd9aca04d70ee73df748ee7 /roundcubemail/program/include
parentfaed0ae02f87c44c96e22e4eeaac53b217d9536a (diff)
- fix abbreviate_string() (#1486420)
git-svn-id: https://svn.roundcube.net/trunk@3206 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail/program/include')
-rw-r--r--roundcubemail/program/include/rcube_shared.inc7
1 files changed, 4 insertions, 3 deletions
diff --git a/roundcubemail/program/include/rcube_shared.inc b/roundcubemail/program/include/rcube_shared.inc
index bfd6740db..99d8b16df 100644
--- a/roundcubemail/program/include/rcube_shared.inc
+++ b/roundcubemail/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;