Mercurial > defr > drupal > views_calc
diff views_calc_table.inc @ 2:b0a976e17cc7
Views Calc: Version de dev du 14/06/2009
author | Franck Deroche <franck@defr.org> |
---|---|
date | Fri, 07 Aug 2009 15:17:08 +0200 |
parents | 0651c02e6ed7 |
children | 5635080385bd |
line wrap: on
line diff
--- a/views_calc_table.inc Wed Aug 05 18:20:29 2009 +0200 +++ b/views_calc_table.inc Fri Aug 07 15:17:08 2009 +0200 @@ -1,5 +1,5 @@ <?php -// $Id: views_calc_table.inc,v 1.15 2009/04/22 02:21:41 karens Exp $ +// $Id: views_calc_table.inc,v 1.17 2009/06/13 17:05:38 karens Exp $ /** * @file * Copied from the table style plugin. @@ -78,7 +78,7 @@ */ function pre_render($results) { parent::pre_render($results); - + // If there are no calc fields, do nothing. if (!$calc_fields = $this->get_calc_fields()) { return; @@ -87,7 +87,6 @@ if (!empty($this->view->views_calc_calculation)) { return; } - $this->view->totals = array(); $this->view->sub_totals = array(); @@ -102,15 +101,17 @@ $nids[] = $value->nid; } // Add sub_total rows to the results. + // TODO Looks like we have problems unless we + // force a non-page display, need to keep an eye on this. foreach ($calc_fields as $calc => $field) { if ($summary_view = views_get_view($this->view->name)) { - $summary_view->set_display($this->view->current_display); + //$summary_view->set_display($this->view->current_display); $summary_view->set_arguments($this->view->args); $summary_view->views_calc_calculation = $calc; $summary_view->views_calc_nids = $nids; $summary_view->views_calc_sub_total = TRUE; $summary_view->is_cacheable = FALSE; - $summary_view->execute(); + $summary_view->preview(); $this->view->sub_totals[] = array_shift($summary_view->result); } } @@ -119,14 +120,14 @@ // Add grand totals to the results. foreach ($calc_fields as $calc => $field) { if ($summary_view = views_get_view($this->view->name)) { - $summary_view->set_display($this->view->current_display); + //$summary_view->set_display($this->view->current_display); $summary_view->set_arguments($this->view->args); $summary_view->pager['items_per_page'] = 0; $summary_view->views_calc_calculation = $calc; $summary_view->views_calc_nids = array(); $summary_view->views_calc_sub_total = FALSE; $summary_view->is_cacheable = FALSE; - $summary_view->execute(); + $summary_view->preview(); $this->view->totals[] = array_shift($summary_view->result); } } @@ -167,6 +168,10 @@ foreach ($this->view->field as $field) { $query_field = substr($field->field, 0, 3) == 'cid' ? $field->definition['calc'] : $field->table .'.'. $field->field; $query_alias = $field->field_alias; + // Bail if we have a broken handler. + if ($query_alias == 'unknown') { + continue; + } if (in_array($field->field, $fields)) { // Calculated fields. $this->view->query->add_field(NULL, "$calc($query_field)", $query_alias); @@ -206,6 +211,10 @@ foreach ($this->view->field as $field) { $query_field = substr($field->field, 0, 3) == 'cid' ? $field->definition['calc'] : $field->table .'.'. $field->field; $query_alias = $field->field_alias; + // Bail if we have a broken handler. + if ($query_alias == 'unknown') { + continue; + } $this->view->query->add_table($field->table, NULL, NULL, $field->table); if (!empty($fields) && in_array($field->field, $fields)) { // Calculated fields.