function testCond($cond, $data, $or = false, $empty = false) { $valid = true; $def = $empty; $modifKeys = array('and', 'or'); App::import('Lib', 'Operations'); foreach ($cond as $key => $cnd) { $op = false; $path = $key; if (is_numeric($path)) { $val = $data; } elseif (in_array($path, $modifKeys)) { $val = $data; } elseif (array_key_exists($path, $data)) { $val = $data[$path]; } else { $op = Operations::parseStringOperation($path, array('mode' => 'left', 'type' => 'bool', 'sepPattern' => '\\h+')); if ($op) { $path = $op['subject']; } $val = Set::Extract($path, $data); } if ($op) { $op['subject'] = $val; $op['val'] = $cnd; $valid = Operations::applyOperation($op); } elseif (is_null($cnd)) { $valid = is_null($val); } elseif (is_array($cnd)) { $or = $path == 'or'; $valid = SetMulti::testCond($cnd, $val, $or); } elseif (!is_null($data)) { $valid = $val == $cnd; } else { $valid = false; } if ($valid == $or) { return $or; } $def = $valid; } return $def; }