#1094712 by dereine: Replace locale_language_list with views version of the function...
[project/views.git] / modules / translation / views_handler_field_node_language.inc
1 <?php
2
3 /**
4 * Field handler to translate a language into its readable form.
5 */
6 class views_handler_field_node_language extends views_handler_field_node {
7 function option_definition() {
8 $options = parent::option_definition();
9 $options['native_language'] = array('default' => FALSE);
10
11 return $options;
12 }
13
14 function options_form(&$form, &$form_state) {
15 parent::options_form($form, $form_state);
16 $form['native_language'] = array(
17 '#title' => t('Native language'),
18 '#type' => 'checkbox',
19 '#default_value' => $this->options['native_language'],
20 '#description' => t('If enabled, the native name of the language will be displayed'),
21 );
22 }
23
24 function render($values) {
25 $languages = views_language_list(empty($this->options['native_language']) ? 'name' : 'native');
26 $value = $this->get_value($values);
27 $value = isset($languages[$value]) ? $languages[$value] : '';
28 return $this->render_link($value, $values);
29 }
30 }