From c9dcf849b9d196f27131c21b79ebf1793f3c1cda Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 16 Aug 2007 11:28:58 +0000 Subject: - two new packages... diff and utf - only 60 chars for topic title if new post (please see changelog for explanation) - change utf8_wordwrap (had some bugs david and nils spotted - was not really functional, sorry for this. :D) git-svn-id: file:///svn/phpbb/trunk@8034 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/utf/utf_tools.php | 53 +++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 22 deletions(-) (limited to 'phpBB/includes/utf/utf_tools.php') diff --git a/phpBB/includes/utf/utf_tools.php b/phpBB/includes/utf/utf_tools.php index 9ee39570a9..f8156fb8d2 100644 --- a/phpBB/includes/utf/utf_tools.php +++ b/phpBB/includes/utf/utf_tools.php @@ -1,7 +1,7 @@ ''); $index = 0; - foreach ($words as $word) + foreach ($lines as $line) { - if (!isset($lines[$index])) - { - $lines[$index] = ''; - } + $words = explode(' ', $line); - if (!empty($lines[$index]) && utf8_strlen($lines[$index]) > $width) + for ($i = 0, $size = sizeof($words); $i < $size; $i++) { - $lines[$index] = substr($lines[$index], 0, -1); - $index++; - $lines[$index] = ''; + $word = $words[$i]; + + // If cut is true we need to cut the word if it is > width chars + if ($cut && utf8_strlen($word) > $width) + { + $words[$i] = utf8_substr($word, $width); + $word = utf8_substr($word, 0, $width); + $i--; + } + + if (utf8_strlen($new_lines[$index] . $word) > $width) + { + $new_lines[$index] = substr($new_lines[$index], 0, -1); + $index++; + $new_lines[$index] = ''; + } + + $new_lines[$index] .= $word . ' '; } - $lines[$index] .= $word . ' '; + $new_lines[$index] = substr($new_lines[$index], 0, -1); + $index++; + $new_lines[$index] = ''; } - return implode($break, $lines); + unset($new_lines[$index]); + return implode($break, $new_lines); } ?> \ No newline at end of file -- cgit v1.2.1