1 | <?php |
---|
2 | /** |
---|
3 | * @file |
---|
4 | * Views area handlers. |
---|
5 | */ |
---|
6 | |
---|
7 | /** |
---|
8 | * @defgroup views_area_handlers Views' area handlers |
---|
9 | * @{ |
---|
10 | * Handlers to tell Views what can display in header, footer |
---|
11 | * and empty text in a view. |
---|
12 | */ |
---|
13 | |
---|
14 | class views_handler_area extends views_handler { |
---|
15 | /** |
---|
16 | * Get this field's label. |
---|
17 | */ |
---|
18 | function label() { |
---|
19 | if (!isset($this->options['label'])) { |
---|
20 | return $this->ui_name(); |
---|
21 | } |
---|
22 | return $this->options['label']; |
---|
23 | } |
---|
24 | |
---|
25 | function option_definition() { |
---|
26 | $options = parent::option_definition(); |
---|
27 | $label = !empty($this->definition['label']) ? $this->definition['label'] : $this->definition['title']; |
---|
28 | $options['label'] = array('default' => $label, 'translatable' => TRUE); |
---|
29 | $options['empty'] = array('default' => 0, 'bool' => TRUE); |
---|
30 | |
---|
31 | return $options; |
---|
32 | } |
---|
33 | |
---|
34 | /** |
---|
35 | * Provide extra data to the administration form |
---|
36 | */ |
---|
37 | function admin_summary() { |
---|
38 | return $this->label(); |
---|
39 | } |
---|
40 | |
---|
41 | /** |
---|
42 | * Default options form that provides the label widget that all fields |
---|
43 | * should have. |
---|
44 | */ |
---|
45 | function options_form(&$form, &$form_state) { |
---|
46 | parent::options_form($form, $form_state); |
---|
47 | $form['label'] = array( |
---|
48 | '#type' => 'textfield', |
---|
49 | '#title' => t('Label'), |
---|
50 | '#default_value' => isset($this->options['label']) ? $this->options['label'] : '', |
---|
51 | '#description' => t('The label for this area that will be displayed only administratively.'), |
---|
52 | ); |
---|
53 | |
---|
54 | if ($form_state['type'] != 'empty') { |
---|
55 | $form['empty'] = array( |
---|
56 | '#type' => 'checkbox', |
---|
57 | '#title' => t('Display even if view has no result'), |
---|
58 | '#default_value' => isset($this->options['empty']) ? $this->options['empty'] : 0, |
---|
59 | ); |
---|
60 | } |
---|
61 | } |
---|
62 | |
---|
63 | /** |
---|
64 | * Don't run a query |
---|
65 | */ |
---|
66 | function query() { } |
---|
67 | |
---|
68 | /** |
---|
69 | * Render the area |
---|
70 | */ |
---|
71 | function render($empty = FALSE) { |
---|
72 | return ''; |
---|
73 | } |
---|
74 | |
---|
75 | /** |
---|
76 | * Area handlers shouldn't have groupby. |
---|
77 | */ |
---|
78 | function use_group_by() { |
---|
79 | return FALSE; |
---|
80 | } |
---|
81 | } |
---|
82 | |
---|
83 | /** |
---|
84 | * A special handler to take the place of missing or broken handlers. |
---|
85 | * |
---|
86 | * @ingroup views_area_handlers |
---|
87 | */ |
---|
88 | class views_handler_area_broken extends views_handler_area { |
---|
89 | function ui_name($short = FALSE) { |
---|
90 | return t('Broken/missing handler'); |
---|
91 | } |
---|
92 | |
---|
93 | function ensure_my_table() { /* No table to ensure! */ } |
---|
94 | function query() { /* No query to run */ } |
---|
95 | function render($empty = FALSE) { return ''; } |
---|
96 | function options_form(&$form, &$form_state) { |
---|
97 | $form['markup'] = array( |
---|
98 | '#prefix' => '<div class="form-item description">', |
---|
99 | '#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.'), |
---|
100 | ); |
---|
101 | } |
---|
102 | |
---|
103 | /** |
---|
104 | * Determine if the handler is considered 'broken' |
---|
105 | */ |
---|
106 | function broken() { return TRUE; } |
---|
107 | } |
---|
108 | |
---|
109 | /** |
---|
110 | * @} |
---|
111 | */ |
---|