Project

General

Profile

Paste
Download (1.38 KB) Statistics
| Branch: | Revision:

root / drupal7 / sites / all / modules / webform / views / webform_handler_field_webform_status.inc @ 01f36513

1
<?php
2

    
3
/**
4
 * Views handler to display the open or closed status of a webform.
5
 */
6
class webform_handler_field_webform_status extends views_handler_field_boolean {
7

    
8
  /**
9
   *
10
   */
11
  public function options_form(&$form, &$form_state) {
12
    parent::options_form($form, $form_state);
13
    $form['type']['#options'] = array('open-closed' => t('Open/Closed')) + $form['type']['#options'];
14
  }
15

    
16
  /**
17
   *
18
   */
19
  public function option_definition() {
20
    $options = parent::option_definition();
21
    $options['type']['default'] = 'open-closed';
22
    return $options;
23
  }
24

    
25
  /**
26
   *
27
   */
28
  public function render($values) {
29
    $value = $values->{$this->field_alias};
30
    if (!empty($this->options['not'])) {
31
      $value = !$value;
32
    }
33
    switch ($this->options['type']) {
34
      case 'yes-no':
35
        return $value ? t('Yes') : t('No');
36

    
37
      case 'true-false':
38
        return $value ? t('True') : t('False');
39

    
40
      case 'unicode-yes-no':
41
        return $value ? t('✔') : t('✖');
42

    
43
      case 'enabled-disabled':
44
        return $value ? t('Enabled') : t('Disabled');
45

    
46
      case 'boolean':
47
        return $value ? 1 : 0;
48

    
49
      case 'on-off':
50
        return $value ? t('On') : t('Off');
51

    
52
      case 'custom':
53
        return $value ? $this->options['type_custom_true'] : $this->options['type_custom_false'];
54

    
55
      case 'open-closed':
56
      default:
57
        return $value ? t('Open') : t('Closed');
58
    }
59
  }
60

    
61
}