Révision 5d12d676
Ajouté par Assos Assos il y a environ 6 ans
drupal7/sites/all/modules/views/handlers/views_handler_field_boolean.inc | ||
---|---|---|
11 | 11 |
* Allows for display of true/false, yes/no, on/off, enabled/disabled. |
12 | 12 |
* |
13 | 13 |
* Definition terms: |
14 |
* - output formats: An array where the first entry is displayed on boolean true
|
|
15 |
* and the second is displayed on boolean false. An example for sticky is:
|
|
16 |
* @code
|
|
17 |
* 'output formats' => array(
|
|
18 |
* 'sticky' => array(t('Sticky'), ''),
|
|
19 |
* ),
|
|
20 |
* @endcode
|
|
14 |
* - output formats: An array where the first entry is displayed on boolean true |
|
15 |
* and the second is displayed on boolean false. An example for sticky is: |
|
16 |
* @code |
|
17 |
* 'output formats' => array( |
|
18 |
* 'sticky' => array(t('Sticky'), ''), |
|
19 |
* ), |
|
20 |
* @endcode |
|
21 | 21 |
* |
22 | 22 |
* @ingroup views_field_handlers |
23 | 23 |
*/ |
24 | 24 |
class views_handler_field_boolean extends views_handler_field { |
25 |
function option_definition() { |
|
25 |
|
|
26 |
/** |
|
27 |
* {@inheritdoc} |
|
28 |
*/ |
|
29 |
public function option_definition() { |
|
26 | 30 |
$options = parent::option_definition(); |
27 | 31 |
$options['type'] = array('default' => 'yes-no'); |
28 | 32 |
$options['type_custom_true'] = array('default' => '', 'translatable' => TRUE); |
... | ... | |
32 | 36 |
return $options; |
33 | 37 |
} |
34 | 38 |
|
35 |
function init(&$view, &$options) { |
|
39 |
/** |
|
40 |
* {@inheritdoc} |
|
41 |
*/ |
|
42 |
public function init(&$view, &$options) { |
|
36 | 43 |
parent::init($view, $options); |
37 | 44 |
|
38 | 45 |
$default_formats = array( |
... | ... | |
48 | 55 |
$this->formats = array_merge($default_formats, $output_formats, $custom_format); |
49 | 56 |
} |
50 | 57 |
|
51 |
function options_form(&$form, &$form_state) { |
|
58 |
/** |
|
59 |
* {@inheritdoc} |
|
60 |
*/ |
|
61 |
public function options_form(&$form, &$form_state) { |
|
52 | 62 |
foreach ($this->formats as $key => $item) { |
53 | 63 |
$options[$key] = implode('/', $item); |
54 | 64 |
} |
... | ... | |
91 | 101 |
parent::options_form($form, $form_state); |
92 | 102 |
} |
93 | 103 |
|
94 |
function render($values) { |
|
104 |
/** |
|
105 |
* {@inheritdoc} |
|
106 |
*/ |
|
107 |
public function render($values) { |
|
95 | 108 |
$value = $this->get_value($values); |
96 | 109 |
if (!empty($this->options['not'])) { |
97 | 110 |
$value = !$value; |
... | ... | |
100 | 113 |
if ($this->options['type'] == 'custom') { |
101 | 114 |
return $value ? filter_xss_admin($this->options['type_custom_true']) : filter_xss_admin($this->options['type_custom_false']); |
102 | 115 |
} |
103 |
else if (isset($this->formats[$this->options['type']])) {
|
|
116 |
elseif (isset($this->formats[$this->options['type']])) { |
|
104 | 117 |
return $value ? $this->formats[$this->options['type']][0] : $this->formats[$this->options['type']][1]; |
105 | 118 |
} |
106 | 119 |
else { |
107 | 120 |
return $value ? $this->formats['yes-no'][0] : $this->formats['yes-no'][1]; |
108 | 121 |
} |
109 | 122 |
} |
123 |
|
|
110 | 124 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules