1 date_views_filter_handler_simple.inc date_views_filter_handler_simple::op_simple($field)

Overrides views_handler_filter_date::op_simple

File

core/modules/date/views/date_views_filter_handler_simple.inc, line 173
A standard Views filter for a single date field, using Date API form selectors and sql handling.

Class

date_views_filter_handler_simple
@file A standard Views filter for a single date field, using Date API form selectors and sql handling.

Code

function op_simple($field) {

  // Add the delta field to the view so we can later find the value that matched our query.
  list($table_name, $field_name) = explode('.', $field);
  if (!empty($this->options['add_delta']) && (substr($field_name, -6) == '_value' || substr($field_name, -7) == '_value2')) {
    $this->query->add_field($table_name, 'delta');
    $real_field_name = str_replace(array('_value', '_value2'), '', $this->real_field);
    $this->query->add_field($table_name, 'entity_id', 'date_id_' . $real_field_name);
    $this->query->add_field($table_name, 'delta', 'date_delta_' . $real_field_name);
  }

  $value = $this->get_filter_value('value', $this->value['value']);
  $comp_date = new BackdropDateTime($value, date_default_timezone(), $this->format);
  $field = $this->date_handler->sql_field($field, NULL, $comp_date);
  $field = $this->date_handler->sql_format($this->format, $field);
  $placeholder = $this->placeholder();
  $group = !empty($this->options['date_group']) ? $this->options['date_group'] : $this->options['group'];
  $this->query->add_where_expression($group, "$field $this->operator $placeholder", array($placeholder => $value));
}