You are here

function _datex_date_views_argument_handler_simple::summary_query in Datex 7.3

Inject a test for valid date range before the summary query.

Overrides views_handler_argument_formula::summary_query

File

./datex.views.inc, line 781
Datex views integration.

Class

_datex_date_views_argument_handler_simple
Copied from date_views module. So we have no hard dependency on it.

Code

function summary_query() {

  // @TODO The summary values are computed by the database.
  // Unless the database has built-in timezone handling it will use
  // a fixed offset, which will not be right for all dates.
  // The only way I can see to make this work right is to store the offset
  // for each date in the database so it can be added to the base
  // date value before the database formats the result. Because this is a huge
  // architectural change, it won't go in until we start a new branch.
  $this->formula = $this->date_handler
    ->sql_format($this->sql_format, $this->date_handler
    ->sql_field("***table***.{$this->real_field}"));
  $this
    ->ensure_my_table();

  // Now that our table is secure, get our formula.
  $formula = $this
    ->get_formula();

  // Add the field, give it an alias that does NOT match the actual
  // field name or grouping won't work right.
  $this->base_alias = $this->name_alias = $this->query
    ->add_field(NULL, $formula, $this->field . '_summary');
  $this->query
    ->set_count_field(NULL, $formula, $this->field);
  return $this
    ->summary_basics(FALSE);
}