From 02d2ca5157169e768def2c4c386c8e9990038281 Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Fri, 30 Jul 2010 10:19:06 +0000 Subject: [PATCH] improve the handling of overlong words, fix a bug regarding the check of infolog_status existing in known status for the type selected --- infolog/inc/class.infolog_ui.inc.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/infolog/inc/class.infolog_ui.inc.php b/infolog/inc/class.infolog_ui.inc.php index d9f081c740..6fcf638514 100644 --- a/infolog/inc/class.infolog_ui.inc.php +++ b/infolog/inc/class.infolog_ui.inc.php @@ -1013,7 +1013,7 @@ class infolog_ui if ($content['js']) $content['js'] = ''; } // on a type-change, set the status to the default status of that type, if the actual status is not supported by the new type - if (!in_array($content['info_status'],$this->bo->status[$content['info_type']])) + if (!array_key_exists($content['info_status'],$this->bo->status[$content['info_type']])) { $content['info_status'] = $this->bo->status['defaults'][$content['info_type']]; if ($content['info_status'] != 'done') $content['info_datecompleted'] = ''; @@ -1041,14 +1041,21 @@ class infolog_ui { continue; } - foreach(array(',' => ', ', '.' => '. ') as $pattern => $replace) // set blank behind all , and . + $cont = split(' ', $content[$key]); + $ckarray = array(); + foreach($cont as &$word) { - if(strpos($content[$key], $replace) === false) + // set blank behind all , and . if words are too long, apply wordwrap afterwards to make sure we get + if (strlen($word)>75) { - $content[$key] = str_replace($pattern, $replace, $content[$key]); + 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; } - $content[$key] = wordwrap($content[$key], 75, ' ', true); + $content[$key] = join(' ',$ckarray); + unset($ckarray); } if (is_numeric($_REQUEST['cat_id'])) {