You are here

function views_handler_filter_field_partial_date_year::accept_exposed_input in Partial Date 7

Do some minor translation of the exposed input

Overrides views_handler_filter_numeric::accept_exposed_input

File

includes/partial_date.views.year_period_handler.inc, line 265

Class

views_handler_filter_field_partial_date_year
TODO: This is a placeholder to eventually provide a exposed list filter based on the field approximate year values.

Code

function accept_exposed_input($input) {
  if (empty($this->options['exposed'])) {
    return TRUE;
  }

  // rewrite the input value so that it's in the correct format so that
  // the parent gets the right data.
  if (!empty($this->options['expose']['identifier'])) {
    $value =& $input[$this->options['expose']['identifier']];
    if (!is_array($value)) {
      $value = array(
        'value' => $value,
      );
    }
  }
  $rc = parent::accept_exposed_input($input);
  if (empty($this->options['expose']['required'])) {

    // We have to do some of our own checking for non-required filters.
    $info = $this
      ->operators();
    if (!empty($info[$this->operator]['values'])) {
      switch ($info[$this->operator]['values']) {
        case 1:
          if ($value['value'] === '') {
            return FALSE;
          }
          break;
        case 2:
          if ($value['min'] === '' && $value['max'] === '') {
            return FALSE;
          }
          break;
      }
    }
  }
  return $rc;
}