You are here

function calendar_systems_preprocess_content_field in Calendar Systems 7

Same name and namespace in other branches
  1. 8 calendar_systems.module \calendar_systems_preprocess_content_field()
  2. 6.3 calendar_systems.module \calendar_systems_preprocess_content_field()
  3. 6 calendar_systems.module \calendar_systems_preprocess_content_field()
  4. 7.3 calendar_systems.module \calendar_systems_preprocess_content_field()
  5. 7.2 calendar_systems.module \calendar_systems_preprocess_content_field()

For basic integration with views

Parameters

$variables:

File

./calendar_systems.module, line 737
Contains Calendar Systems hook implementations and helpers.

Code

function calendar_systems_preprocess_content_field(&$variables) {

  // Are we called for the right field?
  if ($variables['field_type'] == 'date') {
    foreach ($variables['items'] as $key => $item) {
      $display = 'full';
      if ($variables['teaser']) {
        $display = 'teaser';
      }
      $type_info = date_get_format_types($variables['field']['display_settings'][$display]['format']);
      if (!$type_info) {
        $_format = $variables['field']['default_format'];
      }
      else {
        $_format = $type_info['title'];
      }
      if (!isset($variables['field']['granularity'])) {
        $granularity = FALSE;
      }
      else {
        $granularity = $variables['field']['granularity'];
      }
      if (isset($variables['items'][$key]['value2'])) {
        $format = _calendar_systems_get_format($_format, $granularity);
        $variables['items'][$key]['view'] = calendar_systems_format_date(strtotime($variables['items'][$key]['value']), 'custom', $format) . ' - ' . calendar_systems_format_date(strtotime($variables['items'][$key]['value2']), 'custom', $format);
      }
      else {
        $format = _calendar_systems_get_format($_format, $granularity);
        $variables['items'][$key]['view'] = calendar_systems_format_date(strtotime($variables['items'][$key]['value']), 'custom', $format);
      }
    }
  }
}