/[drupal]/contributions/modules/views_calc/views_calc_table.inc
ViewVC logotype

Diff of /contributions/modules/views_calc/views_calc_table.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.16, Sat Jun 13 11:53:20 2009 UTC revision 1.17, Sat Jun 13 17:05:38 2009 UTC
# Line 1  Line 1 
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.
# Line 78  class views_calc_table extends views_plu Line 78  class views_calc_table extends views_plu
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;
# Line 87  class views_calc_table extends views_plu Line 87  class views_calc_table extends views_plu
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    
# Line 102  class views_calc_table extends views_plu Line 101  class views_calc_table extends views_plu
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        }        }
# Line 119  class views_calc_table extends views_plu Line 120  class views_calc_table extends views_plu
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      }      }

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17

  ViewVC Help
Powered by ViewVC 1.1.2