Index: i18ntaxonomy.module =================================================================== --- i18ntaxonomy.module (revision 1650) +++ i18ntaxonomy.module (working copy) @@ -645,3 +645,14 @@ function i18ntaxonomy_vocabulary($vid = return $options; } } + +/** + * Implementation of hook_views_api + */ +function i18ntaxonomy_views_api() { + return array( + 'api' => '2.0', + 'path' => drupal_get_path('module', 'i18ntaxonomy'), + ); +} + Index: i18ntaxonomy.views.inc =================================================================== --- i18ntaxonomy.views.inc (revision 0) +++ i18ntaxonomy.views.inc (revision 0) @@ -0,0 +1,28 @@ + array( + 'path' => drupal_get_path('module', 'i18ntaxonomy') . '/includes', + ), + 'handlers' => array( + 'i18ntaxonomy_handler_filter_term_node_tid' => array( + 'parent' => 'views_handler_filter_term_node_tid', + ), + ), + ); +} Index: includes/i18ntaxonomy_handler_filter_term_node_tid.inc =================================================================== --- includes/i18ntaxonomy_handler_filter_term_node_tid.inc (revision 0) +++ includes/i18ntaxonomy_handler_filter_term_node_tid.inc (revision 0) @@ -0,0 +1,59 @@ +options['vid']); + if (!empty($this->options['expose']['i18ntaxonomy_terms'])) { + if (empty($this->options['hierarchy'])) { + global $language; + $options = array(); + $result = db_query("SELECT * FROM {term_data} WHERE vid = %d AND language = '%s' ORDER BY weight, name", $vocabulary->vid, $language->language); + while ($term = db_fetch_object($result)) { + $options[$term->tid] = $term->name; + } + + $form['value'] = array( + '#type' => 'select', + '#title' => t('Select terms from vocabulary @voc', array('@voc' => $vocabulary->name)), + '#multiple' => TRUE, + '#options' => $options, + '#size' => min(9, count($options)), + '#default_value' => $default_value, + ); + } + } + + // Localise terms + foreach ($form['value']['#options'] as $index => $opt) { + foreach ($opt->option as $opt_key => $opt_value) { + $prefix = ''; + if (preg_match('/^(-+?)(.*)$/', $opt_value, $matches)) { + $opt_value = $matches[2]; + $prefix = $matches[1]; + } + $form['value']['#options'][$index]->option[$opt_key] = $prefix . tt("taxonomy:term:$opt_key:name", $opt_value); + } + } + } + + function expose_options() { + parent::expose_options(); + $this->options['expose']['i18ntaxonomy_terms'] = FALSE; + } + + function expose_form_right(&$form, &$form_state) { + parent::expose_form_right($form, $form_state); + $vocabulary = taxonomy_vocabulary_load($this->options['vid']); + if (i18ntaxonomy_vocabulary($vocabulary->vid) == I18N_TAXONOMY_TRANSLATE) { + $form['expose']['i18ntaxonomy_terms'] = array( + '#type' => 'checkbox', + '#title' => t('Limit list to terms with the same language that actual page language'), + '#description' => t('If checked, the only items presented to the user will be the ones whit the same page language.'), + '#default_value' => !empty($this->options['expose']['i18ntaxonomy_terms']), + ); + } + } +}