Projet

Général

Profil

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

root / drupal7 / sites / all / modules / views / modules / field / views_handler_filter_field_list_boolean.inc @ 5d12d676

1
<?php
2

    
3
/**
4
 * @file
5
 * Definition of views_handler_filter_field_list_boolean.
6
 */
7

    
8
/**
9
 * Filter handler for boolean fields.
10
 *
11
 * @ingroup views_filter_handlers
12
 */
13
class views_handler_filter_field_list_boolean extends views_handler_filter_field_list {
14

    
15
  /**
16
   * {@inheritdoc}
17
   */
18
  public function get_value_options() {
19
    $field = field_info_field($this->definition['field_name']);
20
    $value_options = list_allowed_values($field);
21

    
22
    // Boolean fields have an option for using the label as the 'on' value. This
23
    // results in there being no label values in the allows values array.
24
    // If this is the case, we need to provide the labels.
25
    $filtered = array_filter($value_options);
26
    if (empty($filtered)) {
27
      // We can't provide the label in the same way the FieldAPI formatter does,
28
      // as these are different on each instance, and we may be operating on
29
      // more than one bundle.
30
      $value_options[0] = t('Off');
31
      $value_options[1] = t('On');
32
    }
33

    
34
    $this->value_options = $value_options;
35
  }
36

    
37
}