commit 061e1a3ce419de6b4e86169488bb23c290f68733
Author: Florian Weber <f.weber@digi-info.de>
Date:   Fri Aug 5 16:18:25 2011 +0200

    Issue #1172116 by webflo: Added Missing filter: taxonomy fields.

diff --git a/i18nviews.info b/i18nviews.info
index ce2c7ca..9425984 100644
--- a/i18nviews.info
+++ b/i18nviews.info
@@ -21,4 +21,5 @@ files[] = includes/i18nviews_handler_filter_term_language.inc
 files[] = includes/i18nviews_handler_filter_taxonomy_index_tid.inc
 files[] = includes/i18nviews_plugin_argument_validate_i18n_taxonomy_term.inc
 files[] = includes/i18nviews_plugin_localization_i18nstrings.inc
+files[] = includes/i18nviews_handler_filter_term_node_tid.inc
 files[] = includes/i18nviews_handler_filter_term_node_tid_depth.inc
diff --git a/includes/i18nviews.views.inc b/includes/i18nviews.views.inc
index 1c79d4b..3c78db3 100644
--- a/includes/i18nviews.views.inc
+++ b/includes/i18nviews.views.inc
@@ -158,15 +158,24 @@ function i18nviews_views_data_alter(&$data) {
 }
 
 /**
- * Implementation of hook_field_views_data().
+ * Implementation of hook_field_views_data_alter().
  *
  * modules/taxonomy.views.inc taxonomy_field_views_data()
+ * @see hook_field_views_data().
+ * @see field_views_data().
  */
-function i18nviews_field_views_data(&$result, &$field, $module) {
-  // provide translated variant
-  if ($module=='taxonomy') {
-    // TODO CHECK
-    //dsm(func_get_args());
+function i18nviews_field_views_data_alter(&$data, &$field, $module) {
+  if ($module == 'taxonomy') {
+    foreach ($data as $table_name => $table_data) {
+      foreach ($table_data as $field_name => $field_data) {
+        if (isset($field_data['filter'])) {
+          $data[$table_name][$field_name . '_i18n'] = $data[$table_name][$field_name];
+          $data[$table_name][$field_name . '_i18n']['real field'] = $field_name;
+          $data[$table_name][$field_name . '_i18n']['title'] .= ' (translated)';
+          $data[$table_name][$field_name . '_i18n']['filter']['handler'] = 'i18nviews_handler_filter_term_node_tid';
+        }
+      }
+    }
   }
 }
 
diff --git a/includes/i18nviews_handler_filter_term_node_tid.inc b/includes/i18nviews_handler_filter_term_node_tid.inc
new file mode 100644
index 0000000..47f0928
--- /dev/null
+++ b/includes/i18nviews_handler_filter_term_node_tid.inc
@@ -0,0 +1,119 @@
+<?php
+
+/**
+ * Filter by term id (translated).
+ */
+class i18nviews_handler_filter_term_node_tid extends views_handler_filter_term_node_tid {
+  function value_form(&$form, &$form_state) {
+    $vocabulary = taxonomy_vocabulary_machine_name_load($this->options['vocabulary']);
+    if (empty($vocabulary) && $this->options['limit']) {
+      $form['markup'] = array(
+        '#markup' => '<div class="form-item">' . t('An invalid vocabulary is selected. Please change it in the options.') . '</div>',
+      );
+      return;
+    }
+
+    if ($this->options['type'] == 'textfield') {
+      $default = '';
+      if ($this->value) {
+        $result = db_select('taxonomy_term_data', 'td')
+          ->fields('td')
+          ->condition('td.tid', $this->value)
+          ->execute();
+        foreach ($result as $term) {
+          if ($default) {
+            $default .= ', ';
+          }
+          $default .= check_plain(i18n_string('taxonomy:term:'. $term->tid .':name', $term->name));
+        }
+      }
+
+      $form['value'] = array(
+        '#title' => $this->options['limit'] ? t('Select terms from vocabulary @voc', array('@voc' => $vocabulary->name)) : t('Select terms'),
+        '#type' => 'textfield',
+        '#default_value' => $default,
+      );
+
+      if ($this->options['limit']) {
+        $form['value']['#autocomplete_path'] = 'admin/views/ajax/autocomplete/taxonomy/' . $vocabulary->vid;
+      }
+    }
+    else {
+      if (!empty($this->options['hierarchy']) && $this->options['limit']) {
+        $tree = taxonomy_get_tree($vocabulary->vid);
+        $options = array();
+
+        if ($tree) {
+          foreach ($tree as $term) {
+            $choice = new stdClass();
+            $choice->option = array($term->tid => str_repeat('-', $term->depth) . check_plain(i18n_string('taxonomy:term:'. $term->tid .':name', $term->name)));
+            $options[] = $choice;
+          }
+        }
+      }
+      else {
+        $options = array();
+        $query = db_select('taxonomy_term_data', 'td');
+        $query->innerJoin('taxonomy_vocabulary', 'tv', 'td.vid = tv.vid');
+        $query->fields('td');
+        $query->orderby('tv.weight');
+        $query->orderby('tv.name');
+        $query->orderby('td.weight');
+        $query->orderby('td.name');
+        $query->addTag('term_access');
+        if ($this->options['limit']) {
+          $query->condition('tv.machine_name', $vocabulary->machine_name);
+        }
+        $result = $query->execute();
+        foreach ($result as $term) {
+          $options[$term->tid] = check_plain(i18n_string('taxonomy:term:'. $term->tid .':name', $term->name));
+        }
+      }
+
+      $default_value = (array) $this->value;
+
+      if (!empty($form_state['exposed'])) {
+        $identifier = $this->options['expose']['identifier'];
+
+        if (!empty($this->options['expose']['reduce'])) {
+          $options = $this->reduce_value_options($options);
+
+          if (!empty($this->options['expose']['multiple']) && empty($this->options['expose']['required'])) {
+            $default_value = array();
+          }
+        }
+
+        if (empty($this->options['expose']['multiple'])) {
+          if (empty($this->options['expose']['required']) && (empty($default_value) || !empty($this->options['expose']['reduce']))) {
+            $default_value = 'All';
+          }
+          elseif (empty($default_value)) {
+            $keys = array_keys($options);
+            $default_value = array_shift($keys);
+          }
+          else {
+            $copy = $default_value;
+            $default_value = array_shift($copy);
+          }
+        }
+      }
+      $form['value'] = array(
+        '#type' => 'select',
+        '#title' => $this->options['limit'] ? t('Select terms from vocabulary @voc', array('@voc' => $vocabulary->name)) : t('Select terms'),
+        '#multiple' => TRUE,
+        '#options' => $options,
+        '#size' => min(9, count($options)),
+        '#default_value' => $default_value,
+      );
+
+      if (!empty($form_state['exposed']) && !isset($form_state['input'][$identifier])) {
+        $form_state['input'][$identifier] = $default_value;
+      }
+    }
+
+    if (empty($form_state['exposed'])) {
+      // Retain the helper option
+      $this->helper->options_form($form, $form_state);
+    }
+  }
+}
