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