You are here

function timefield_property_info_callback in Timefield 7

Callback to create the property info for timefield.

See also

timefield_field_info()

1 string reference to 'timefield_property_info_callback'
timefield_field_info in ./timefield.module
Implements hook_field_info().

File

./timefield.module, line 1269
Defines a Field API field for time

Code

function timefield_property_info_callback(&$info, $entity_type, $field, $instance, $field_type) {
  $name = $field['field_name'];
  $property =& $info[$entity_type]['bundles'][$instance['bundle']]['properties'][$name];
  $property['type'] = $field['cardinality'] != 1 ? 'list<timefield>' : 'timefield';
  $property['getter callback'] = 'entity_metadata_field_verbatim_get';
  $property['setter callback'] = 'entity_metadata_field_verbatim_set';
  $property['property info'] = array(
    'value' => array(
      'label' => t('Integer offset for the Start Time'),
      'type' => 'integer',
      'getter callback' => 'entity_property_verbatim_get',
    ),
    'value_formatted' => array(
      'label' => t('Start Time'),
      'type' => 'text',
      'getter callback' => 'entity_property_verbatim_get',
    ),
  );
  if (!empty($field['settings']['totime'])) {
    $property['property info']['value2'] = array(
      'label' => t('Integer Offset for the End Time'),
      'type' => 'integer',
      'getter callback' => 'entity_property_verbatim_get',
    );
    $property['property info']['value2_formatted'] = array(
      'label' => t('End Time'),
      'type' => 'text',
      'getter callback' => 'entity_property_verbatim_get',
    );
  }
  if ($field['settings']['weekly_summary']) {
    $property['property info']['label'] = array(
      'label' => t('Label'),
      'description' => t('The label of this weekly schedule'),
      'type' => 'text',
      'getter callback' => 'entity_property_verbatim_get',
      'setter callback' => 'entity_property_verbatim_set',
    );
  }
  if ($field['settings']['weekly_summary'] || $field['settings']['weekly_summary_with_label']) {
    foreach (_timefield_weekly_summary_days() as $index => $label) {
      $property['property info'][$index] = array(
        'label' => $label,
        'description' => t('If this schedule applies to !day', array(
          '!day' => $label,
        )),
        'type' => 'boolean',
        'getter callback' => 'entity_property_verbatim_get',
        'setter callback' => 'entity_property_verbatim_set',
      );
    }
  }
  unset($property['query callback']);
}