diff --git a/app/Services/Utils.php b/app/Services/Utils.php index d805f0fa..da42c795 100644 --- a/app/Services/Utils.php +++ b/app/Services/Utils.php @@ -66,4 +66,34 @@ class Utils return $fname; } + public static function getStringOmitted($str, $length, $append = true) + { + $str = trim($str); + $strlength = strlen($str); + + if ($length == 0 || $length >= $strlength) { + return $str; + } elseif ($length < 0) { + $length = $strlength + $length; + + if ($length < 0) { + $length = $strlength; + } + } + + if (function_exists('mb_substr')) { + $newstr = mb_substr($str, 0, $length, 'utf-8'); + } elseif (function_exists('iconv_substr')) { + $newstr = iconv_substr($str, 0, $length, 'utf-8'); + } else { + $newstr = substr($str, 0, $length); + } + + if ($append && $str != $newstr) { + $newstr .= '...'; + } + + return $newstr; + } + } diff --git a/resources/views/skinlib/index.tpl b/resources/views/skinlib/index.tpl index f48da90c..5d11784d 100644 --- a/resources/views/skinlib/index.tpl +++ b/resources/views/skinlib/index.tpl @@ -48,7 +48,7 @@