You are here

function _hs_taxonomy_hierarchical_select_terms_to_options in Hierarchical Select 6.3

Same name and namespace in other branches
  1. 5.3 modules/hs_taxonomy.module \_hs_taxonomy_hierarchical_select_terms_to_options()
  2. 7.3 modules/hs_taxonomy.module \_hs_taxonomy_hierarchical_select_terms_to_options()

Transform an array of terms into an associative array of options, for use in a select form item.

Parameters

$terms: An array of term objects.

Return value

An associative array of options, keys are tids, values are term names.

4 calls to _hs_taxonomy_hierarchical_select_terms_to_options()
hs_content_taxonomy_hierarchical_select_children in modules/hs_content_taxonomy.module
Implementation of hook_hierarchical_select_children().
hs_content_taxonomy_hierarchical_select_root_level in modules/hs_content_taxonomy.module
Implementation of hook_hierarchical_select_root_level().
hs_taxonomy_hierarchical_select_children in modules/hs_taxonomy.module
Implementation of hook_hierarchical_select_children().
hs_taxonomy_hierarchical_select_root_level in modules/hs_taxonomy.module
Implementation of hook_hierarchical_select_root_level().

File

modules/hs_taxonomy.module, line 865
Implementation of the Hierarchical Select API for the Taxonomy module.

Code

function _hs_taxonomy_hierarchical_select_terms_to_options($terms) {
  $options = array();
  foreach ($terms as $key => $term) {

    // Use the translated term when available!
    if (module_exists('i18ntaxonomy') && isset($term->vid) && i18ntaxonomy_vocabulary($term->vid) == I18N_TAXONOMY_LOCALIZE) {
      $options[$term->tid] = tt("taxonomy:term:{$term->tid}:name", $term->name);
    }
    else {
      $options[$term->tid] = t($term->name);
    }
  }
  return $options;
}