Project

General

Profile

Bug #20288 » bug10861-v4.patch

Administrator Admin, 2009-05-20 17:52

View differences:

tests/t3lib/t3lib_tcemain_testcase.php (working copy)
$this->fixture->checkModifyAccessList('be_users')
);
}
/**
* @test
*/
public function evalCheckValueDouble2() {
$testData = array (
'-0,5' => '-0.50',
'1000' => '1000.00',
'1000,10' => '1000.10',
'1000,0' => '1000.00',
'600.000.000,00' => '600000000.00',
'60aaa00' => '6000.00',
);
foreach ($testData as $value => $expectedReturnValue){
$returnValue = $this->fixture->checkValue_input_Eval($value, array('double2'), '');
$this->assertSame(
$returnValue['value'],
$expectedReturnValue
);
}
}
}
?>
t3lib/jsfunc.evalfield.js (working copy)
return outVal;
}
function evalFunc_parseDouble(value) {
var theVal = ''+value;
var dec=0;
if (!value) return 0;
for (var a=theVal.length; a>0; a--) {
if (theVal.substr(a-1,1)=='.' || theVal.substr(a-1,1)==',') {
dec = theVal.substr(a);
theVal = theVal.substr(0,a-1);
break;
}
var theVal = "" + value;
theVal = theVal.replace(/[^0-9,\.-]/g, "");
var negative = theVal.substring(0, 1) === '-';
theVal = theVal.replace(/-/g, "");
theVal = theVal.replace(/,/g, ".");
if (theVal.indexOf(".") == -1) {
theVal += ".0";
}
var parts = theVal.split(".");
var dec = parts.pop();
theVal = Number(parts.join("") + "." + dec);
if (negative) {
theVal *= -1;
}
dec = this.getNumChars(dec)+'00';
theVal=this.parseInt(this.noSpace(theVal))+TS.decimalSign+dec.substr(0,2);
theVal = theVal.toFixed(2);
return theVal;
}
t3lib/class.t3lib_tcemain.php (working copy)
*
* @param string Value to evaluate
* @param array Array of evaluations to traverse.
* @param string Is-in string
* @return string Modified $value
* @param string Is-in string for 'is_in' evaluation
* @return array Modified $value in key 'value' or empty array
*/
function checkValue_input_Eval($value,$evalArray,$is_in) {
$res = Array();
......
}
break;
case 'double2':
$theDec = 0;
for ($a=strlen($value); $a>0; $a--) {
if (substr($value,$a-1,1)=='.' || substr($value,$a-1,1)==',') {
$theDec = substr($value,$a);
$value = substr($value,0,$a-1);
break;
}
$value = preg_replace('/[^0-9,\.-]/', '', $value);
$negative = substr($value, 0, 1) == '-';
$value = strtr($value, array(',' => '.', '-' => ''));
if (strpos($value, '.') === false) {
$value .= '.0';
}
$theDec = preg_replace('/[^0-9]/','',$theDec).'00';
$value = intval(str_replace(' ','',$value)).'.'.substr($theDec,0,2);
$valueArray = explode('.', $value);
$dec = array_pop($valueArray);
$value = join('', $valueArray) . '.' . $dec;
if ($negative) {
$value *= -1;
}
$value = number_format($value, 2, '.', '');
break;
case 'md5':
if (strlen($value)!=32){$set=false;}
(3-3/3)