View Single Post
  #12  
Old 28th May 2013, 11:07
remy74 remy74 is offline
Junior Member
 
Join Date: May 2013
Posts: 16
Thanks: 9
Thanked 6 Times in 4 Posts
Smile

Ok it's working, implement this on functions.inc.php (before the last '}' of the file) :

Code:
	public function formatBytes($size, $precision = 2) {
        $base=log($size)/log(1024);
        $suffixes=array('','k','M','G','T');
        return round(pow(1024,$base-floor($base)),$precision).$suffixes[floor($base)];	
        
		}
And on tform.inc.php :
Code:
       function filterField($field_name, $field_value, $filters, $filter_event) {

			global $app;
			$returnval = $field_value;
				
			//* Loop trough all filters
			foreach($filters as $filter) {
				if($filter['event'] == $filter_event) {
					switch ($filter['type']) {
						case 'TOLOWER':
							$returnval = strtolower($returnval);
						break;
						case 'TOUPPER':
							$returnval = strtoupper($returnval);
						break;
						case 'IDNTOASCII':
							$returnval = $app->functions->idn_encode($returnval);
						break;
						case 'IDNTOUTF8':
							$returnval = $app->functions->idn_decode($returnval);
						break;
						case 'BYTES':
                                                // format the value for bytes, return a TEXT / VARCHAR, not integer !
							$returnval = $app->functions->formatBytes($returnval);
						break;	
						default:
							$this->errorMessage .= "Unknown Filter: ".$filter['type'];
						break;
						
					}
				}
			}
            return $returnval;
        }
Maybe this will help someone else.
Reply With Quote