You are here

protected function availability_calendar_handler_filter_availability::getValidOrEmptyValue in Availability Calendars 7.5

Returns the given value if it is valid or an empty value otherwise.

Parameters

string|int $value:

string $type:

Return value

string|int|null

1 call to availability_calendar_handler_filter_availability::getValidOrEmptyValue()
availability_calendar_handler_filter_availability::accept_exposed_input in views/availability_calendar_handler_filter_availability.inc
Check to see if input from the exposed filters should be accepted.

File

views/availability_calendar_handler_filter_availability.inc, line 582

Class

availability_calendar_handler_filter_availability
Views handler to filter on availability.

Code

protected function &getValidOrEmptyValue(&$value, $type) {
  $empty = empty($value);
  if (!$empty) {

    // If the value is not empty but does not validate, it apparently is
    // the default value ("help text") that should be treated as empty.
    $valid = $type === 'duration' ? (is_int($value) || ctype_digit($value)) && $value > 0 : availability_calendar_parse_entry_date($value) !== FALSE;
    if (!$valid) {
      $value = NULL;
    }
  }
  return $value;
}