summaryrefslogtreecommitdiffstats
path: root/lib/helper.php
diff options
context:
space:
mode:
authorJakob Sack <kde@jakobsack.de>2011-03-02 22:28:32 +0100
committerJakob Sack <kde@jakobsack.de>2011-03-02 22:28:32 +0100
commite5ea0a3daa307d6df6c864d13adcf733a286213e (patch)
treef82eb1081ed4589dafacfb8f564ed7e61609d380 /lib/helper.php
parentdfa6b749baf95856601ea476e58f884cfb453055 (diff)
downloadnextcloud-server-e5ea0a3daa307d6df6c864d13adcf733a286213e.tar.gz
nextcloud-server-e5ea0a3daa307d6df6c864d13adcf733a286213e.zip
Added helper for filesize, fixed wrong name for mimetypeIcon()
Diffstat (limited to 'lib/helper.php')
-rw-r--r--lib/helper.php24
1 files changed, 23 insertions, 1 deletions
diff --git a/lib/helper.php b/lib/helper.php
index 085ab67e737..5999c33a458 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -60,7 +60,7 @@ class OC_HELPER {
* show an icon for a filetype
*
*/
- public static function showIcon( $mimetype ){
+ public static function mimetypeIcon( $mimetype ){
global $SERVERROOT;
global $WEBROOT;
// Replace slash with a minus
@@ -79,6 +79,28 @@ class OC_HELPER {
return "$WEBROOT/img/mimetypes/application-octet-stream.png";
}
}
+
+ /**
+ * Human filesize (1 kB for 1024 etc. )
+ *
+ */
+ public static function humanFileSize( $bytes ){
+ if( $bytes < 1024 ){
+ return "$bytes B";
+ }
+ $bytes = round( $bytes / 1024, 1 );
+ if( $bytes < 1024 ){
+ return "$bytes kB";
+ }
+ $bytes = round( $bytes / 1024, 1 );
+ if( $bytes < 1024 ){
+ return "$bytes MB";
+ }
+
+ // Wow, heavy duty for owncloud
+ $bytes = round( $bytes / 1024, 1 );
+ return "$bytes GB";
+ }
}
?>