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 85ad3d82 Assos Assos
<?php
2
3
/**
4
 * @file
5 5d12d676 Assos Assos
 * Contains .
6 85ad3d82 Assos Assos
 */
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 5d12d676 Assos Assos
15
  /**
16
   * {@inheritdoc}
17
   */
18
  public function option_definition() {
19 85ad3d82 Assos Assos
    $options = parent::option_definition();
20
    $options['native_language'] = array('default' => FALSE, 'bool' => TRUE);
21
22
    return $options;
23
  }
24
25 5d12d676 Assos Assos
  /**
26
   * {@inheritdoc}
27
   */
28
  public function options_form(&$form, &$form_state) {
29 85ad3d82 Assos Assos
    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 5d12d676 Assos Assos
  /**
39
   * {@inheritdoc}
40
   */
41
  public function render($values) {
42 4003efde Assos Assos
    $languages = views_language_list(empty($this->options['native_language']) ? 'name' : 'native');
43 85ad3d82 Assos Assos
    $value = $this->get_value($values);
44
    return isset($languages[$value]) ? $languages[$value] : '';
45
  }
46 5d12d676 Assos Assos
47 85ad3d82 Assos Assos
}