From a406e83b2dd22b5923db2501605ea75f2049a41a Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Wed, 7 Nov 2012 07:54:50 +0000 Subject: [PATCH] attempt to improve overlong-word-control behavior --- infolog/inc/class.infolog_ui.inc.php | 43 ++++++++++++++++++---------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/infolog/inc/class.infolog_ui.inc.php b/infolog/inc/class.infolog_ui.inc.php index 27e6bd8dd9..a8e4e1120e 100644 --- a/infolog/inc/class.infolog_ui.inc.php +++ b/infolog/inc/class.infolog_ui.inc.php @@ -1679,25 +1679,38 @@ class infolog_ui { continue; } - $cont = explode(' ', $content[$key]); - $ckarray = array(); - foreach($cont as &$word) + $contlines = explode("\n", $content[$key]); + $clarray = array(); + foreach ($contlines as &$line) { - // set blank behind all , and . if words are too long, apply wordwrap afterwards to make sure we get - if (strlen($word)>75) + if(strlen($line) < 75) { - $buff = html::activate_links($word); - if (strlen($buff) == strlen($word)) // no links -> try to break overlong words - { - if (!(strpos($word,',')===false) && strpos($word,', ')===false) $word = str_replace(',',', ',$word); - if (!(strpos($word,'.')===false) && strpos($word,'. ')===false) $word = str_replace('.','. ',$word); - $word = wordwrap($word, 75, ' ', true); - } + $clarray[] = $line; + continue; } - $ckarray[] =$word; + $cont = explode(' ', $line); + $ckarray = array(); + foreach($cont as &$word) + { + // set blank behind all , and . if words are too long, apply wordwrap afterwards to make sure we get + if (strlen($word)>75) + { + $buff = html::activate_links($word); + if (strlen($buff) == strlen($word)) // no links -> try to break overlong words + { + if (!(strpos($word,',')===false) && strpos($word,', ')===false) $word = str_replace(',',', ',$word); + if (!(strpos($word,'.')===false) && strpos($word,'. ')===false) $word = str_replace('.','. ',$word); + $word = wordwrap($word, 75, ' ', true); + } + } + $ckarray[] =$word; + } + $line = join(' ',$ckarray); + unset($ckarray); + $clarray[] = $line; } - $content[$key] = join(' ',$ckarray); - unset($ckarray); + $content[$key] = join("\n",$clarray); + unset($clarray); } if (is_numeric($_REQUEST['cat_id'])) {