You are here

function date_field in Date 5.2

Same name and namespace in other branches
  1. 5 date.module \date_field()
  2. 6.2 date/date.module \date_field()
  3. 6 date/date.module \date_field()

Implementation of hook_field().

Validation and submission operation code is moved into a separate file and included only when processing forms.

File

date/date.module, line 353
Defines date/time field types for the Content Construction Kit (CCK).

Code

function date_field($op, &$node, $field, &$items, $teaser, $page) {

  // Add some information needed to interpret token values.
  $additions[$field['field_name']] = $items;
  foreach ($items as $delta => $item) {
    $timezone = isset($item['timezone']) ? $item['timezone'] : '';
    $additions[$field['field_name']][$delta]['timezone'] = date_get_timezone($field['tz_handling'], $timezone);
    $additions[$field['field_name']][$delta]['timezone_db'] = date_get_timezone_db($field['tz_handling']);
    $additions[$field['field_name']][$delta]['date_type'] = $field['type'];
  }
  switch ($op) {
    case 'load':
      return $additions;
      break;
    case 'validate':
      require_once './' . drupal_get_path('module', 'date') . '/date_elements.inc';
      return _date_field_validate($op, $node, $field, $items, $teaser, $page);
      break;
    case 'insert':
    case 'update':
      require_once './' . drupal_get_path('module', 'date') . '/date_elements.inc';
      $items = $additions[$field['field_name']];
      $node->{$field}['field_name'] = $additions;
      return _date_field_update($op, $node, $field, $items, $teaser, $page);
      break;
  }
}