diff --git a/materio_search_api.module b/materio_search_api.module index 7c6cd81a..b0d579d9 100755 --- a/materio_search_api.module +++ b/materio_search_api.module @@ -708,6 +708,8 @@ function materio_search_api_advanced_search_form($form, &$form_state){ ); foreach ($vocabularies as $vid) { + // dsm($vid, "vid"); + $voc = taxonomy_vocabulary_load($vid); // dsm($voc, 'voc'); @@ -717,14 +719,13 @@ function materio_search_api_advanced_search_form($form, &$form_state){ '#tree' => true, ); - $tree = taxonomy_get_tree($vid, 0, 1); + $tree = taxonomy_get_tree($vid, 0, 1, TRUE); // dsm($tree, 'tree'); if(!count($tree)) continue; foreach ($tree as $term) { - $term = taxonomy_term_load($term->tid); // dsm($term, "term"); $children = taxonomy_get_children($term->tid, $vid); diff --git a/materio_taxonomy.module b/materio_taxonomy.module index 07a7a404..2e5a987d 100755 --- a/materio_taxonomy.module +++ b/materio_taxonomy.module @@ -1,4 +1,4 @@ - t('access taxonomy terms page'), 'description' => t(''), ); - + return $perms; } @@ -26,4 +26,52 @@ function materio_taxonomy_menu_alter(&$items) { $items['taxonomy/term/%taxonomy_term']['access arguments'] = array('access taxonomy terms page'); $items['taxonomy/term/%taxonomy_term/view']['access arguments'] = array('access taxonomy terms page'); $items['taxonomy/term/%taxonomy_term/feed']['access arguments'] = array('access taxonomy terms page'); +} + + + +/** + * Implementation of hook_query_term_access_alter(). + * + * debug de i18n_select_query_term_access_alter() + * qui filtre les terms par language mm pour les vocabulaires en mode localized. + * utile pour la recherche avancée de materio_search_api materio_search_api_advanced_search_form() + * + */ +function materio_taxonomy_query_term_access_alter(QueryAlterableInterface $query) { + // dsm($query, 'materio taxo query'); + $conditions =& $query->conditions(); + + # roll over condition first time to determine i18n_voc_mode + $i18n_voc_mode = 0; + foreach ($conditions as $condition) { + if (is_array($condition)) { + // dsm($condition, 'conditon '.$condition['field']); + if($condition['field'] == 't.vid'){ + $vid = $condition['value']; + $i18n_voc_mode = i18n_taxonomy_vocabulary_mode($vid); + // dsm($i18n_voc_mode, 'i18n_voc_mode'); + } + } + } + + # roll over conditions a second time to re-alter/fixe language selection + # i18n vocabulary mode is 1 for localized terms + if($i18n_voc_mode == 1){ + foreach ($conditions as $index => $condition) { + if (is_array($condition)) { + // dsm($condition, 'conditon '.$condition['field']); + if($condition['field'] == 't.language' && $i18n_voc_mode == 1){ + $l = array('und'); + $ll = i18n_language_list(); + // dsm($ll, 'list language'); + foreach ($ll as $langcode => $langname) { + $l[] = $langcode; + } + $conditions[$index]['value'] = $l; + } + } + } + } + } \ No newline at end of file