bugfixe : i18n was filtrering to much terms with taxonomy_get_tree
fixed in materio_taxonomy module with query alter
This commit is contained in:
parent
8f54fcd944
commit
0bba2d0657
@ -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);
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Implements hook_permission().
|
||||
@ -18,7 +18,7 @@ function materio_taxonomy_permission() {
|
||||
'title' => 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user