You are here

function hs_taxonomy_hierarchical_select_item_get_label in Hierarchical Select 7.3

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

Implements hook_hierarchical_select_item_get_label().

File

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

Code

function hs_taxonomy_hierarchical_select_item_get_label($item, $params) {
  static $labels = array();
  if (!isset($labels[$item])) {
    if ($item === 0 && isset($params['root_term']) && $params['root_term'] === TRUE) {
      $term = new StdClass();
      $term->name = '<' . t('root') . '>';
    }
    else {
      $term = taxonomy_term_load($item);

      // Try to translate the label if the i18n module is available.
      if (module_exists('i18n_taxonomy')) {
        $term->name = i18n_taxonomy_term_name($term);
      }
    }
    $labels[$item] = $term->name;
  }
  return $labels[$item];
}