Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/units/helpers/search_helper.php
Show First 20 Lines • Show All 210 Lines • ▼ Show 20 Line(s) | |||||
* Performs new search on a given grid | * Performs new search on a given grid | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access public | * @access public | ||||
*/ | */ | ||||
public function performSearch($event) | public function performSearch($event) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
// process search keyword | // process search keyword | ||||
$search_keyword = $this->Application->GetVar($event->getPrefixSpecial(true) . '_search_keyword'); | $search_keyword = $this->Application->GetVar($event->getPrefixSpecial(true) . '_search_keyword'); | ||||
$this->Application->StoreVar($event->getPrefixSpecial() . '_search_keyword', $search_keyword); | $this->Application->StoreVar($event->getPrefixSpecial() . '_search_keyword', $search_keyword); | ||||
$custom_filter = $this->processCustomFilters($event); | $custom_filter = $this->processCustomFilters($event); | ||||
if ( !$search_keyword && $custom_filter === false ) { | if ( !$search_keyword && $custom_filter === false ) { | ||||
Show All 17 Lines | |||||
function processAutomaticFilters($event, $search_keyword, $custom_filter) | function processAutomaticFilters($event, $search_keyword, $custom_filter) | ||||
{ | { | ||||
$grid_name = $this->Application->GetVar('grid_name'); | $grid_name = $this->Application->GetVar('grid_name'); | ||||
$grids = $this->Application->getUnitOption($event->Prefix, 'Grids'); | $grids = $this->Application->getUnitOption($event->Prefix, 'Grids'); | ||||
$search_fields = array_keys($grids[$grid_name]['Fields']); | $search_fields = array_keys($grids[$grid_name]['Fields']); | ||||
$search_filter = Array(); | $search_filter = Array(); | ||||
/** @var kDBList $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBList */ | |||||
foreach ($search_fields as $search_field) { | foreach ($search_fields as $search_field) { | ||||
$custom_search = isset($custom_filter[$search_field]); | $custom_search = isset($custom_filter[$search_field]); | ||||
$filter_data = $this->getSearchClause($object, $search_field, $search_keyword, $custom_search); | $filter_data = $this->getSearchClause($object, $search_field, $search_keyword, $custom_search); | ||||
if ($filter_data) { | if ($filter_data) { | ||||
$search_filter[$search_field] = $filter_data; | $search_filter[$search_field] = $filter_data; | ||||
▲ Show 20 Lines • Show All 422 Lines • ▼ Show 20 Line(s) | |||||
if ( $time_format ) { | if ( $time_format ) { | ||||
// time is missing, but time format available -> guess time and add to date | // time is missing, but time format available -> guess time and add to date | ||||
$time = ($type == 'from') ? adodb_mktime(0, 0, 0) : adodb_mktime(23, 59, 59); | $time = ($type == 'from') ? adodb_mktime(0, 0, 0) : adodb_mktime(23, 59, 59); | ||||
$time = adodb_date($time_format, $time); | $time = adodb_date($time_format, $time); | ||||
$value[$type] .= $dt_separator . $time; | $value[$type] .= $dt_separator . $time; | ||||
} | } | ||||
} | } | ||||
/** @var kFormatter $formatter */ | |||||
$formatter = $this->Application->recallObject($options['formatter']); | $formatter = $this->Application->recallObject($options['formatter']); | ||||
/* @var $formatter kFormatter */ | |||||
$value_ts = $formatter->Parse($value[$type], $search_field, $object); | $value_ts = $formatter->Parse($value[$type], $search_field, $object); | ||||
if ( $object->GetErrorPseudo($search_field) ) { | if ( $object->GetErrorPseudo($search_field) ) { | ||||
// invalid format -> ignore this date in search | // invalid format -> ignore this date in search | ||||
$object->RemoveError($search_field); | $object->RemoveError($search_field); | ||||
return false; | return false; | ||||
Show All 9 Lines | |||||
* @return string | * @return string | ||||
*/ | */ | ||||
function _getInputTimeFormat($field_options) | function _getInputTimeFormat($field_options) | ||||
{ | { | ||||
if ( array_key_exists('input_time_format', $field_options) ) { | if ( array_key_exists('input_time_format', $field_options) ) { | ||||
return $field_options['input_time_format']; | return $field_options['input_time_format']; | ||||
} | } | ||||
/** @var LanguagesItem $lang_current */ | |||||
$lang_current = $this->Application->recallObject('lang.current'); | $lang_current = $this->Application->recallObject('lang.current'); | ||||
/* @var $lang_current LanguagesItem */ | |||||
return $lang_current->GetDBField('InputTimeFormat'); | return $lang_current->GetDBField('InputTimeFormat'); | ||||
} | } | ||||
/** | /** | ||||
* Resets current search | * Resets current search | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
Show All 12 Lines | |||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @param Array $type_clauses | * @param Array $type_clauses | ||||
* @param string $types | * @param string $types | ||||
* @param string $except_types | * @param string $except_types | ||||
*/ | */ | ||||
function SetComplexFilter($event, &$type_clauses, $types, $except_types) | function SetComplexFilter($event, &$type_clauses, $types, $except_types) | ||||
{ | { | ||||
/** @var kMultipleFilter $includes_or_filter */ | |||||
$includes_or_filter = $this->Application->makeClass('kMultipleFilter', Array (kDBList::FLT_TYPE_OR)); | $includes_or_filter = $this->Application->makeClass('kMultipleFilter', Array (kDBList::FLT_TYPE_OR)); | ||||
/* @var $includes_or_filter kMultipleFilter */ | |||||
/** @var kMultipleFilter $excepts_and_filter */ | |||||
$excepts_and_filter = $this->Application->makeClass('kMultipleFilter', Array (kDBList::FLT_TYPE_AND)); | $excepts_and_filter = $this->Application->makeClass('kMultipleFilter', Array (kDBList::FLT_TYPE_AND)); | ||||
/* @var $excepts_and_filter kMultipleFilter */ | |||||
/** @var kMultipleFilter $includes_or_filter_h */ | |||||
$includes_or_filter_h = $this->Application->makeClass('kMultipleFilter', Array (kDBList::FLT_TYPE_OR)); | $includes_or_filter_h = $this->Application->makeClass('kMultipleFilter', Array (kDBList::FLT_TYPE_OR)); | ||||
/* @var $includes_or_filter_h kMultipleFilter */ | |||||
/** @var kMultipleFilter $excepts_and_filter_h */ | |||||
$excepts_and_filter_h = $this->Application->makeClass('kMultipleFilter', Array (kDBList::FLT_TYPE_AND)); | $excepts_and_filter_h = $this->Application->makeClass('kMultipleFilter', Array (kDBList::FLT_TYPE_AND)); | ||||
/* @var $excepts_and_filter_h kMultipleFilter */ | |||||
if ( $types ) { | if ( $types ) { | ||||
$types = explode(',', $types); | $types = explode(',', $types); | ||||
foreach ($types as $type) { | foreach ($types as $type) { | ||||
$type = trim($type); | $type = trim($type); | ||||
if ( isset($type_clauses[$type]) ) { | if ( isset($type_clauses[$type]) ) { | ||||
Show All 18 Lines | |||||
} | } | ||||
else { | else { | ||||
$excepts_and_filter->addFilter('filter_' . $type, $type_clauses[$type]['except']); | $excepts_and_filter->addFilter('filter_' . $type, $type_clauses[$type]['except']); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
/** @var kDBList $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBList */ | |||||
$object->addFilter('includes_filter', $includes_or_filter); | $object->addFilter('includes_filter', $includes_or_filter); | ||||
$object->addFilter('excepts_filter', $excepts_and_filter); | $object->addFilter('excepts_filter', $excepts_and_filter); | ||||
$object->addFilter('includes_filter_h', $includes_or_filter_h, kDBList::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); | $object->addFilter('excepts_filter_h', $excepts_and_filter_h, kDBList::HAVING_FILTER); | ||||
} | } | ||||
Show All 32 Lines |