protected function build_compound_crits_to_words(Utils_RecordBrowser_Crits $crits) { $parts = array(); foreach ($crits->get_component_crits() as $c) { $words = $this->to_words_internal($c); if ($words['str']) { $parts[] = $words; } } if (!$parts) { return self::$empty_c; } $multiple = count($parts) > 1; foreach ($parts as $k => $p) { $parts[$k] = $multiple && $p['multiple'] ? $this->cc($p['str']) : $p['str']; } $join_operator = strtolower($crits->get_join_operator()); $glue = ' ' . _V($join_operator) . ' '; $neg = $crits->get_negation() ? ' ' . __('Not') : ''; $str = implode($glue, $parts); if ($neg) { if ($multiple) { $str = $this->cc($str); } $str = "{$neg} {$str}"; $multiple = false; } return array('str' => $str, 'multiple' => $multiple); }
protected function validate_compound(Utils_RecordBrowser_Crits $crits, $record) { if ($crits->is_empty()) { return true; } $or = $crits->get_join_operator() == 'OR'; $success = $or ? false : true; foreach ($crits->get_component_crits() as $c) { $satisfied = $this->validate($c, $record); if ($or) { if ($satisfied) { $success = true; break; } } else { if (!$satisfied) { $success = false; break; } } } if ($crits->get_negation()) { $success = !$success; } return $success; }