You are here

function lingotek_bulk_grid_query in Lingotek Translation 7.6

Same name and namespace in other branches
  1. 7.7 lingotek.bulk_grid.inc \lingotek_bulk_grid_query()
1 call to lingotek_bulk_grid_query()
lingotek_grid_get_rows in ./lingotek.bulk_grid.inc
Dynamic query processing function for the grid Since the header defines which columns are shown, this query gets all possible values and refines the header using the columns selected in the UI The filters are also processed here

File

./lingotek.bulk_grid.inc, line 1295

Code

function lingotek_bulk_grid_query($form_state, $count_only, $entity_id_key, $label_col, $entity_type, $limit, $bundle_col, $info, $entity_properties, $eid) {
  $base_table = $info['base table'];
  if ($count_only) {
    $query = db_select('' . $base_table . '', 'n');
  }
  else {
    $query = db_select('' . $base_table . '', 'n')
      ->extend('PagerDefault')
      ->extend('TableSort');
    $query
      ->limit($limit)
      ->orderByHeader($form_state['values']['grid_header']);
  }
  if ($base_table == 'node') {
    $query
      ->innerJoin('node', 'node2', '(n.nid = node2.nid) AND (node2.tnid = 0 OR node2.tnid = node2.nid)');
  }

  // Entity Title and Name of Content Type (type)
  $query
    ->fields('n', array(
    $entity_id_key,
  ));
  if ($label_col) {
    $query
      ->addField('n', $label_col, 'title');
  }
  $query
    ->addField('n', $entity_properties['language_col'], 'language');
  if (isset($entity_properties['changed'])) {
    $query
      ->addField('n', 'changed');
  }
  lingotek_bulk_grid_query_add_entity_specifics($query, $entity_type, $bundle_col, $info);
  lingotek_bulk_grid_query_add_statuses($query, $entity_type, $eid);
  lingotek_bulk_grid_query_add_localized_title($query, $entity_type, $eid, $label_col);
  lingotek_bulk_grid_query_add_keys($query, $entity_type, $eid);
  return $query;
}