You are here

function ws_datefield_wsfields_datetime2_data_alter in Web Service Data 7

Implements hook_wsfields_FIELD_TYPE_data_alter().

Parameters

array $data: An array of date information Ex: array( LANGUAGE_NONE => array( 0 => array( value => DateTime/DateObject instance, value2 => DateTime/DateObject instance, rrule => iCal Repeat Rule), 1 => array( value => DateTime/DateObject instance, value2 => DateTime/DateObject instance, rrule => iCal Repeat Rule), ) );

Prepares data for the 'datetime' field type

File

modules/ws_datefield/ws_datefield.module, line 24
Main module for ws_datefields

Code

function ws_datefield_wsfields_datetime2_data_alter($data, $field) {

  // @todo check the field settings to know if the repeat rules or end dates are enabled on this field
  // @todo determine if the offset needs to be in the field value or not
  $repeat = TRUE;
  $end_date = TRUE;
  $field_data = array();
  if (!empty($field['translatable'])) {
    $languages = language_list();
  }
  else {
    $languages = array(
      LANGUAGE_NONE => LANGUAGE_NONE,
    );
  }
  foreach ($languages as $lang => $language) {
    foreach ($data[$lang] as $key => $lang_data) {

      // Populate the field data
      _ws_datefield_populate_datetime_field_data($field_data, $value, $repeat, $end_date, $language);
    }
  }
  $data = $field_data;
  return $data;
}