You are here

public function date_views_filter_handler_simple::op_contains in Date 7.3

Same name and namespace in other branches
  1. 7.2 date_views/includes/date_views_filter_handler_simple.inc \date_views_filter_handler_simple::op_contains()

@todo Document this.

1 method overrides date_views_filter_handler_simple::op_contains()
date_views_filter_handler::op_contains in date_views/includes/date_views_filter_handler.inc
@todo Document this.

File

date_views/includes/date_views_filter_handler_simple.inc, line 225
A standard Views filter for a single date field.

Class

date_views_filter_handler_simple
A standard Views filter for a single date field.

Code

public function op_contains($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');
  }
  $value = $this
    ->get_filter_value('value', $this->value['value']);
  $comp_date = new DateObject($value, date_default_timezone(), $this->format);
  $fields = date_views_fields($this->base_table);
  $fields = $fields['name'];
  $fromto = $fields[$field]['fromto'];
  $field_min = $this->date_handler
    ->sql_field($fromto[0], NULL, $comp_date);
  $field_min = $this->date_handler
    ->sql_format($this->format, $field_min);
  $field_max = $this->date_handler
    ->sql_field($fromto[1], NULL, $comp_date);
  $field_max = $this->date_handler
    ->sql_format($this->format, $field_max);
  $placeholder_min = $this
    ->placeholder();
  $placeholder_max = $this
    ->placeholder();
  $group = !empty($this->options['date_group']) ? $this->options['date_group'] : $this->options['group'];
  $this->query
    ->add_where_expression($group, "{$field_max} >= {$placeholder_min} AND {$field_min} <= {$placeholder_max}", array(
    $placeholder_min => $value,
    $placeholder_max => $value,
  ));
}