Index: trunk/core/kernel/utility/formatters.php =================================================================== diff -u -r2331 -r2334 --- trunk/core/kernel/utility/formatters.php (.../formatters.php) (revision 2331) +++ trunk/core/kernel/utility/formatters.php (.../formatters.php) (revision 2334) @@ -1003,48 +1003,31 @@ } } } - - /*function Format($value, $field_name, &$object, $format=null) +} + +class kFilesizeFormatter extends kFormatter { + + function Format($value, $field_name, &$object, $format=null) { - return parent::Format($value, $field_name, $object, $format); - }*/ - -/* function Format($value, $field_name, &$object, $format=null) - { - if( isset($field_options['master_field']) ) - { - $regional =& $this->Application->recallObject('lang.current'); - switch( $regional->GetDBField('UnitSystem') ) - { - case 2: // US/UK - $major = floor( $value / 0.5 ); - $minor = $value - $major; - $major = $object->SetDBField($field_name.'_a', $major); - $minor = $object->SetDBField($field_name.'_b', $minor); - break; - default: - } + if ($value >= 1099511627776) { + $return = round($value / 1024 / 1024 / 1024 / 1024, 2); + $suffix = "Tb"; + } elseif ($value >= 1073741824) { + $return = round($value / 1024 / 1024 / 1024, 2); + $suffix = "Gb"; + } elseif ($value >= 1048576) { + $return = round($value / 1024 / 1024, 2); + $suffix = "Mb"; + } elseif ($value >= 1024) { + $return = round($value / 1024, 2); + $suffix = "Kb"; + } else { + $return = $value; + $suffix = "B"; } - return parent::Format($value, $field_name, $object); - }*/ - - /*function Parse($value, $field_name, &$object) - { - $regional =& $this->Application->recallObject('lang.current'); - switch($regional->GetDBField('UnitSystem')) - { - case 1: // metric - return $object->GetDBField('UnitSystem_a'); - break; - case 2: // US/UK - return $object->GetDBField('UnitSystem_a') * 0.5 + - $object->GetDBField('UnitSystem_b') * 0.5 / 16; - break; - default: - } - }*/ - + $return .= ' '.$suffix; + return $return; + } } - ?>