You are here

function date_views_filter_handler_simple::op_simple in Date 8

Same name and namespace in other branches
  1. 7.3 date_views/includes/date_views_filter_handler_simple.inc \date_views_filter_handler_simple::op_simple()
  2. 7.2 date_views/includes/date_views_filter_handler_simple.inc \date_views_filter_handler_simple::op_simple()
1 method overrides date_views_filter_handler_simple::op_simple()
date_views_filter_handler::op_simple in date_views/includes/date_views_filter_handler.inc

File

date_views/includes/date_views_filter_handler_simple.inc, line 149
A standard Views filter for a single date field, using Date API form selectors and sql handling.

Class

date_views_filter_handler_simple

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 DrupalDateTime($value, drupal_get_user_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,
  ));
}