public static function FormatFileSize($size) { static $units = array(' B', ' KB', ' MB', ' GB', ' TB'); $size = (int) $size; for ($i = 0; $size >= 1024 && $i < 4; $i++) { $size /= 1024; } return round($size, 2) . $units[$i]; }
/** * Process db row * @param array $row * @return array */ public function processRow(array $row) { global $ADMIN; // edit link $row['file_name'] = sprintf('<a href="/%s/media-archive/edit-attachment.php?f_attachment_id=%d">%s</a>', $ADMIN, $row['id'], $row['file_name']); // human readable size $row['size_in_bytes'] = parent::FormatFileSize($row['size_in_bytes']); // yes/no disposition $row['content_disposition'] = empty($row['content_disposition']) ? getGS('Yes') : getGS('No'); // get in use info $object = new Attachment($row['id']); $row['InUse'] = (int) $object->inUse(); return array_values($row); }