1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Views handler to display the open or closed status of a webform.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
*
|
10
|
*/
|
11
|
class webform_handler_field_webform_status extends views_handler_field_boolean {
|
12
|
|
13
|
/**
|
14
|
*
|
15
|
*/
|
16
|
public function options_form(&$form, &$form_state) {
|
17
|
parent::options_form($form, $form_state);
|
18
|
$form['type']['#options'] = array('open-closed' => t('Open/Closed')) + $form['type']['#options'];
|
19
|
}
|
20
|
|
21
|
/**
|
22
|
*
|
23
|
*/
|
24
|
public function option_definition() {
|
25
|
$options = parent::option_definition();
|
26
|
$options['type']['default'] = 'open-closed';
|
27
|
return $options;
|
28
|
}
|
29
|
|
30
|
/**
|
31
|
*
|
32
|
*/
|
33
|
public function render($values) {
|
34
|
$value = $values->{$this->field_alias};
|
35
|
if (!empty($this->options['not'])) {
|
36
|
$value = !$value;
|
37
|
}
|
38
|
switch ($this->options['type']) {
|
39
|
case 'yes-no':
|
40
|
return $value ? t('Yes') : t('No');
|
41
|
|
42
|
case 'true-false':
|
43
|
return $value ? t('True') : t('False');
|
44
|
|
45
|
case 'unicode-yes-no':
|
46
|
return $value ? t('✔') : t('✖');
|
47
|
|
48
|
case 'enabled-disabled':
|
49
|
return $value ? t('Enabled') : t('Disabled');
|
50
|
|
51
|
case 'boolean':
|
52
|
return $value ? 1 : 0;
|
53
|
|
54
|
case 'on-off':
|
55
|
return $value ? t('On') : t('Off');
|
56
|
|
57
|
case 'custom':
|
58
|
return $value ? $this->options['type_custom_true'] : $this->options['type_custom_false'];
|
59
|
|
60
|
case 'open-closed':
|
61
|
default:
|
62
|
return $value ? t('Open') : t('Closed');
|
63
|
}
|
64
|
}
|
65
|
|
66
|
}
|