Index: apachesolr_search.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr_search.module,v retrieving revision 1.1.2.6.2.133 diff -u -p -r1.1.2.6.2.133 apachesolr_search.module --- apachesolr_search.module 24 Feb 2010 23:00:01 -0000 1.1.2.6.2.133 +++ apachesolr_search.module 12 Jul 2010 08:58:31 -0000 @@ -663,7 +663,7 @@ function apachesolr_search_taxonomy_face } // Check that we have a response and a valid vid. - if (is_object($response->facet_counts->facet_fields->$delta) && ($vocab = taxonomy_vocabulary_load($vid))) { + if (is_object($response->facet_counts->facet_fields->$delta) && ($vocab = apachesolr_search_localize_taxonomy_vocabulary(taxonomy_vocabulary_load($vid)))) { $reflect_hierarchy = apachesolr_search_get_hierarchical_vocabularies(); $contains_active = FALSE; $facets = array(); @@ -694,6 +694,7 @@ function apachesolr_search_taxonomy_face // @todo: faster as 2x separate queries? $result = db_query("SELECT tid, parent FROM {term_hierarchy} WHERE parent > 0 AND (tid IN ($placeholders) OR parent IN ($placeholders))", array_merge($tids, $tids)); while ($term = db_fetch_object($result)) { + $term = apachesolr_search_localize_taxonomy_term($term); // Mark all terms that are parents for later CSS class. // We assume data in the Solr index is complete - potential for some // breakage here. @@ -745,6 +746,60 @@ function apachesolr_search_taxonomy_face } /** + * Localizes taxonomy term + * + * @param $term + * The taxonomy term object to localize. + * @return + * A localized version of the term object. + */ +function apachesolr_search_localize_taxonomy_term($term) { + if (module_exists('i18ntaxonomy') && i18ntaxonomy_vocabulary($term->vid) == I18N_TAXONOMY_LOCALIZE) { + $term->name = i18nstrings("taxonomy:term:{$term->tid}:name", $term->name); + } + return $term; +} + +/** + * Localizes taxonomy vocabulary + * + * @param $vocab + * The taxonomy vocabulary object to localize. + * @return + * The localized version of the vocabulary object. + */ +function apachesolr_search_localize_taxonomy_vocabulary($vocab) { + if (module_exists('i18ntaxonomy') && i18ntaxonomy_vocabulary($vocab->vid) == I18N_TAXONOMY_LOCALIZE) { + $vocab->name = i18nstrings("taxonomy:vocabulary:{$vocab->vid}:name", $vocab->name); + } + return $vocab; +} + +/** + * Detects if taxonomy object should be localized + * + * @param $obj + * A taxonomy vocabulary or term object. + * @return + * TRUE if the object should be localized. + */ +function apachesolr_search_taxonomy_needs_localization($obj) { + static $localize = array(); + + if (module_exists('i18ntaxonomy')) { + if (empty($localize)) { + $localize = i18ntaxonomy_vocabulary(NULL, I18N_TAXONOMY_LOCALIZE); + } + } + + if (in_array($obj->vid, $localize)) { + return TRUE; + } + + return FALSE; +} + +/** * Callback function for the 'Filter by book' facet block. */ function apachesolr_search_get_book($facet, &$options) { @@ -845,6 +900,9 @@ function apachesolr_search_get_username( function apachesolr_search_get_type($facet) { $type = node_get_types('name', $facet); // A disabled or missing node type returns FALSE. + if ($type && module_exists('i18ncontent')) { + $type = tt("nodetype:type:$type:name", $type); + } return ($type === FALSE) ? $facet : $type; } @@ -1134,7 +1192,7 @@ function theme_apachesolr_breadcrumb_uid */ function theme_apachesolr_breadcrumb_tid($tid) { if (function_exists('taxonomy_get_term')) { - if ($term = taxonomy_get_term($tid)) { + if ($term = apachesolr_search_localize_taxonomy_term(taxonomy_get_term($tid))) { return $term->name; } }