Feature #19515 » extend_condition.diff
t3lib/class.t3lib_matchcondition.php (working copy) | ||
---|---|---|
}
|
||
break;
|
||
case 'globalVar':
|
||
$values = explode(',',$value);
|
||
while(list(,$test)=each($values)) {
|
||
$values = explode(',',$value);
|
||
foreach ($values as $test) {
|
||
$test = trim($test);
|
||
if (strlen($test)) {
|
||
$point = strcspn($test,'=<>');
|
||
$point = strcspn($test,'!=<>');
|
||
$theVarName = substr($test,0,$point);
|
||
$nv = $this->getGP_ENV_TSFE(trim($theVarName));
|
||
$testValue = substr($test,$point);
|
||
|
||
if ($this->testNumber($testValue,$nv)) {return true;}
|
||
}
|
||
}
|
||
... | ... | |
}
|
||
/**
|
||
* Will evaluate a $value based on an operator: "<", ">" or "=" (default)
|
||
* Will evaluate a $value based on an operator: "<", ">", "<=", ">=", "!=" or "=" (default)
|
||
*
|
||
* @param string The value to compare with on the form [operator][number]. Eg. "< 123"
|
||
* @param integer The number
|
||
* @return boolean If $value is "50" and $test is "< 123" then it will return true.
|
||
*/
|
||
function testNumber($test,$value) {
|
||
$test = trim($test);
|
||
$test = trim($test);
|
||
switch(substr($test,0,1)) {
|
||
case '<':
|
||
if (doubleval(substr($test,1))>$value) return true;
|
||
if (substr($test, 1, 1) == '=') {
|
||
return ($value <= doubleval(substr($test, 2)));
|
||
} else {
|
||
return ($value < doubleval(substr($test, 1)));
|
||
}
|
||
break;
|
||
case '>':
|
||
if (doubleval(substr($test,1))<$value) return true;
|
||
if (substr($test, 1, 1) == '=') {
|
||
return ($value >= doubleval(substr($test, 2)));
|
||
} else {
|
||
return ($value > doubleval(substr($test, 1)));
|
||
}
|
||
break;
|
||
case '!':
|
||
return (doubleval(substr($test, 2)) != $value);
|
||
break;
|
||
default:
|
||
if (trim(substr($test,1))==$value) return true;
|
||
return (trim(substr($test, 1)) == $value);
|
||
break;
|
||
}
|
||