protected function AvailabilityCalendarFieldHandler::convertAvailabilityString in Availability Calendars 7.5
Converts a string specifying the availability to an array.
Converts a string specifying the availability to a "multiple availability" array.
Parameters
string $dates: Availability data, see README.txt for a description of the expected format.
array $element: Field configuration expected by availability_calendar_field_widget_month_form_validate_line().
Return value
array|false Array with the availability as accepted by availability_calendar_update_multiple_availability(), or false on error.
See also
availability_calendar_field_widget_month_form_validate()
availability_calendar_field_attach_submit_inc()
1 call to AvailabilityCalendarFieldHandler::convertAvailabilityString()
- AvailabilityCalendarFieldHandler::prepareCalendar in ./
availability_calendar_migrate_field_handlers.inc - Prepares an Availability Calendar.
File
- ./
availability_calendar_migrate_field_handlers.inc, line 138 - Migrate field handlers.
Class
- AvailabilityCalendarFieldHandler
- Migrates availability data to availability_calendar fields.
Code
protected function convertAvailabilityString($dates, $element) {
$changes = array();
$lines = explode("\n", $dates);
foreach ($lines as $line) {
$line = trim($line);
if (!empty($line)) {
$change = availability_calendar_field_widget_month_form_validate_line($line, $element, TRUE);
if ($change === FALSE) {
watchdog('availability_calendar', "Invalid availability data: %line", array(
'%line' => $line,
), WATCHDOG_ERROR);
return FALSE;
}
$changes[] = $change;
}
}
return $changes;
}