1 | <?php |
---|
2 | |
---|
3 | /** |
---|
4 | * Handler for GROUP BY on simple numeric fields. |
---|
5 | */ |
---|
6 | class views_handler_field_group_by_numeric extends views_handler_field_numeric { |
---|
7 | function init(&$view, $options) { |
---|
8 | parent::init($view, $options); |
---|
9 | |
---|
10 | // Initialize the original handler. |
---|
11 | $this->handler = views_get_handler($options['table'], $options['field'], 'field'); |
---|
12 | $this->handler->init($view, $options); |
---|
13 | } |
---|
14 | |
---|
15 | /** |
---|
16 | * Called to add the field to a query. |
---|
17 | */ |
---|
18 | function query() { |
---|
19 | $this->ensure_my_table(); |
---|
20 | // Add the field, taking care of any aggregation that may affect it. |
---|
21 | $params = array( |
---|
22 | 'function' => $this->options['group_type'], |
---|
23 | ); |
---|
24 | |
---|
25 | $this->field_alias = $this->query->add_field($this->table_alias, $this->real_field, NULL, $params); |
---|
26 | $this->add_additional_fields(); |
---|
27 | } |
---|
28 | |
---|
29 | /** |
---|
30 | * Called to determine what to tell the clicksorter. |
---|
31 | */ |
---|
32 | function click_sort($order) { |
---|
33 | $params = array( |
---|
34 | 'function' => $this->options['group_type'], |
---|
35 | ); |
---|
36 | |
---|
37 | $this->query->add_orderby($this->table, $this->field, $order, $this->field_alias, $params); |
---|
38 | } |
---|
39 | |
---|
40 | function ui_name($short = FALSE) { |
---|
41 | return $this->get_field(parent::ui_name($short)); |
---|
42 | } |
---|
43 | } |
---|