You are here

function _term_reference_tree_taxonomy_resolve_labels in Taxonomy Term Reference Tree Widget 7

Resolves the label to use in the widget for the given taxonomy terms.

Parameters

array $terms: The array of taxonomy terms.

1 call to _term_reference_tree_taxonomy_resolve_labels()
term_reference_tree_process_checkbox_tree in ./term_reference_tree.widget.inc
Process the checkbox_tree widget.

File

./term_reference_tree.module, line 200

Code

function _term_reference_tree_taxonomy_resolve_labels($terms, $token_display) {
  if (!empty($token_display) && module_exists('token')) {
    $loaded = entity_load('taxonomy_term', array_keys($terms));
    foreach ($loaded as $term) {
      $terms[$term->tid]->term_reference_tree_token = token_replace($token_display, array(
        'term' => $term,
      ), array(
        'clear' => TRUE,
      ));
    }
  }
  elseif (module_exists('locale')) {
    $to_resolve = array();
    foreach ($terms as $term) {
      if (!isset($term->term_reference_tree_label)) {
        $to_resolve[$term->tid] = $term->tid;
      }
    }
    $loaded = entity_load('taxonomy_term', array_keys($to_resolve));
    foreach ($loaded as $term) {
      $terms[$term->tid]->term_reference_tree_label = entity_label('taxonomy_term', $term);
    }
  }
}