Created
March 23, 2011 22:01
-
-
Save boombatower/884118 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 03fecfb85c930b820f6b52753362263c19616a27 | |
Author: Jimmy Berry <jimmy@boombatower.com> | |
Date: Fri Feb 25 17:03:15 2011 -0600 | |
Provide group_by functionality in base field_handler. | |
diff --git handlers/views_handler_field.inc handlers/views_handler_field.inc | |
index bae45fc..c237e20 100644 | |
--- handlers/views_handler_field.inc | |
+++ handlers/views_handler_field.inc | |
@@ -61,7 +61,8 @@ class views_handler_field extends views_handler { | |
function query() { | |
$this->ensure_my_table(); | |
// Add the field. | |
- $this->field_alias = $this->query->add_field($this->table_alias, $this->real_field); | |
+ $params = $this->options['group_type'] != 'group' ? array('function' => $this->options['group_type']) : array(); | |
+ $this->field_alias = $this->query->add_field($this->table_alias, $this->real_field, NULL, $params); | |
$this->add_additional_fields(); | |
} | |
@@ -121,7 +122,8 @@ class views_handler_field extends views_handler { | |
if (isset($this->field_alias)) { | |
// Since fields should always have themselves already added, just | |
// add a sort on the field. | |
- $this->query->add_orderby(NULL, NULL, $order, $this->field_alias); | |
+ $params = $this->options['group_type'] != 'group' ? array('function' => $this->options['group_type']) : array(); | |
+ $this->query->add_orderby(NULL, NULL, $order, $this->field_alias, $params); | |
} | |
} | |
@@ -1196,6 +1198,10 @@ If you would like to have the characters %5B and %5D please use the html entity | |
return $themes; | |
} | |
+ | |
+ function ui_name($short = FALSE) { | |
+ return $this->get_field(parent::ui_name($short)); | |
+ } | |
} | |
/** | |
diff --git handlers/views_handler_field_group_by_numeric.inc handlers/views_handler_field_group_by_numeric.inc | |
deleted file mode 100644 | |
index 5f33095..0000000 | |
--- handlers/views_handler_field_group_by_numeric.inc | |
+++ /dev/null | |
@@ -1,43 +0,0 @@ | |
-<?php | |
- | |
-/** | |
- * Handler for GROUP BY on simple numeric fields. | |
- */ | |
-class views_handler_field_group_by_numeric extends views_handler_field_numeric { | |
- function init(&$view, &$options) { | |
- parent::init($view, $options); | |
- | |
- // Initialize the original handler. | |
- $this->handler = views_get_handler($options['table'], $options['field'], 'field'); | |
- $this->handler->init($view, $options); | |
- } | |
- | |
- /** | |
- * Called to add the field to a query. | |
- */ | |
- function query() { | |
- $this->ensure_my_table(); | |
- // Add the field, taking care of any aggregation that may affect it. | |
- $params = array( | |
- 'function' => $this->options['group_type'], | |
- ); | |
- | |
- $this->field_alias = $this->query->add_field($this->table_alias, $this->real_field, NULL, $params); | |
- $this->add_additional_fields(); | |
- } | |
- | |
- /** | |
- * Called to determine what to tell the clicksorter. | |
- */ | |
- function click_sort($order) { | |
- $params = array( | |
- 'function' => $this->options['group_type'], | |
- ); | |
- | |
- $this->query->add_orderby($this->table, $this->field, $order, $this->field_alias, $params); | |
- } | |
- | |
- function ui_name($short = FALSE) { | |
- return $this->get_field(parent::ui_name($short)); | |
- } | |
-} | |
diff --git plugins/views_plugin_query_default.inc plugins/views_plugin_query_default.inc | |
index 5a46bc8..3da4d60 100644 | |
--- plugins/views_plugin_query_default.inc | |
+++ plugins/views_plugin_query_default.inc | |
@@ -1362,7 +1362,7 @@ class views_plugin_query_default extends views_plugin_query { | |
'method' => 'views_query_default_aggregation_method_simple', | |
'handler' => array( | |
'argument' => 'views_handler_argument_group_by_numeric', | |
- 'field' => 'views_handler_field_group_by_numeric', | |
+ 'field' => 'views_handler_field_numeric', | |
'filter' => 'views_handler_filter_group_by_numeric', | |
'sort' => 'views_handler_sort_group_by_numeric', | |
), | |
@@ -1372,7 +1372,6 @@ class views_plugin_query_default extends views_plugin_query { | |
'method' => 'views_query_default_aggregation_method_simple', | |
'handler' => array( | |
'argument' => 'views_handler_argument_group_by_numeric', | |
- 'field' => 'views_handler_field_group_by_numeric', | |
'filter' => 'views_handler_filter_group_by_numeric', | |
'sort' => 'views_handler_sort_group_by_numeric', | |
), | |
@@ -1382,7 +1381,6 @@ class views_plugin_query_default extends views_plugin_query { | |
'method' => 'views_query_default_aggregation_method_simple', | |
'handler' => array( | |
'argument' => 'views_handler_argument_group_by_numeric', | |
- 'field' => 'views_handler_field_group_by_numeric', | |
'filter' => 'views_handler_filter_group_by_numeric', | |
'sort' => 'views_handler_sort_group_by_numeric', | |
), | |
@@ -1392,7 +1390,6 @@ class views_plugin_query_default extends views_plugin_query { | |
'method' => 'views_query_default_aggregation_method_simple', | |
'handler' => array( | |
'argument' => 'views_handler_argument_group_by_numeric', | |
- 'field' => 'views_handler_field_group_by_numeric', | |
'filter' => 'views_handler_filter_group_by_numeric', | |
'sort' => 'views_handler_sort_group_by_numeric', | |
), | |
@@ -1402,7 +1399,6 @@ class views_plugin_query_default extends views_plugin_query { | |
'method' => 'views_query_default_aggregation_method_simple', | |
'handler' => array( | |
'argument' => 'views_handler_argument_group_by_numeric', | |
- 'field' => 'views_handler_field_group_by_numeric', | |
'filter' => 'views_handler_filter_group_by_numeric', | |
'sort' => 'views_handler_sort_group_by_numeric', | |
), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment