You are here

public function FrxSyntaxEngine::test in Forena Reports 7.3

Same name and namespace in other branches
  1. 6.2 FrxSyntaxEngine.inc \FrxSyntaxEngine::test()
  2. 7.4 FrxSyntaxEngine.inc \FrxSyntaxEngine::test()

Test for TRUE/FALSE for conditions that are able to be represented using bind parameters Note that | are used to separate the different conditions and these are to be OR'd together.

Parameters

$condition String:

File

./FrxSyntaxEngine.inc, line 160
FrXSytnaxEngine defines how regular expression procesing/token substitution takes place. It includes support for passing in a formatter oobject that will escape strings properly before substituting them.

Class

FrxSyntaxEngine
@file FrXSytnaxEngine defines how regular expression procesing/token substitution takes place. It includes support for passing in a formatter oobject that will escape strings properly before substituting them.

Code

public function test($condition) {
  $eval = TRUE;
  $tests = explode('&', $condition);
  if ($tests) {
    foreach ($tests as $test) {
      $t = trim($test);
      $res = $this
        ->replace($t, TRUE);
      if (is_string($res)) {
        $res = trim($res, ' !') ? TRUE : FALSE;
        if (strpos($t, '!') === 0) {
          $res = !$res;
        }
      }
      else {
        $res = $res ? TRUE : FALSE;
      }
      $eval = $eval && $res;
    }
  }
  return $eval;
}