Index: branches/unlabeled/unlabeled-1.62.2/admin/install/inportal_schema.sql =================================================================== diff -u -r6139 -r6508 --- branches/unlabeled/unlabeled-1.62.2/admin/install/inportal_schema.sql (.../inportal_schema.sql) (revision 6139) +++ branches/unlabeled/unlabeled-1.62.2/admin/install/inportal_schema.sql (.../inportal_schema.sql) (revision 6508) @@ -291,7 +291,7 @@ InputDateFormat varchar(50) NOT NULL default '', InputTimeFormat varchar(50) NOT NULL default '', DecimalPoint char(2) NOT NULL default '.', - ThousandSep char(1) NOT NULL default ',', + ThousandSep tinytext NULL, Charset varchar(20) NOT NULL default '', UnitSystem tinyint(4) NOT NULL default '1', PRIMARY KEY (LanguageId) Index: branches/unlabeled/unlabeled-1.1.2/core/kernel/utility/formatters/formatter.php =================================================================== diff -u -r4950 -r6508 --- branches/unlabeled/unlabeled-1.1.2/core/kernel/utility/formatters/formatter.php (.../formatter.php) (revision 4950) +++ branches/unlabeled/unlabeled-1.1.2/core/kernel/utility/formatters/formatter.php (.../formatter.php) (revision 6508) @@ -20,6 +20,17 @@ $type_ok = preg_match('#int|integer|double|float|real|numeric|string#', $field_type); if($field_type == 'string') return $value; + static $comma = null; + static $thousands = null; + if (is_null($comma) || is_null($thousands)) { + $lang =& $this->Application->recallObject('lang.current'); + $comma = $lang->GetDBField('DecimalPoint'); + $thousands = $lang->GetDBField('ThousandSep'); + } + + $value = str_replace($thousands, '', $value); + $value = str_replace($comma, '.', $value); + if ($value != '' && $type_ok) { $ret = is_numeric($value); @@ -43,10 +54,26 @@ $options = $object->GetFieldOptions($field_name); if ( isset($format) ) $options['format'] = $format; $tc_value = $this->TypeCast($value,$options); - if( ($tc_value === false) || ($tc_value != $value) ) return $value; // for leaving badly formatted date on the form + if( ($tc_value === false) || ("$tc_value" != "$value") ) return $value; // for leaving badly formatted date on the form - if (isset($options['format'])) return sprintf($options['format'], $tc_value); + if (isset($options['format'])) { + $tc_value = sprintf($options['format'], $tc_value); + } + if (preg_match('#int|integer|double|float|real|numeric#', $options['type'])) { + static $comma = null; + static $thousands = null; + if (is_null($comma) || is_null($thousands)) { + $lang =& $this->Application->recallObject('lang.current'); + $comma = $lang->GetDBField('DecimalPoint'); + $thousands = $lang->GetDBField('ThousandSep'); + } + + //counting decimal places after formatting with sprintf (if any), otherwise - 0 + $dec_places = preg_match('/[\.,]+/', $tc_value) ? strlen(preg_replace('/^.*[\.,]+/', '', $tc_value)) : 0; + return number_format($tc_value, $dec_places, $comma, $thousands); + } + return $tc_value; } Index: branches/unlabeled/unlabeled-1.16.2/core/units/languages/languages_config.php =================================================================== diff -u -r6106 -r6508 --- branches/unlabeled/unlabeled-1.16.2/core/units/languages/languages_config.php (.../languages_config.php) (revision 6106) +++ branches/unlabeled/unlabeled-1.16.2/core/units/languages/languages_config.php (.../languages_config.php) (revision 6508) @@ -140,7 +140,7 @@ 'DateFormat' => Array('type' => 'string','not_null' => '1','default' => '','required'=>1), 'TimeFormat' => Array('type' => 'string','not_null' => '1','default' => '','required'=>1), 'InputDateFormat' => Array('type' => 'string', 'formatter' => 'kOptionsFormatter', 'options' => Array('m/d/Y' => 'm/d/Y'), 'not_null' => '1','default' => 'm/d/Y', 'required' => 1), - 'InputTimeFormat' => Array('type' => 'string', 'formatter' => 'kOptionsFormatter', 'options' => Array('g:i:s A' => 'g:i:s A'), 'not_null' => '1','default' => 'g:i:s A', 'required' => 1), + 'InputTimeFormat' => Array('type' => 'string', 'formatter' => 'kOptionsFormatter', 'options' => Array('g:i:s A' => 'g:i:s A'), 'not_null' => '1','default' => 'g:i:s A', 'required' => 1), 'DecimalPoint' => Array('type' => 'string','not_null' => '1','default' => ''), 'ThousandSep' => Array('type' => 'string','not_null' => '1','default' => ''), 'Charset' => Array('type' => 'string','not_null' => '1','default' => '','required'=>1), Index: branches/unlabeled/unlabeled-1.11.2/core/kernel/parser/construct_tags.php =================================================================== diff -u -r6479 -r6508 --- branches/unlabeled/unlabeled-1.11.2/core/kernel/parser/construct_tags.php (.../construct_tags.php) (revision 6479) +++ branches/unlabeled/unlabeled-1.11.2/core/kernel/parser/construct_tags.php (.../construct_tags.php) (revision 6508) @@ -84,7 +84,6 @@ function Process() { - print_pre($this, 'Processig '); switch ($this->Tag) { case 'if': case 'ifnot': Index: branches/unlabeled/unlabeled-1.16.2/kernel/units/languages/languages_config.php =================================================================== diff -u -r6106 -r6508 --- branches/unlabeled/unlabeled-1.16.2/kernel/units/languages/languages_config.php (.../languages_config.php) (revision 6106) +++ branches/unlabeled/unlabeled-1.16.2/kernel/units/languages/languages_config.php (.../languages_config.php) (revision 6508) @@ -140,7 +140,7 @@ 'DateFormat' => Array('type' => 'string','not_null' => '1','default' => '','required'=>1), 'TimeFormat' => Array('type' => 'string','not_null' => '1','default' => '','required'=>1), 'InputDateFormat' => Array('type' => 'string', 'formatter' => 'kOptionsFormatter', 'options' => Array('m/d/Y' => 'm/d/Y'), 'not_null' => '1','default' => 'm/d/Y', 'required' => 1), - 'InputTimeFormat' => Array('type' => 'string', 'formatter' => 'kOptionsFormatter', 'options' => Array('g:i:s A' => 'g:i:s A'), 'not_null' => '1','default' => 'g:i:s A', 'required' => 1), + 'InputTimeFormat' => Array('type' => 'string', 'formatter' => 'kOptionsFormatter', 'options' => Array('g:i:s A' => 'g:i:s A'), 'not_null' => '1','default' => 'g:i:s A', 'required' => 1), 'DecimalPoint' => Array('type' => 'string','not_null' => '1','default' => ''), 'ThousandSep' => Array('type' => 'string','not_null' => '1','default' => ''), 'Charset' => Array('type' => 'string','not_null' => '1','default' => '','required'=>1), Index: branches/unlabeled/unlabeled-1.27.2/core/kernel/db/dbitem.php =================================================================== diff -u -r6120 -r6508 --- branches/unlabeled/unlabeled-1.27.2/core/kernel/db/dbitem.php (.../dbitem.php) (revision 6120) +++ branches/unlabeled/unlabeled-1.27.2/core/kernel/db/dbitem.php (.../dbitem.php) (revision 6508) @@ -100,7 +100,9 @@ { $options = $this->GetFieldOptions($name); $parsed = $value; - if ($value == '') $parsed = NULL; + if ($value == '') { + $parsed = NULL; + } if (isset($options['formatter'])) { $formatter =& $this->Application->recallObject($options['formatter']); // $parsed = $formatter->Parse($value, $options, $err); @@ -781,13 +783,13 @@ if( !isset($id) ) $id = $this->GetID(); $event = new kEvent( Array('name'=>$name,'prefix'=>$this->Prefix,'special'=>$this->Special) ); $event->setEventParam('id', $id); - + if ($additional_params) { foreach ($additional_params as $ap_name => $ap_value) { $event->setEventParam($ap_name, $ap_value); } } - + $this->Application->HandleEvent($event); return $event->status == erSUCCESS ? true : false; } @@ -921,15 +923,15 @@ foreach ($this->customFields as $custom_id => $custom_name) { $cdata->SetDBField($ml_formatter->LangFieldName('cust_'.$custom_id), $this->GetDBField('cust_'.$custom_name)); } - + if ($cdata->isLoaded()) { $ret = $cdata->Update(); } else { $ret = $cdata->Create(); if ($cdata->mode == 't') $cdata->setTempID(); } - + return $ret; } }