bugfixe : i18n was filtrering to much terms with taxonomy_get_tree

fixed in materio_taxonomy module with query alter
This commit is contained in:
Bachir Soussi Chiadmi 2014-09-16 21:09:06 +08:00
parent 8f54fcd944
commit 0bba2d0657
2 changed files with 53 additions and 4 deletions

View File

@ -708,6 +708,8 @@ function materio_search_api_advanced_search_form($form, &$form_state){
); );
foreach ($vocabularies as $vid) { foreach ($vocabularies as $vid) {
// dsm($vid, "vid");
$voc = taxonomy_vocabulary_load($vid); $voc = taxonomy_vocabulary_load($vid);
// dsm($voc, 'voc'); // dsm($voc, 'voc');
@ -717,14 +719,13 @@ function materio_search_api_advanced_search_form($form, &$form_state){
'#tree' => true, '#tree' => true,
); );
$tree = taxonomy_get_tree($vid, 0, 1); $tree = taxonomy_get_tree($vid, 0, 1, TRUE);
// dsm($tree, 'tree'); // dsm($tree, 'tree');
if(!count($tree)) if(!count($tree))
continue; continue;
foreach ($tree as $term) { foreach ($tree as $term) {
$term = taxonomy_term_load($term->tid);
// dsm($term, "term"); // dsm($term, "term");
$children = taxonomy_get_children($term->tid, $vid); $children = taxonomy_get_children($term->tid, $vid);

View File

@ -27,3 +27,51 @@ function materio_taxonomy_menu_alter(&$items) {
$items['taxonomy/term/%taxonomy_term/view']['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'); $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;
}
}
}
}
}