summaryrefslogtreecommitdiffstats
path: root/lib/helper.php
diff options
context:
space:
mode:
authorFrank Karlitschek <frank@owncloud.org>2012-11-19 00:53:46 -0800
committerFrank Karlitschek <frank@owncloud.org>2012-11-19 00:53:46 -0800
commit5b2aeebaf0506c66df358e705bcb06d80a093dd2 (patch)
tree7f5dd49984bc441fd6b0188c72e14bf67eb44f42 /lib/helper.php
parentc5e891008b2b4402531bdbf07adb0bfefbbc242e (diff)
parent0ce5e9257e71dd8bf21379c3cbe774be8e4efd7b (diff)
downloadnextcloud-server-5b2aeebaf0506c66df358e705bcb06d80a093dd2.tar.gz
nextcloud-server-5b2aeebaf0506c66df358e705bcb06d80a093dd2.zip
Merge pull request #280 from butonic/feature_bmp_support
add bmp support
Diffstat (limited to 'lib/helper.php')
-rw-r--r--lib/helper.php16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/helper.php b/lib/helper.php
index 339a12dc1ed..27ebd24f6e5 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -743,4 +743,20 @@ class OC_Helper {
return false;
}
+
+ /**
+ * Shortens str to maxlen by replacing characters in the middle with '...', eg.
+ * ellipsis('a very long string with lots of useless info to make a better example', 14) becomes 'a very ...example'
+ * @param string $str the string
+ * @param string $maxlen the maximum length of the result
+ * @return string with at most maxlen characters
+ */
+ public static function ellipsis($str, $maxlen) {
+ if (strlen($str) > $maxlen) {
+ $characters = floor($maxlen / 2);
+ return substr($str, 0, $characters) . '...' . substr($str, -1 * $characters);
+ }
+ return $str;
+ }
+
}