Index: branches/5.2.x/core/units/helpers/search_helper.php =================================================================== diff -u -N -r14092 -r14095 --- branches/5.2.x/core/units/helpers/search_helper.php (.../search_helper.php) (revision 14092) +++ branches/5.2.x/core/units/helpers/search_helper.php (.../search_helper.php) (revision 14095) @@ -1,6 +1,6 @@ VirtualFields[$field_name]) ? 'having' : 'where'; - $field_type = isset($object->Fields[$field_name]['type']) ? $object->Fields[$field_name]['type'] : 'string'; + $sql_filter_type = $object->isVirtualField($field_name) ? 'having' : 'where'; + $field_options = $object->GetFieldOptions($field_name); + $field_type = isset($field_options['type']) ? $field_options['type'] : 'string'; + if (preg_match('/(.*)\.(.*)/', $field_name, $regs)) { $table_name = '`'.$regs[1].'`.'; // field from external table $field_name = $regs[2]; @@ -235,7 +237,7 @@ */ function getSearchClause(&$object, $field_name, $search_keyword, $custom_search) { - if (array_key_exists($field_name, $object->VirtualFields) && !array_key_exists($field_name, $object->CalculatedFields)) { + if ($object->isVirtualField($field_name) && !$object->isCalculatedField($field_name)) { // Virtual field, that is shown in grid, but it doesn't have corresponding calculated field. // Happens, when field value is calculated on the fly (during grid display) and it is not searchable. return ''; @@ -248,15 +250,16 @@ $filter_value = ''; // get field clause by formatter name and/or parameters - $formatter = getArrayValue($object->Fields[$field_name], 'formatter'); + $field_options = $object->GetFieldOptions($field_name); + $formatter = getArrayValue($field_options, 'formatter'); + switch ($formatter) { case 'kOptionsFormatter': $search_keys = Array(); if ($custom_search === false) { // if keywords passed through simple search filter (on each grid) - $use_phrases = getArrayValue($object->Fields[$field_name], 'use_phrases'); - $field_options = $object->GetFieldOptions($field_name); + $use_phrases = getArrayValue($field_options, 'use_phrases'); $multiple = array_key_exists('multiple', $field_options) && $field_options['multiple']; foreach ($field_options['options'] as $key => $val) { @@ -625,15 +628,17 @@ } } - $formatter =& $this->Application->recallObject($object->Fields[$search_field]['formatter']); + $formatter =& $this->Application->recallObject($options['formatter']); $value_ts = $formatter->Parse($value[$type], $search_field, $object); - $pseudo = getArrayValue($object->FieldErrors, $search_field, 'pseudo'); - if ($pseudo) { - unset($object->FieldErrors[$search_field]); // remove error! + + if ( $object->GetErrorPseudo($search_field) ) { // invalid format -> ignore this date in search + $object->RemoveError($search_field); + return false; } + return $value_ts; } @@ -677,11 +682,11 @@ */ function SetComplexFilter(&$event, &$type_clauses, $types, $except_types) { - $includes_or_filter =& $this->Application->makeClass('kMultipleFilter', FLT_TYPE_OR); - $excepts_and_filter =& $this->Application->makeClass('kMultipleFilter', FLT_TYPE_AND); + $includes_or_filter =& $this->Application->makeClass('kMultipleFilter', Array (kDBList::FLT_TYPE_OR)); + $excepts_and_filter =& $this->Application->makeClass('kMultipleFilter', Array (kDBList::FLT_TYPE_AND)); - $includes_or_filter_h =& $this->Application->makeClass('kMultipleFilter', FLT_TYPE_OR); - $excepts_and_filter_h =& $this->Application->makeClass('kMultipleFilter', FLT_TYPE_AND); + $includes_or_filter_h =& $this->Application->makeClass('kMultipleFilter', Array (kDBList::FLT_TYPE_OR)); + $excepts_and_filter_h =& $this->Application->makeClass('kMultipleFilter', Array (kDBList::FLT_TYPE_AND)); if ($types) { $types = explode(',', $types); @@ -714,11 +719,12 @@ } $object =& $event->getObject(); + /* @var $object kDBList */ $object->addFilter('includes_filter', $includes_or_filter); $object->addFilter('excepts_filter', $excepts_and_filter); - $object->addFilter('includes_filter_h', $includes_or_filter_h, HAVING_FILTER); - $object->addFilter('excepts_filter_h', $excepts_and_filter_h, HAVING_FILTER); + $object->addFilter('includes_filter_h', $includes_or_filter_h, kDBList::HAVING_FILTER); + $object->addFilter('excepts_filter_h', $excepts_and_filter_h, kDBList::HAVING_FILTER); } } \ No newline at end of file