You are here

function tmgmt_node_handler_filter_missing_translation::query in Translation Management Tool 7

Add this filter to the query.

Due to the nature of fapi, the value and the operator have an unintended level of indirection. You will find them in $this->operator and $this->value respectively.

Overrides views_handler_filter::query

File

sources/node/views/handlers/tmgmt_node_handler_filter_missing_translation.inc, line 25
Definition of tmgmt_node_handler_filter_missing_translation.

Class

tmgmt_node_handler_filter_missing_translation
Filter by language.

Code

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

  // Don't do anything if no language was selected.
  if (!$this->value) {
    return;
  }
  $join = new views_join();
  $join->definition['left_table'] = $this->table_alias;
  $join->definition['left_field'] = $this->real_field;
  $join->definition['table'] = 'node';
  $join->definition['field'] = 'tnid';
  $join->definition['type'] = 'LEFT';
  $join
    ->construct();
  $join->extra = array(
    array(
      'field' => 'language',
      'value' => $this->value,
    ),
  );
  $table_alias = $this->query
    ->add_table('node', $this->relationship, $join);
  $this->query
    ->add_where_expression($this->options['group'], "{$this->table_alias}.language != :language", array(
    ':language' => $this->value,
  ));
  if ($this->target_status == 'untranslated_or_outdated') {
    $this->query
      ->add_where_expression($this->options['group'], "({$table_alias}.nid IS NULL OR {$this->table_alias}.translate = 1)");
  }
  elseif ($this->target_status == 'outdated') {
    $this->query
      ->add_where_expression($this->options['group'], "{$this->table_alias}.translate = 1");
  }
  elseif ($this->target_status == 'untranslated') {
    $this->query
      ->add_where_expression($this->options['group'], "{$table_alias}.nid IS NULL");
  }
}