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

Quote:
Originally Posted by till View Post
There is no api function availbale for that. The places were we use such conversions (e.g. web statistics) it is hard coded. Its a good idea to add it as a filter in the next version.
For testing, I'm trying to add this :
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 'FORMATED_BYTES':
                                                        $unit = array('Bytes', 'KB', 'MB', 'GB', 'TB');
                                                        $returnval= @round($value/pow(1024, ($i = floor(log($returnval, 1024)))), 2).' '.$unit[$i];
                                                //   In the next try, will implement this on the functions class ..   
                                               // $returnval = $app->functions->convertSize($returnval);
                                                break;          
                                                default:
                                                        $this->errorMessage .= "Unknown Filter: ".$filter['type'];
                                                break;

                                        }
                                }
                        }
            return $returnval;
        }
on the tform.inc files ..
And on the tfrom file module :
Code:
'filters'   => array( 0 => array( 'event' => 'SHOW',
                                              'type' => 'FORMATED_BYTES')
											  ),
but no lucky, not working.. Is we forget something else ?

Last edited by remy74; 28th May 2013 at 11:03.
Reply With Quote
Sponsored Links