You are here

function availability_calendar_field_info in Availability Calendars 7.4

Same name and namespace in other branches
  1. 7.5 availability_calendar.field.inc \availability_calendar_field_info()
  2. 7.3 availability_calendar.field.inc \availability_calendar_field_info()

Implements hook_field_info(). @link http://api.drupal.org/api/drupal/modules--field--field.api.php/function/...

Provides the descriptions of the fields offered by this module.

File

./availability_calendar.field.inc, line 39

Code

function availability_calendar_field_info() {

  // Get the states. They are used to determine some default settings.
  module_load_include('inc', 'availability_calendar', 'availability_calendar');
  $states = availability_calendar_get_states();
  if (!empty($states[1]) && $states[1]['css_class'] == 'cal-nc') {

    // State "Not communicated" exists, make this the default, but allow only
    // other states to be selected by the editor.
    $allowed_states = $states;
    unset($allowed_states[1]);
    $allowed_states = array_keys($allowed_states);
    $default_state = 1;
  }
  else {
    $allowed_states = array();

    // No state selected = all states.
    $default_state = 0;

    // Required, but no default.
  }
  return array(
    'availability_calendar' => array(
      'label' => t('Availability Calendar'),
      'description' => t('Allows to add an availability calendar to your entities.'),
      // States are not stored in the field settings but in their own table.
      // Fields can select a subset of this global set as allowed states.
      'settings' => array(
        'allocation_type' => AC_ALLOCATION_TYPE_OVERNIGHT,
        'allowed_states' => $allowed_states,
        'default_state' => $default_state,
      ),
      'instance_settings' => array(
        'allow_disable' => 1,
        'add_name' => 1,
      ),
      'default_widget' => 'availability_calendar',
      'default_formatter' => 'availability_calendar_viewport',
      'i18n_sync_callback' => 'availability_calendar_i18n_sync_availability_calendar_field',
    ),
  );
}