1 |
85ad3d82
|
Assos Assos
|
<?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 |
feca1e4a
|
Assos Assos
|
/**
|
9 |
|
|
*
|
10 |
|
|
*/
|
11 |
|
|
public function options_form(&$form, &$form_state) {
|
12 |
85ad3d82
|
Assos Assos
|
parent::options_form($form, $form_state);
|
13 |
|
|
$form['type']['#options'] = array('open-closed' => t('Open/Closed')) + $form['type']['#options'];
|
14 |
|
|
}
|
15 |
|
|
|
16 |
feca1e4a
|
Assos Assos
|
/**
|
17 |
|
|
*
|
18 |
|
|
*/
|
19 |
|
|
public function option_definition() {
|
20 |
85ad3d82
|
Assos Assos
|
$options = parent::option_definition();
|
21 |
|
|
$options['type']['default'] = 'open-closed';
|
22 |
|
|
return $options;
|
23 |
|
|
}
|
24 |
|
|
|
25 |
feca1e4a
|
Assos Assos
|
/**
|
26 |
|
|
*
|
27 |
|
|
*/
|
28 |
|
|
public function render($values) {
|
29 |
85ad3d82
|
Assos Assos
|
$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 |
feca1e4a
|
Assos Assos
|
|
37 |
85ad3d82
|
Assos Assos
|
case 'true-false':
|
38 |
|
|
return $value ? t('True') : t('False');
|
39 |
feca1e4a
|
Assos Assos
|
|
40 |
e9984459
|
Assos Assos
|
case 'unicode-yes-no':
|
41 |
|
|
return $value ? t('✔') : t('✖');
|
42 |
feca1e4a
|
Assos Assos
|
|
43 |
e9984459
|
Assos Assos
|
case 'enabled-disabled':
|
44 |
|
|
return $value ? t('Enabled') : t('Disabled');
|
45 |
feca1e4a
|
Assos Assos
|
|
46 |
e9984459
|
Assos Assos
|
case 'boolean':
|
47 |
|
|
return $value ? 1 : 0;
|
48 |
feca1e4a
|
Assos Assos
|
|
49 |
85ad3d82
|
Assos Assos
|
case 'on-off':
|
50 |
|
|
return $value ? t('On') : t('Off');
|
51 |
feca1e4a
|
Assos Assos
|
|
52 |
e9984459
|
Assos Assos
|
case 'custom':
|
53 |
|
|
return $value ? $this->options['type_custom_true'] : $this->options['type_custom_false'];
|
54 |
feca1e4a
|
Assos Assos
|
|
55 |
85ad3d82
|
Assos Assos
|
case 'open-closed':
|
56 |
|
|
default:
|
57 |
|
|
return $value ? t('Open') : t('Closed');
|
58 |
|
|
}
|
59 |
|
|
}
|
60 |
feca1e4a
|
Assos Assos
|
|
61 |
85ad3d82
|
Assos Assos
|
} |