Projet

Général

Profil

Paste
Télécharger (1,1 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / views / modules / locale / views_handler_field_locale_language.inc @ 4003efde

1
<?php
2

    
3
/**
4
 * @file
5
 * Contains .
6
 */
7

    
8
/**
9
 * Field handler to translate a language into its readable form.
10
 *
11
 * @ingroup views_field_handlers
12
 */
13
class views_handler_field_locale_language extends views_handler_field {
14

    
15
  /**
16
   * {@inheritdoc}
17
   */
18
  public function option_definition() {
19
    $options = parent::option_definition();
20
    $options['native_language'] = array('default' => FALSE, 'bool' => TRUE);
21

    
22
    return $options;
23
  }
24

    
25
  /**
26
   * {@inheritdoc}
27
   */
28
  public function options_form(&$form, &$form_state) {
29
    parent::options_form($form, $form_state);
30
    $form['native_language'] = array(
31
      '#title' => t('Native language'),
32
      '#type' => 'checkbox',
33
      '#default_value' => $this->options['native_language'],
34
      '#description' => t('If enabled, the native name of the language will be displayed'),
35
    );
36
  }
37

    
38
  /**
39
   * {@inheritdoc}
40
   */
41
  public function render($values) {
42
    $languages = views_language_list(empty($this->options['native_language']) ? 'name' : 'native');
43
    $value = $this->get_value($values);
44
    return isset($languages[$value]) ? $languages[$value] : '';
45
  }
46

    
47
}