1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Views area handlers.
|
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 |
|
|
* Overrides views_handler::init().
|
24 |
|
|
*
|
25 |
|
|
* Make sure that no result area handlers are set to be shown when the result
|
26 |
|
|
* is empty.
|
27 |
|
|
*/
|
28 |
|
|
function init(&$view, &$options) {
|
29 |
|
|
parent::init($view, $options);
|
30 |
|
|
if ($this->handler_type == 'empty') {
|
31 |
|
|
$this->options['empty'] = TRUE;
|
32 |
|
|
}
|
33 |
|
|
}
|
34 |
|
|
|
35 |
|
|
/**
|
36 |
|
|
* Get this field's label.
|
37 |
|
|
*/
|
38 |
|
|
function label() {
|
39 |
|
|
if (!isset($this->options['label'])) {
|
40 |
|
|
return $this->ui_name();
|
41 |
|
|
}
|
42 |
|
|
return $this->options['label'];
|
43 |
|
|
}
|
44 |
|
|
|
45 |
|
|
function option_definition() {
|
46 |
|
|
$options = parent::option_definition();
|
47 |
|
|
|
48 |
|
|
$this->definition['field'] = !empty($this->definition['field']) ? $this->definition['field'] : '';
|
49 |
|
|
$label = !empty($this->definition['label']) ? $this->definition['label'] : $this->definition['field'];
|
50 |
|
|
$options['label'] = array('default' => $label, 'translatable' => TRUE);
|
51 |
|
|
$options['empty'] = array('default' => FALSE, 'bool' => TRUE);
|
52 |
|
|
|
53 |
|
|
return $options;
|
54 |
|
|
}
|
55 |
|
|
|
56 |
|
|
/**
|
57 |
|
|
* Provide extra data to the administration form
|
58 |
|
|
*/
|
59 |
|
|
function admin_summary() {
|
60 |
|
|
return $this->label();
|
61 |
|
|
}
|
62 |
|
|
|
63 |
|
|
/**
|
64 |
|
|
* Default options form that provides the label widget that all fields
|
65 |
|
|
* should have.
|
66 |
|
|
*/
|
67 |
|
|
function options_form(&$form, &$form_state) {
|
68 |
|
|
parent::options_form($form, $form_state);
|
69 |
|
|
$form['label'] = array(
|
70 |
|
|
'#type' => 'textfield',
|
71 |
|
|
'#title' => t('Label'),
|
72 |
|
|
'#default_value' => isset($this->options['label']) ? $this->options['label'] : '',
|
73 |
|
|
'#description' => t('The label for this area that will be displayed only administratively.'),
|
74 |
|
|
);
|
75 |
|
|
|
76 |
|
|
if ($form_state['type'] != 'empty') {
|
77 |
|
|
$form['empty'] = array(
|
78 |
|
|
'#type' => 'checkbox',
|
79 |
|
|
'#title' => t('Display even if view has no result'),
|
80 |
|
|
'#default_value' => isset($this->options['empty']) ? $this->options['empty'] : 0,
|
81 |
|
|
);
|
82 |
|
|
}
|
83 |
|
|
}
|
84 |
|
|
|
85 |
|
|
/**
|
86 |
|
|
* Don't run a query
|
87 |
|
|
*/
|
88 |
|
|
function query() { }
|
89 |
|
|
|
90 |
|
|
/**
|
91 |
|
|
* Render the area
|
92 |
|
|
*/
|
93 |
|
|
function render($empty = FALSE) {
|
94 |
|
|
return '';
|
95 |
|
|
}
|
96 |
|
|
|
97 |
|
|
/**
|
98 |
|
|
* Area handlers shouldn't have groupby.
|
99 |
|
|
*/
|
100 |
|
|
function use_group_by() {
|
101 |
|
|
return FALSE;
|
102 |
|
|
}
|
103 |
|
|
}
|
104 |
|
|
|
105 |
|
|
/**
|
106 |
|
|
* A special handler to take the place of missing or broken handlers.
|
107 |
|
|
*
|
108 |
|
|
* @ingroup views_area_handlers
|
109 |
|
|
*/
|
110 |
|
|
class views_handler_area_broken extends views_handler_area {
|
111 |
|
|
function ui_name($short = FALSE) {
|
112 |
|
|
return t('Broken/missing handler');
|
113 |
|
|
}
|
114 |
|
|
|
115 |
|
|
function ensure_my_table() { /* No table to ensure! */ }
|
116 |
|
|
function query($group_by = FALSE) { /* No query to run */ }
|
117 |
|
|
function render($empty = FALSE) { return ''; }
|
118 |
|
|
function options_form(&$form, &$form_state) {
|
119 |
|
|
$form['markup'] = array(
|
120 |
|
|
'#prefix' => '<div class="form-item description">',
|
121 |
|
|
'#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.'),
|
122 |
|
|
);
|
123 |
|
|
}
|
124 |
|
|
|
125 |
|
|
/**
|
126 |
|
|
* Determine if the handler is considered 'broken'
|
127 |
|
|
*/
|
128 |
|
|
function broken() { return TRUE; }
|
129 |
|
|
}
|
130 |
|
|
|
131 |
|
|
/**
|
132 |
|
|
* @}
|
133 |
|
|
*/ |