| | |
| | | // add required (non empty) fields filter |
| | | $req_filter = ''; |
| | | foreach ((array)$required as $field) { |
| | | if (in_array($field, (array)$fields)) // required field is already in search filter |
| | | continue; |
| | | if ($attrs = $this->_map_field($field)) { |
| | | if (count($attrs) > 1) |
| | | $req_filter .= '(|'; |
| | |
| | | |
| | | foreach ((array)$this->prop['autovalues'] as $lf => $templ) { |
| | | if (empty($attrs[$lf])) { |
| | | // replace {attr} placeholders with concrete attribute values |
| | | $templ = preg_replace('/\{\w+\}/', '', strtr($templ, $attrvals)); |
| | | |
| | | if (strpos($templ, '(') !== false) |
| | | $attrs[$lf] = eval("return ($templ);"); |
| | | else |
| | | $attrs[$lf] = $templ; |
| | | if (strpos($templ, '(') !== false) { |
| | | // replace {attr} placeholders with (escaped!) attribute values to be safely eval'd |
| | | $code = preg_replace('/\{\w+\}/', '', strtr($templ, array_map('addslashes', $attrvals))); |
| | | $attrs[$lf] = eval("return ($code);"); |
| | | } |
| | | else { |
| | | // replace {attr} placeholders with concrete attribute values |
| | | $attrs[$lf] = preg_replace('/\{\w+\}/', '', strtr($templ, $attrvals)); |
| | | } |
| | | } |
| | | } |
| | | } |