1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
5d12d676
|
Assos Assos
|
* Definition of views_handler_area and views_handler_area_broken.
|
6 |
85ad3d82
|
Assos Assos
|
*/
|
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 |
5d12d676
|
Assos Assos
|
* {@inheritdoc}
|
24 |
85ad3d82
|
Assos Assos
|
*/
|
25 |
5d12d676
|
Assos Assos
|
public function init(&$view, &$options) {
|
26 |
85ad3d82
|
Assos Assos
|
parent::init($view, $options);
|
27 |
5d12d676
|
Assos Assos
|
// Make sure that no result area handlers are set to be shown when the
|
28 |
|
|
// result is empty.
|
29 |
85ad3d82
|
Assos Assos
|
if ($this->handler_type == 'empty') {
|
30 |
|
|
$this->options['empty'] = TRUE;
|
31 |
|
|
}
|
32 |
|
|
}
|
33 |
|
|
|
34 |
|
|
/**
|
35 |
5d12d676
|
Assos Assos
|
* {@inheritdoc}
|
36 |
85ad3d82
|
Assos Assos
|
*/
|
37 |
5d12d676
|
Assos Assos
|
public function label() {
|
38 |
85ad3d82
|
Assos Assos
|
if (!isset($this->options['label'])) {
|
39 |
|
|
return $this->ui_name();
|
40 |
|
|
}
|
41 |
|
|
return $this->options['label'];
|
42 |
|
|
}
|
43 |
|
|
|
44 |
5d12d676
|
Assos Assos
|
/**
|
45 |
|
|
* {@inheritdoc}
|
46 |
|
|
*/
|
47 |
|
|
public function option_definition() {
|
48 |
85ad3d82
|
Assos Assos
|
$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 |
5d12d676
|
Assos Assos
|
* Provide extra data to the administration form.
|
60 |
85ad3d82
|
Assos Assos
|
*/
|
61 |
5d12d676
|
Assos Assos
|
public function admin_summary() {
|
62 |
85ad3d82
|
Assos Assos
|
return $this->label();
|
63 |
|
|
}
|
64 |
|
|
|
65 |
|
|
/**
|
66 |
5d12d676
|
Assos Assos
|
* Default options form that provides the label widget that all fields should
|
67 |
|
|
* have.
|
68 |
85ad3d82
|
Assos Assos
|
*/
|
69 |
5d12d676
|
Assos Assos
|
public function options_form(&$form, &$form_state) {
|
70 |
85ad3d82
|
Assos Assos
|
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 |
5d12d676
|
Assos Assos
|
* Don't run a query.
|
89 |
85ad3d82
|
Assos Assos
|
*/
|
90 |
5d12d676
|
Assos Assos
|
public function query() {
|
91 |
|
|
}
|
92 |
85ad3d82
|
Assos Assos
|
|
93 |
|
|
/**
|
94 |
5d12d676
|
Assos Assos
|
* Render the area.
|
95 |
85ad3d82
|
Assos Assos
|
*/
|
96 |
5d12d676
|
Assos Assos
|
public function render($empty = FALSE) {
|
97 |
85ad3d82
|
Assos Assos
|
return '';
|
98 |
|
|
}
|
99 |
|
|
|
100 |
|
|
/**
|
101 |
|
|
* Area handlers shouldn't have groupby.
|
102 |
|
|
*/
|
103 |
5d12d676
|
Assos Assos
|
public function use_group_by() {
|
104 |
85ad3d82
|
Assos Assos
|
return FALSE;
|
105 |
|
|
}
|
106 |
5d12d676
|
Assos Assos
|
|
107 |
85ad3d82
|
Assos Assos
|
}
|
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 |
5d12d676
|
Assos Assos
|
|
116 |
|
|
/**
|
117 |
|
|
* {@inheritdoc}
|
118 |
|
|
*/
|
119 |
|
|
public function ui_name($short = FALSE) {
|
120 |
85ad3d82
|
Assos Assos
|
return t('Broken/missing handler');
|
121 |
|
|
}
|
122 |
|
|
|
123 |
5d12d676
|
Assos Assos
|
/**
|
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 |
85ad3d82
|
Assos Assos
|
$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 |
5d12d676
|
Assos Assos
|
* {@inheritdoc}
|
156 |
85ad3d82
|
Assos Assos
|
*/
|
157 |
5d12d676
|
Assos Assos
|
public function broken() {
|
158 |
|
|
return TRUE;
|
159 |
|
|
}
|
160 |
|
|
|
161 |
85ad3d82
|
Assos Assos
|
}
|
162 |
|
|
|
163 |
|
|
/**
|
164 |
|
|
* @}
|
165 |
|
|
*/ |