Issue #1698460 by dawehner | TolstoyDotCom: Fixed 'No language' substitution.
[project/i18nviews.git] / includes / i18nviews_handler_field_taxonomy_term_name.inc
1 <?php
2
3 /**
4 * Field handler to provide simple renderer that allows linking to a taxonomy
5 * term.
6 */
7 class i18nviews_handler_field_taxonomy_term_name extends views_handler_field_taxonomy {
8
9 /**
10 * Get the value that's supposed to be rendered.
11 *
12 * @param $values
13 * An object containing all retrieved values.
14 * @param $field
15 * Optional name of the field where the value is stored.
16 */
17 function get_value($values, $field = NULL) {
18 $alias = isset($field) ? $this->aliases[$field] : $this->field_alias;
19 $alias_localized = $alias . '_i18n';
20 if (isset($values->{$alias_localized})) {
21 return $values->{$alias_localized};
22 }
23 return parent::get_value($values, $field);
24 }
25
26 /**
27 * Translate the taxonomy term name.
28 *
29 * @param $values
30 */
31 function pre_render(&$values) {
32 foreach ($values as $key => $value) {
33 if (isset($value->{$this->field_alias})) {
34 $term = new stdClass();
35 $term->tid = $this->get_value($value, 'tid');
36 $term->vid = $this->get_value($value, 'vid');
37 $term->name = $this->get_value($value);
38 $values[$key]->{$this->field_alias . '_i18n'} = i18n_taxonomy_term_name($term);
39 }
40 }
41 }
42 }