You are here

function commerce_file_field_info in Commerce File 7

Implements hook_field_info().

File

includes/commerce_file.field.inc, line 34
Implement an commerce_file field, based on the file module's file field.

Code

function commerce_file_field_info() {

  // build base field info
  $base = array(
    'label' => t('Commerce File'),
    'description' => t('This field stores the ID of a licensed file as an integer value.'),
    'settings' => array(
      'uri_scheme' => _commerce_file_default_system_scheme(),
    ),
    'instance_settings' => array(
      'file_extensions' => 'mp4 m4v flv wmv mp3 wav jpg jpeg png pdf doc docx ppt pptx xls xlsx',
      'file_directory' => '',
      'max_filesize' => '',
    ),
    'default_widget' => 'commerce_file_generic',
    'default_formatter' => 'commerce_file_access_link',
    'property_type' => 'commerce_file',
    'property_callbacks' => array(
      'commerce_file_field_property_info_callback',
    ),
  );

  // set license settings default to unlimited
  $license_info = _commerce_file_collate_license_info();
  $instance_defaults = array();
  foreach ($license_info as $k => $info) {
    $instance_defaults[$k] = isset($info['property info']['default']) ? $info['property info']['default'] : COMMERCE_FILE_FIELD_UNLIMITED;
  }
  $base['instance_settings'] += array(
    'data' => $instance_defaults,
  );
  return array(
    COMMERCE_FILE_FIELD_TYPE => array_merge_recursive($base + array(
      'label' => t('Commerce File'),
      'description' => t('This field stores the ID of a licensed file as an integer value.'),
    )),
  );
}