You are here

function lingotek_bulk_grid_query_add_entity_specifics in Lingotek Translation 7.7

Same name and namespace in other branches
  1. 7.6 lingotek.bulk_grid.inc \lingotek_bulk_grid_query_add_entity_specifics()
1 call to lingotek_bulk_grid_query_add_entity_specifics()
lingotek_bulk_grid_query in ./lingotek.bulk_grid.inc

File

./lingotek.bulk_grid.inc, line 1931

Code

function lingotek_bulk_grid_query_add_entity_specifics($query, $entity_type, $bundle_col, $info) {
  if ($entity_type == 'comment') {
    $query
      ->join('node', 'nn', 'nn.nid = n.nid');
    $query
      ->addExpression("CONCAT('comment_node_',nn.type)", 'type');
    $query
      ->addExpression("CONCAT('comment_node_',nn.type)", 'node_type');
  }
  elseif ($entity_type == 'taxonomy_term') {
    $taxonomy_bundles_with_custom_fields = lingotek_get_advanced_vocabularies();
    if (empty($taxonomy_bundles_with_custom_fields)) {
      $taxonomy_bundles_with_custom_fields = array(
        -1,
      );
    }
    $query
      ->addField('n', 'description');
    $query
      ->innerJoin('taxonomy_vocabulary', 'tv', 'n.vid = tv.vid');
    $query
      ->addField('tv', 'name', 'tv_name');
    $query
      ->addField('tv', 'machine_name', 'type');
    $query
      ->addField('tv', 'i18n_mode', 'translation_mode');
    $query
      ->condition('tv.machine_name', $taxonomy_bundles_with_custom_fields, 'IN');
  }
  elseif ($bundle_col) {
    if ($info['entity keys']['bundle'] != 'type') {
      $query
        ->addField('n', $info['entity keys']['bundle']);
    }
    $query
      ->addField('n', $info['entity keys']['bundle'], 'type');

    // beans have the $bundle_col, and also need the label
    if ($entity_type == 'bean') {
      $query
        ->addField('n', 'label');
    }
    if ($entity_type == 'menu_link') {
      $min_query = db_select('menu_links', 'ml')
        ->condition('ml.i18n_tsid', 0, '!=')
        ->groupBy('i18n_tsid');
      $min_query
        ->addExpression('MIN(mlid)', 'minimum');
      $ml_or = db_or();
      $ml_or
        ->condition('n.i18n_tsid', 0);
      $ml_or
        ->condition('n.mlid', $min_query, 'IN');
      $query
        ->condition('n.language', LANGUAGE_NONE, '!=');
      $query
        ->condition($ml_or);
    }
  }
}