You are here

function i18n_taxonomy_allowed_values in Internationalization 7

Returns the set of valid terms for a taxonomy field.

Parameters

$field: The field definition.

Return value

The array of valid terms for this field, keyed by term id.

8 string references to 'i18n_taxonomy_allowed_values'
i18nTaxonomyTestCase::testTaxonomyFieldCallback in i18n_taxonomy/i18n_taxonomy.test
Tests the implementation of 'options_list_callback' for term reference fields. Enable and disable the callback properly. Avoid WSOD!
i18n_taxonomy_disable in i18n_taxonomy/i18n_taxonomy.install
Implements hook_disable()
i18n_taxonomy_field_info_alter in i18n_taxonomy/i18n_taxonomy.module
Implements hook_field_info_alter()
i18n_taxonomy_field_prepare_translation in i18n_taxonomy/i18n_taxonomy.module
Prepare and synchronize translation for term reference fields
i18n_taxonomy_field_storage_details_alter in i18n_taxonomy/i18n_taxonomy.module
Implements hook_field_storage_details_alter().

... See full list

File

i18n_taxonomy/i18n_taxonomy.module, line 379
i18n taxonomy module

Code

function i18n_taxonomy_allowed_values($field) {
  global $language;
  $options = array();
  foreach ($field['settings']['allowed_values'] as $tree) {
    if ($vocabulary = taxonomy_vocabulary_machine_name_load($tree['vocabulary'])) {
      if (i18n_taxonomy_vocabulary_mode($vocabulary->vid) == I18N_MODE_TRANSLATE) {
        $parent = i18n_taxonomy_translation_term_tid($tree['parent'], NULL, $tree['parent']);
        $context_language = i18n_language_context();
        $terms = i18n_taxonomy_get_tree($vocabulary->vid, $context_language->language, $parent);
      }
      else {
        $terms = taxonomy_get_tree($vocabulary->vid, $tree['parent']);
      }
      if ($terms) {
        foreach ($terms as $term) {
          $options[$term->tid] = str_repeat('-', $term->depth) . i18n_taxonomy_term_name($term);
        }
      }
    }
  }
  return $options;
}