BUG Fix file size format in document links

This commit is contained in:
Saophalkun Ponlu 2012-09-03 17:25:21 +12:00
parent 79c8efee74
commit 7ba2a4617a

View File

@ -661,15 +661,11 @@ class DMSDocument extends DataObject implements DMSDocumentInterface {
return filesize($this->getFullPath());
}
/**
* An alias to DMSDocument::getSize()
*/
function getFileSizeFormatted(){
if($size = $this->getSize()){
if($size < 1024) return $size . ' bytes';
if($size < 1024*10) return (round($size/1024*10)/10). ' KB';
if($size < 1024*1024) return round($size/1024) . ' KB';
if($size < 1024*1024*10) return (round(($size/1024)/1024*10)/10) . ' MB';
if($size < 1024*1024*1024) return round(($size/1024)/1024) . ' MB';
return round($size/(1024*1024*1024)*10)/10 . ' GB';
}
return $this->getSize();
}