You are here

function availability_calendar_booking_formlet_field_formatter_settings_summary in Availability Calendars 7.3

Same name and namespace in other branches
  1. 7.5 booking_formlet/availability_calendar_booking_formlet.module \availability_calendar_booking_formlet_field_formatter_settings_summary()
  2. 7.4 booking_formlet/availability_calendar_booking_formlet.module \availability_calendar_booking_formlet_field_formatter_settings_summary()

Implements hook_field_formatter_settings_summary(). @link http://api.drupal.org/api/drupal/modules--field_ui--field_ui.api.php/fun...

File

booking_formlet/availability_calendar_booking_formlet.module, line 329
Availability Calendar booking formlet module. This submdule of the Availability Calendar module defines a field that shows a small booking form that interacts with a calendar field. The form only has an arraival and departure date field and a submit…

Code

function availability_calendar_booking_formlet_field_formatter_settings_summary($field, $instance, $view_mode) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $summary = array();

  // Summary info about showing whole form or submit button only.
  $summary[] = $settings['submit_only'] ? t('Only show the submit button') : t('Show the complete booking formlet');

  // Summary info about the source of the begin date.
  switch ($settings['preset_begin_date_source']) {
    case 'today':
      $source = t('today');
      break;
    case 'get':
    case 'post':
      $key = availability_calendar_booking_formlet_format_key($settings['preset_begin_date_key']);
      $source = '$_' . strtoupper($settings['preset_begin_date_source']) . $key;
      break;
    case 'none':
    default:
      $source = t('blank');
      break;
  }
  $summary[] = t('Default begin date: @value', array(
    '@value' => $source,
  ));

  // Summary info about the source of the end date.
  switch ($settings['preset_end_date_source']) {
    case 'get':
    case 'post':
      $key = availability_calendar_booking_formlet_format_key($settings['preset_end_date_key']);
      $source = '$_' . strtoupper($settings['preset_end_date_source']) . $key;
      $line = t('Default end date: @value', array(
        '@value' => $source,
      ));
      break;
    case 'get1':
    case 'post1':
      $key = availability_calendar_booking_formlet_format_key($settings['preset_end_date_key']);
      $source = substr($settings['preset_end_date_source'], 0, strpos($settings['preset_end_date_source'], '_'));
      $source = '$_' . strtoupper($source) . $key;
      $line = t('Default departure date: @value', array(
        '@value' => $source,
      ));
      break;
    case 'get_duration':
    case 'post_duration':
      $key = availability_calendar_booking_formlet_format_key($settings['preset_end_date_key']);
      $global = $settings['preset_end_date_source'] === 'get_duration' ? 'GET' : 'POST';
      $source = '$_' . $global . $key;
      $line = t('Default end date: begin + @value days', array(
        '@value' => $source,
      ));
      break;
    case 'fixed_duration':
      $source = $settings['preset_end_date_key'];
      $line = t('Default end date: begin + @value days', array(
        '@value' => $source,
      ));
      break;
    case 'none':
    default:
      $source = t('blank');
      $line = t('Default end date: @value', array(
        '@value' => $source,
      ));
      break;
  }
  $summary[] = $line;
  return implode('<br/>', $summary);
}