summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEarl Miles2009-12-24 01:02:03 (GMT)
committer Earl Miles2009-12-24 01:02:03 (GMT)
commit3e2ac7eb9db62b99554c66de3d22aeebcaf73e8e (patch)
tree04ecc0355da3786b30c30bcc9ede1453391f888a
parentaf74c7ab60b5979e68bbad74c94a685de5cb999a (diff)
#387748 by recrit: Allow summaries to be ordered by number of records.
-rw-r--r--CHANGELOG.txt1
-rw-r--r--handlers/views_handler_argument.inc22
2 files changed, 19 insertions, 4 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 71d4ba8..8947481 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -69,6 +69,7 @@ Views 6.x-3.x-dev
o #629840 by fuerst: Search filter caused bad query on PostgreSQL.
o #593668 by neochief: Allow changing of the display ID.
o #600242 by pcambra: Allow "search" filter as an argument.
+ o #387748 by recrit: Allow summaries to be ordered by number of records.
Views 6.x-3.0-alpha1
Bugs fixed
diff --git a/handlers/views_handler_argument.inc b/handlers/views_handler_argument.inc
index 2a71038..b6a61b3 100644
--- a/handlers/views_handler_argument.inc
+++ b/handlers/views_handler_argument.inc
@@ -336,6 +336,20 @@ class views_handler_argument extends views_handler {
'style plugin' => TRUE,
'breadcrumb' => TRUE, // generate a breadcrumb to here
),
+ 'summary asc by count' => array(
+ 'title' => t('Summary, sorted by number of records ascending'),
+ 'method' => 'default_summary',
+ 'method args' => array('asc', 'num_records'),
+ 'style plugin' => TRUE,
+ 'breadcrumb' => TRUE, // generate a breadcrumb to here
+ ),
+ 'summary desc by count' => array(
+ 'title' => t('Summary, sorted by number of records descending'),
+ 'method' => 'default_summary',
+ 'method args' => array('desc', 'num_records'),
+ 'style plugin' => TRUE,
+ 'breadcrumb' => TRUE, // generate a breadcrumb to here
+ ),
'default' => array(
'title' => t('Provide default argument'),
'method' => 'default_default',
@@ -517,7 +531,7 @@ class views_handler_argument extends views_handler {
* If an argument was expected and was not given, in this case, display
* a summary query.
*/
- function default_summary($order) {
+ function default_summary($order, $by = NULL) {
$this->view->build_info['summary'] = TRUE;
$this->view->build_info['summary_level'] = $this->options['id'];
@@ -531,7 +545,7 @@ class views_handler_argument extends views_handler {
$this->query->clear_fields();
$this->summary_query();
- $this->summary_sort($order);
+ $this->summary_sort($order, $by);
// Summaries have their own sorting and fields, so tell the View not
// to build these.
@@ -622,8 +636,8 @@ class views_handler_argument extends views_handler {
* @param $order
* The order selected in the UI.
*/
- function summary_sort($order) {
- $this->query->add_orderby(NULL, NULL, $order, $this->name_alias);
+ function summary_sort($order, $by = NULL) {
+ $this->query->add_orderby(NULL, NULL, $order, (!empty($by) ? $by : $this->name_alias));
}
/**