1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Definition of views_handler_area and views_handler_area_broken.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* @defgroup views_area_handlers Views area handlers
|
10
|
* @{
|
11
|
* Handlers to tell Views what can display in header, footer
|
12
|
* and empty text in a view.
|
13
|
*/
|
14
|
|
15
|
/**
|
16
|
* Base class for area handlers.
|
17
|
*
|
18
|
* @ingroup views_area_handlers
|
19
|
*/
|
20
|
class views_handler_area extends views_handler {
|
21
|
|
22
|
/**
|
23
|
* {@inheritdoc}
|
24
|
*/
|
25
|
public function init(&$view, &$options) {
|
26
|
parent::init($view, $options);
|
27
|
// Make sure that no result area handlers are set to be shown when the
|
28
|
// result is empty.
|
29
|
if ($this->handler_type == 'empty') {
|
30
|
$this->options['empty'] = TRUE;
|
31
|
}
|
32
|
}
|
33
|
|
34
|
/**
|
35
|
* {@inheritdoc}
|
36
|
*/
|
37
|
public function label() {
|
38
|
if (!isset($this->options['label'])) {
|
39
|
return $this->ui_name();
|
40
|
}
|
41
|
return $this->options['label'];
|
42
|
}
|
43
|
|
44
|
/**
|
45
|
* {@inheritdoc}
|
46
|
*/
|
47
|
public function option_definition() {
|
48
|
$options = parent::option_definition();
|
49
|
|
50
|
$this->definition['field'] = !empty($this->definition['field']) ? $this->definition['field'] : '';
|
51
|
$label = !empty($this->definition['label']) ? $this->definition['label'] : $this->definition['field'];
|
52
|
$options['label'] = array('default' => $label, 'translatable' => TRUE);
|
53
|
$options['empty'] = array('default' => FALSE, 'bool' => TRUE);
|
54
|
|
55
|
return $options;
|
56
|
}
|
57
|
|
58
|
/**
|
59
|
* Provide extra data to the administration form.
|
60
|
*/
|
61
|
public function admin_summary() {
|
62
|
return $this->label();
|
63
|
}
|
64
|
|
65
|
/**
|
66
|
* Default options form that provides the label widget that all fields should
|
67
|
* have.
|
68
|
*/
|
69
|
public function options_form(&$form, &$form_state) {
|
70
|
parent::options_form($form, $form_state);
|
71
|
$form['label'] = array(
|
72
|
'#type' => 'textfield',
|
73
|
'#title' => t('Label'),
|
74
|
'#default_value' => isset($this->options['label']) ? $this->options['label'] : '',
|
75
|
'#description' => t('The label for this area that will be displayed only administratively.'),
|
76
|
);
|
77
|
|
78
|
if ($form_state['type'] != 'empty') {
|
79
|
$form['empty'] = array(
|
80
|
'#type' => 'checkbox',
|
81
|
'#title' => t('Display even if view has no result'),
|
82
|
'#default_value' => isset($this->options['empty']) ? $this->options['empty'] : 0,
|
83
|
);
|
84
|
}
|
85
|
}
|
86
|
|
87
|
/**
|
88
|
* Don't run a query.
|
89
|
*/
|
90
|
public function query() {
|
91
|
}
|
92
|
|
93
|
/**
|
94
|
* Render the area.
|
95
|
*/
|
96
|
public function render($empty = FALSE) {
|
97
|
return '';
|
98
|
}
|
99
|
|
100
|
/**
|
101
|
* Area handlers shouldn't have groupby.
|
102
|
*/
|
103
|
public function use_group_by() {
|
104
|
return FALSE;
|
105
|
}
|
106
|
|
107
|
}
|
108
|
|
109
|
/**
|
110
|
* A special handler to take the place of missing or broken handlers.
|
111
|
*
|
112
|
* @ingroup views_area_handlers
|
113
|
*/
|
114
|
class views_handler_area_broken extends views_handler_area {
|
115
|
|
116
|
/**
|
117
|
* {@inheritdoc}
|
118
|
*/
|
119
|
public function ui_name($short = FALSE) {
|
120
|
return t('Broken/missing handler');
|
121
|
}
|
122
|
|
123
|
/**
|
124
|
* {@inheritdoc}
|
125
|
*/
|
126
|
public function ensure_my_table() {
|
127
|
// No table to ensure!
|
128
|
}
|
129
|
|
130
|
/**
|
131
|
* {@inheritdoc}
|
132
|
*/
|
133
|
public function query($group_by = FALSE) {
|
134
|
// No query to run.
|
135
|
}
|
136
|
|
137
|
/**
|
138
|
* {@inheritdoc}
|
139
|
*/
|
140
|
public function render($empty = FALSE) {
|
141
|
return '';
|
142
|
}
|
143
|
|
144
|
/**
|
145
|
* {@inheritdoc}
|
146
|
*/
|
147
|
public function options_form(&$form, &$form_state) {
|
148
|
$form['markup'] = array(
|
149
|
'#prefix' => '<div class="form-item description">',
|
150
|
'#value' => t('The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.'),
|
151
|
);
|
152
|
}
|
153
|
|
154
|
/**
|
155
|
* {@inheritdoc}
|
156
|
*/
|
157
|
public function broken() {
|
158
|
return TRUE;
|
159
|
}
|
160
|
|
161
|
}
|
162
|
|
163
|
/**
|
164
|
* @}
|
165
|
*/
|