Mercurial > defr > drupal > views_calc
diff views_calc_table.inc @ 3:5635080385bd tip
Merge patch with 1.x-dev
author | Franck Deroche <franck@defr.org> |
---|---|
date | Fri, 07 Aug 2009 15:20:12 +0200 |
parents | cedf71edacf5 b0a976e17cc7 |
children |
line wrap: on
line diff
--- a/views_calc_table.inc Thu Aug 06 19:09:42 2009 +0200 +++ b/views_calc_table.inc Fri Aug 07 15:20:12 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(); @@ -114,6 +113,8 @@ } function do_calculation($calc, $sub_total, $nids = array()) { + // TODO Looks like we have problems unless we + // force a non-page display, need to keep an eye on this. if ($summary_view = views_get_view($this->view->name)) { $summary_view->set_display($this->view->current_display); $summary_view->set_arguments($this->view->args); @@ -122,7 +123,7 @@ $summary_view->views_calc_nids = $nids; $summary_view->views_calc_sub_total = $sub_total; $summary_view->is_cacheable = FALSE; - $summary_view->execute(); + $summary_view->preview(); return array_shift($summary_view->result); } return ''; @@ -168,6 +169,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); @@ -207,6 +212,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.