You are here

function date_api_argument_handler::get_query_fields in Date 6

Same name and namespace in other branches
  1. 6.2 includes/date_api_argument_handler.inc \date_api_argument_handler::get_query_fields()
2 calls to date_api_argument_handler::get_query_fields()
date_api_argument_handler::query in ./date_api.views.inc
Set up the query for this argument.
date_api_argument_handler::summary_query in ./date_api.views.inc
Create a summary query that matches the granularity.

File

./date_api.views.inc, line 257
Defines date-related Views data and plugins:

Class

date_api_argument_handler
Date API argument handler.

Code

function get_query_fields() {
  $fields = date_api_fields();
  $fields = $fields['name'];
  $min_date = isset($this->min_date) ? $this->min_date : NULL;
  $min_utc = isset($this->min_utc) ? $this->min_utc : NULL;
  $max_date = isset($this->max_date) ? $this->max_date : NULL;
  $max_utc = isset($this->max_utc) ? $this->max_utc : NULL;
  foreach ($this->options['date_fields'] as $delta => $name) {
    if ($field = $fields[$name]) {
      $date_handler = new date_sql_handler();
      $date_handler
        ->construct($field['sql_type'], date_default_timezone_name());
      $tz_handling = $field['tz_handling'];
      switch ($tz_handling) {
        case 'date':
          $date_handler->db_timezone = 'UTC';
          $date_handler->local_timezone_field = $field['timezone_field'];
          $date_handler->local_offset_field = $field['offset_field'];
          $date_handler->min_date = $min_date;
          $date_handler->max_date = $max_date;
          break;
        case 'none':
          $date_handler->db_timezone = date_default_timezone_name();
          $date_handler->local_timezone = date_default_timezone_name();
          $date_handler->min_date = $min_date;
          $date_handler->max_date = $max_date;
          break;
        case 'utc':
          $date_handler->db_timezone = 'UTC';
          $date_handler->local_timezone = 'UTC';
          $date_handler->min_date = $min_utc;
          $date_handler->max_date = $max_utc;
          break;
        default:
          $date_handler->db_timezone = 'UTC';
          $date_handler->local_timezone = 'UTC';
          $date_handler->min_date = $min_utc;
          $date_handler->max_date = $max_utc;
          break;
      }
      $this->query_fields[] = array(
        'field' => $field,
        'date_handler' => $date_handler,
      );
    }
  }
}