diff --git a/webui/system/misc.php b/webui/system/misc.php index ae356ed2..ca9598e5 100644 --- a/webui/system/misc.php +++ b/webui/system/misc.php @@ -1,5 +1,10 @@ $length ? substr($what, 0, $length) . "..." : $what; + if($length < 1) { return ''; } + + if(strlen($what) <= $length) { return $what; } + + $arr = preg_split("/\s/", $what); + $s = ''; + + $i = 0; + foreach($arr as $a) { + if($i == 0) { + if($length > 0 && strlen($a) > $length) { + return substr($a, 0, $length) . '...'; + } + } + + if(strlen($s) + strlen($a) <= $length) { + $s .= $a . ' '; + } else { + break; + } + + $i++; + } + + return $s . '...'; } diff --git a/webui/view/theme/default/templates/search/helper.tpl b/webui/view/theme/default/templates/search/helper.tpl index f02d19ed..dfeaec96 100644 --- a/webui/view/theme/default/templates/search/helper.tpl +++ b/webui/view/theme/default/templates/search/helper.tpl @@ -43,7 +43,7 @@
- + - +