function lingotek_bulk_grid_filter_search_box in Lingotek Translation 7.6
Same name and namespace in other branches
- 7.7 lingotek.bulk_grid.inc \lingotek_bulk_grid_filter_search_box()
1 call to lingotek_bulk_grid_filter_search_box()
File
- ./
lingotek.bulk_grid.inc, line 1430
Code
function lingotek_bulk_grid_filter_search_box($query, $filters, $eid, $label_col, $entity_type) {
if (isset($filters['search_type']) && $filters['search_type'] == 'all') {
$filters['title'] = $filters['body'] = $filters['search'];
}
$title_query = $body_query = array(
-1,
);
if ($entity_type == 'comment') {
$title_field_table = 'field_data_subject_field';
$title_field_col = 'subject_field_value';
$body_field_table = 'field_data_comment_body';
$body_field_col = 'comment_body_value';
}
else {
$title_field_table = 'field_data_title_field';
$title_field_col = 'title_field_value';
$body_field_table = 'field_data_body';
$body_field_col = 'body_value';
}
if (isset($filters['title']) && db_table_exists($title_field_table)) {
$title_query = db_select($title_field_table, 'tf')
->distinct()
->fields('tf', array(
'entity_id',
))
->condition('tf.' . $title_field_col, '%' . $filters['title'] . '%', 'LIKE');
}
if (isset($filters['body']) && db_table_exists($body_field_table)) {
$body_query = db_select($body_field_table, 'tb')
->distinct()
->fields('tb', array(
'entity_id',
))
->condition('tb.' . $body_field_col, '%' . $filters['body'] . '%', 'LIKE');
}
// Search
if (isset($filters['search_type']) && $filters['search_type'] == 'all' && isset($filters['search']) && strlen($filters['search'])) {
$or = db_or();
if (!empty($label_col)) {
$or
->condition('n.' . $label_col, '%' . $filters['search'] . '%', 'LIKE');
}
$or
->condition('' . $eid . '', $title_query, 'IN');
$or
->condition('' . $eid . '', $body_query, 'IN');
$query
->condition($or);
}
else {
// Title Field
if (isset($filters['title']) && $filters['title'] != '') {
$or = db_or();
$or
->condition('' . $eid . '', $title_query, 'IN');
if (!empty($label_col)) {
$or
->condition('n.' . $label_col, '%' . $filters['search'] . '%', 'LIKE');
}
$query
->condition($or);
}
// Body Field
if (isset($filters['body']) && $filters['body'] != '') {
$query
->condition('' . $eid . '', $body_query, 'IN');
}
}
}