diff --git a/modules/taxonomy/views_handler_filter_term_node_tid.inc b/modules/taxonomy/views_handler_filter_term_node_tid.inc index 7eb868f..e99bd99 100644 --- a/modules/taxonomy/views_handler_filter_term_node_tid.inc +++ b/modules/taxonomy/views_handler_filter_term_node_tid.inc @@ -125,30 +125,40 @@ class views_handler_filter_term_node_tid extends views_handler_filter_many_to_on $tree = taxonomy_get_tree($vocabulary->vid); $options = array(); + // The translation system needs full entity objects, so we have to look + // up displayable data from a real loaded term object. + foreach ($tree as $data) { + $tids[] = $data->tid; + } + $terms = taxonomy_term_load_multiple($tids); + if ($tree) { foreach ($tree as $term) { $choice = new stdClass(); - $choice->option = array($term->tid => str_repeat('-', $term->depth) . $term->name); + $choice->option = array($term->tid => str_repeat('-', $term->depth) . entity_label('taxonomy_term', $terms[$term->tid])); $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'); + + $query = new EntityFieldQuery(); + $query->entityCondition('entity_type', 'taxonomy_term') + ->propertyOrderBy('vid') // Equivalent of sorting by vocab name, per EFQ docs. + ->propertyOrderBy('weight') + ->propertyOrderBy('name'); + if ($this->options['limit']) { - $query->condition('tv.machine_name', $vocabulary->machine_name); + $query->entityCondition('bundle', $vocabulary->machine_name); } + $result = $query->execute(); - foreach ($result as $term) { - $options[$term->tid] = $term->name; + if (!empty($result['taxonomy_term'])) { + $terms = entity_load('taxonomy_term', array_keys($result['taxonomy_term'])); + foreach ($terms as $term) { + $options[$term->tid] = entity_label('taxonomy_term', $term); + } } }