function views_calc_table::execute_summary_view in Views Calc 6.3
Same name and namespace in other branches
- 6 views_calc_table.inc \views_calc_table::execute_summary_view()
- 7 views_calc_table.inc \views_calc_table::execute_summary_view()
1 call to views_calc_table::execute_summary_view()
- views_calc_table::pre_render in ./
views_calc_table.inc - Views Method pre_render().
File
- ./
views_calc_table.inc, line 111 - Copied from the table style plugin.
Class
- views_calc_table
- Style plugin to render each item as a row in a table.
Code
function execute_summary_view($ids = array()) {
// Clone view for local subquery.
$summary_view = $this->view
->clone_view();
// copy the query object by value not by reference!
$summary_view->query = drupal_clone($this->view->query);
// Make sure the view is completely valid.
$errors = $summary_view
->validate();
if (is_array($errors)) {
foreach ($errors as $error) {
drupal_set_message($error, 'error');
}
return NULL;
}
// intialize summary view
$is_subtotal = !empty($ids);
$summary_view->preview = TRUE;
$summary_view->is_cacheable = FALSE;
$summary_view->views_calc_calculation = TRUE;
$summary_view->views_calc_sub_total = $is_subtotal;
// If it's a subtotal calc, we're filtering the page elements by $ids.
$summary_view->views_calc_ids = $ids;
$summary_view->views_calc_fields = $this->view->views_calc_fields;
// We don't need any offset in the calculation queries because
// the statement does only return the records with the passed ids
$summary_view->query->offset = 0;
// Execute and render the view in preview mode. Note that we only store
// the result if the executed view query returns any result.
$summary_view
->pre_execute($this->view->args);
// All results of the calculation queries are used, so we don't page them.
// Else we will loose the global pager from the page view.
$summary_view
->set_items_per_page(0);
$summary_view
->execute();
$summary_view
->post_execute();
if (!empty($summary_view->result)) {
if ($is_subtotal) {
$this->view->sub_totals = array_shift($summary_view->result);
}
else {
$this->view->totals = array_shift($summary_view->result);
}
}
}