function _global_filter_add_terms in Views Global Filter 7
Same name and namespace in other branches
- 8 global_filter.widgets.inc \_global_filter_add_terms()
- 6 global_filter.module \_global_filter_add_terms()
Add terms to global filter.
2 calls to _global_filter_add_terms()
- global_filter_create_widget in ./
global_filter.widgets.inc - Based on the requested or field-implied widget.
- _global_filter_configure_form in ./
global_filter.blocks.inc - Generates the filter configuration form for filters in a block.
File
- ./
global_filter.widgets.inc, line 572 - global_filter.widgets.inc
Code
function _global_filter_add_terms(&$options, $vocabulary_machine_name, $show_depth = TRUE) {
if (!module_exists('taxonomy')) {
drupal_set_message(t('Global Filter: using vocabulary %vocabulary, but Taxonomy module is not enabled.', array(
'%vocabulary' => $vocabulary_machine_name,
)), 'error');
return;
}
if (!empty($vocabulary_machine_name)) {
foreach (taxonomy_get_vocabularies() as $vid => $vocabulary) {
$found = $vocabulary->machine_name == $vocabulary_machine_name;
if ($found) {
break;
}
}
}
if (empty($found)) {
drupal_set_message(t('Global Filter: the vocabulary %vocabulary does not exist.', array(
'%vocabulary' => $vocabulary_machine_name,
)), 'error');
}
else {
foreach (taxonomy_get_tree($vid) as $term) {
$term_name = module_exists('i18n_taxonomy') ? i18n_taxonomy_term_name($term) : $term->name;
// If $show_depth is set, we follow core's way and append one hyphen for
// each hierarchy level.
$options[$term->tid] = $show_depth ? str_repeat('-', $term->depth) . $term_name : $term_name;
}
}
}