You are here

function entity_translation_handler_filter_translation_exists::query in Entity Translation 7

Override the default behaviour of the handler.

Overrides views_handler_filter_in_operator::query

File

views/entity_translation_handler_filter_translation_exists.inc, line 106
Contains an entity type filter handler.

Class

entity_translation_handler_filter_translation_exists
This handler determines if a translation exists for a particular translation.

Code

function query() {
  $this
    ->ensure_my_table();

  // We need a subquery to determine not in.
  if ($this->operator == 'not in') {
    $entity_type = 'node';
    if ($this->options['use_filter'] && isset($this->view->filter[$this->options['filter']])) {
      $filter = $this->view->filter[$this->options['filter']];
      $entity_type = current($filter->value);
    }
    else {
      $this->query
        ->add_where($this->options['group'], "{$this->table_alias}.entity_type", $this->options['entity_type'], '=');
      $entity_type = $this->options['entity_type'];
    }
    $query = db_select('entity_translation', 'es')
      ->condition('entity_type', $entity_type)
      ->condition('language', $this->value);
    $query
      ->addField('es', 'entity_id');
    $this->query
      ->add_where($this->options['group'], "{$this->table_alias}.entity_id", $query, $this->operator);
  }
  else {
    $value = array_keys($this->value);
    $this->query
      ->add_where($this->options['group'], "{$this->table_alias}.source", '', '<>');
    $this->query
      ->add_where($this->options['group'], "{$this->table_alias}.language", array_values($this->value), $this->operator);
  }
}