mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 20:30:39 +02:00
fixed float numbers troubles (caused by system localization)
This commit is contained in:
@@ -1604,14 +1604,18 @@ class e_model extends e_object
|
||||
*/
|
||||
public function toNumber($value)
|
||||
{
|
||||
if(!is_numeric($value))
|
||||
{
|
||||
$larr = localeconv();
|
||||
$search = array($larr['decimal_point'], $larr['mon_decimal_point'], $larr['thousands_sep'], $larr['mon_thousands_sep'], $larr['currency_symbol'], $larr['int_curr_symbol']);
|
||||
$replace = array('.', '.', '', '', '', '');
|
||||
$value = str_replace($search, $replace, $value);
|
||||
}
|
||||
return (0 + $value);
|
||||
$larr = localeconv();
|
||||
$search = array(
|
||||
$larr['decimal_point'],
|
||||
$larr['mon_decimal_point'],
|
||||
$larr['thousands_sep'],
|
||||
$larr['mon_thousands_sep'],
|
||||
$larr['currency_symbol'],
|
||||
$larr['int_curr_symbol']
|
||||
);
|
||||
$replace = array('.', '.', '', '', '', '');
|
||||
|
||||
return str_replace($search, $replace, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -653,7 +653,12 @@ class e_db_mysql
|
||||
break;
|
||||
|
||||
case 'float':
|
||||
return (float) $fieldValue;
|
||||
// fix - convert localized float numbers
|
||||
$larr = localeconv();
|
||||
$search = array($larr['decimal_point'], $larr['mon_decimal_point'], $larr['thousands_sep'], $larr['mon_thousands_sep'], $larr['currency_symbol'], $larr['int_curr_symbol']);
|
||||
$replace = array('.', '.', '', '', '', '');
|
||||
|
||||
return str_replace($search, $replace, floatval($fieldValue));
|
||||
break;
|
||||
|
||||
case 'null':
|
||||
|
@@ -440,7 +440,7 @@ class e_validator
|
||||
break;
|
||||
|
||||
case 'float':
|
||||
$value = floatval($value);
|
||||
$value = 0.00;
|
||||
break;
|
||||
|
||||
case 'array':
|
||||
@@ -570,6 +570,7 @@ class e_validator
|
||||
break;
|
||||
|
||||
case 'float':
|
||||
$value = $this->toNumber($value);
|
||||
if(!is_numeric($value))
|
||||
{
|
||||
$this->addValidateResult($name, self::ERR_FLOAT_EXPECTED);
|
||||
@@ -586,7 +587,7 @@ class e_validator
|
||||
$this->addValidateResult($name, self::ERR_TOO_HIGH);
|
||||
return false;
|
||||
}
|
||||
$this->addValidData($name, (float) $value);
|
||||
$this->addValidData($name, $value);
|
||||
return true;
|
||||
break;
|
||||
|
||||
@@ -720,6 +721,22 @@ class e_validator
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function toNumber($value)
|
||||
{
|
||||
$larr = localeconv();
|
||||
$search = array(
|
||||
$larr['decimal_point'],
|
||||
$larr['mon_decimal_point'],
|
||||
$larr['thousands_sep'],
|
||||
$larr['mon_thousands_sep'],
|
||||
$larr['currency_symbol'],
|
||||
$larr['int_curr_symbol']
|
||||
);
|
||||
$replace = array('.', '.', '', '', '', '');
|
||||
|
||||
return str_replace($search, $replace, $value);
|
||||
}
|
||||
|
||||
protected function parseMinMax($string)
|
||||
{
|
||||
|
Reference in New Issue
Block a user