<?php
namespace Engine\Smarty\Modifiers; class NumberFormat { static public function create($number, $decimals=null, $dec_point=null, $thousands_sep=null) { $CFG = \Engine\Loader_Cfg::getInstance()->getGlobal(); if ($decimals===null && $dec_point===null && $thousands_sep===null) { if ($CFG['localization']['numberFormat']=='eu') { return number_format((float)$number, 2, ',', '.'); } elseif ($CFG['localization']['numberFormat']=='us') { return number_format((float)$number, 2, '.', ','); } else { return number_format((float)$number, 2, '.', ''); } } if ($CFG['localization']['numberFormat']=='eu') { $decimals = ($decimals===null? 2:$decimals); $dec_point = ($dec_point===null? ',':$dec_point); $thousands_sep = ($thousands_sep===null?'.':$thousands_sep); } elseif ($CFG['localization']['numberFormat']=='us') { $decimals = ($decimals===null? 2:$decimals); $dec_point = ($dec_point===null? '.':$dec_point); $thousands_sep = ($thousands_sep===null?',':$thousands_sep); } else { $decimals = ($decimals===null? 2:$decimals); $dec_point = ($dec_point===null? '.':$dec_point); $thousands_sep = ($thousands_sep===null? '':$thousands_sep); } return number_format((float)$number, $decimals, $dec_point, $thousands_sep); } } 