| 1 |
<?php |
<?php |
| 2 |
// $Id: views_calc_table.inc,v 1.15 2009/04/22 02:21:41 karens Exp $ |
// $Id: views_calc_table.inc,v 1.16 2009/06/13 11:53:20 karens Exp $ |
| 3 |
/** |
/** |
| 4 |
* @file |
* @file |
| 5 |
* Copied from the table style plugin. |
* Copied from the table style plugin. |
| 78 |
*/ |
*/ |
| 79 |
function pre_render($results) { |
function pre_render($results) { |
| 80 |
parent::pre_render($results); |
parent::pre_render($results); |
| 81 |
|
|
| 82 |
// If there are no calc fields, do nothing. |
// If there are no calc fields, do nothing. |
| 83 |
if (!$calc_fields = $this->get_calc_fields()) { |
if (!$calc_fields = $this->get_calc_fields()) { |
| 84 |
return; |
return; |
| 87 |
if (!empty($this->view->views_calc_calculation)) { |
if (!empty($this->view->views_calc_calculation)) { |
| 88 |
return; |
return; |
| 89 |
} |
} |
|
|
|
| 90 |
$this->view->totals = array(); |
$this->view->totals = array(); |
| 91 |
$this->view->sub_totals = array(); |
$this->view->sub_totals = array(); |
| 92 |
|
|
| 101 |
$nids[] = $value->nid; |
$nids[] = $value->nid; |
| 102 |
} |
} |
| 103 |
// Add sub_total rows to the results. |
// Add sub_total rows to the results. |
| 104 |
|
// TODO Looks like we have problems unless we |
| 105 |
|
// force a non-page display, need to keep an eye on this. |
| 106 |
foreach ($calc_fields as $calc => $field) { |
foreach ($calc_fields as $calc => $field) { |
| 107 |
if ($summary_view = views_get_view($this->view->name)) { |
if ($summary_view = views_get_view($this->view->name)) { |
| 108 |
$summary_view->set_display($this->view->current_display); |
//$summary_view->set_display($this->view->current_display); |
| 109 |
$summary_view->set_arguments($this->view->args); |
$summary_view->set_arguments($this->view->args); |
| 110 |
$summary_view->views_calc_calculation = $calc; |
$summary_view->views_calc_calculation = $calc; |
| 111 |
$summary_view->views_calc_nids = $nids; |
$summary_view->views_calc_nids = $nids; |
| 112 |
$summary_view->views_calc_sub_total = TRUE; |
$summary_view->views_calc_sub_total = TRUE; |
| 113 |
$summary_view->is_cacheable = FALSE; |
$summary_view->is_cacheable = FALSE; |
| 114 |
$summary_view->execute(); |
$summary_view->preview(); |
| 115 |
$this->view->sub_totals[] = array_shift($summary_view->result); |
$this->view->sub_totals[] = array_shift($summary_view->result); |
| 116 |
} |
} |
| 117 |
} |
} |
| 120 |
// Add grand totals to the results. |
// Add grand totals to the results. |
| 121 |
foreach ($calc_fields as $calc => $field) { |
foreach ($calc_fields as $calc => $field) { |
| 122 |
if ($summary_view = views_get_view($this->view->name)) { |
if ($summary_view = views_get_view($this->view->name)) { |
| 123 |
$summary_view->set_display($this->view->current_display); |
//$summary_view->set_display($this->view->current_display); |
| 124 |
$summary_view->set_arguments($this->view->args); |
$summary_view->set_arguments($this->view->args); |
| 125 |
$summary_view->pager['items_per_page'] = 0; |
$summary_view->pager['items_per_page'] = 0; |
| 126 |
$summary_view->views_calc_calculation = $calc; |
$summary_view->views_calc_calculation = $calc; |
| 127 |
$summary_view->views_calc_nids = array(); |
$summary_view->views_calc_nids = array(); |
| 128 |
$summary_view->views_calc_sub_total = FALSE; |
$summary_view->views_calc_sub_total = FALSE; |
| 129 |
$summary_view->is_cacheable = FALSE; |
$summary_view->is_cacheable = FALSE; |
| 130 |
$summary_view->execute(); |
$summary_view->preview(); |
| 131 |
$this->view->totals[] = array_shift($summary_view->result); |
$this->view->totals[] = array_shift($summary_view->result); |
| 132 |
} |
} |
| 133 |
} |
} |