You are here

function date_field_load in Date 8

Same name and namespace in other branches
  1. 7.3 date.field.inc \date_field_load()
  2. 7 date.field.inc \date_field_load()
  3. 7.2 date.field.inc \date_field_load()

Implements hook_field_load().

File

./date.field.inc, line 59
Field hooks to implement a date field.

Code

function date_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) {
  $timezone_db = date_get_timezone_db($field['settings']['tz_handling']);
  $db_format = date_type_format($field['type']);
  $keys = date_available_values($field);
  foreach ($entities as $id => $entity) {
    foreach ($items[$id] as $delta => &$item) {

      // If the file does not exist, mark the entire item as empty.
      if (is_array($item)) {
        $item['data'] = isset($item['data']) ? unserialize($item['data']) : array();
        $item['timezone_db'] = $timezone_db;
        $item['date_type'] = $field['type'];
        if (!empty($field['settings']['cache_enabled']) && ($delta < $field['settings']['cache_count'] || $field['settings']['cache_count'] == 0)) {
          foreach ($keys as $key) {
            if (!empty($item[$key])) {
              $item['db'][$key] = $date;
            }
          }
        }
      }
    }
  }
}