You are here

function i18ntaxonomy_views_handler_field_allterms in Internationalization 5.2

Same name and namespace in other branches
  1. 5.3 contrib/i18ntaxonomy.module \i18ntaxonomy_views_handler_field_allterms()
  2. 5 contrib/i18ntaxonomy.module \i18ntaxonomy_views_handler_field_allterms()

Field handler for taxonomy term fields

Remake of views_handler_field_allterms with term name translation

1 string reference to 'i18ntaxonomy_views_handler_field_allterms'
i18ntaxonomy_views_pre_view in contrib/i18ntaxonomy.module
Implementation of hook_views_pre_view().

File

contrib/i18ntaxonomy.module, line 151
Internationalization (i18n) package - taxonomy term translation

Code

function i18ntaxonomy_views_handler_field_allterms($fieldinfo, $fielddata, $value, $data) {
  if ($fieldinfo['vocabulary']) {
    $terms = taxonomy_node_get_terms_by_vocabulary($data->nid, $fieldinfo['vocabulary']);
  }
  else {
    $terms = taxonomy_node_get_terms($data->nid);
  }

  // Translate all these terms
  _i18ntaxonomy_translate_terms($terms);
  if ($fielddata['options'] == 'nolink') {
    foreach ($terms as $term) {
      $links[] = check_plain($term->name);
    }
    $links = !empty($links) ? implode(' | ', $links) : '';
  }
  else {
    $node = new stdClass();
    $node->taxonomy = $terms;
    $links = theme('links', taxonomy_link('taxonomy terms', $node));
  }
  return $links;
}