You are here

function date_copy_type_form in Date 5

Same name and namespace in other branches
  1. 5.2 date_copy/date_copy.module \date_copy_type_form()
  2. 6 date_copy/date_copy.module \date_copy_type_form()

A form to select a content type.

2 calls to date_copy_type_form()
date_copy_import_event_form in ./date_copy.module
Event import form.
date_copy_import_ical_form in ./date_copy.module
iCal import form.

File

./date_copy.module, line 87

Code

function date_copy_type_form($target = TRUE) {
  $form = array();
  $node_types = node_get_types('names');
  $fields = content_fields();
  $type_options = array();

  // Find out what content types contain date fields and set them up as target options.
  foreach ($fields as $field_name => $field) {
    if ($field['type'] == 'date' || $field['type'] == 'datestamp') {
      $type_options[$field['type_name']] = $node_types[$field['type_name']];
    }
  }
  if (sizeof($type_options) < 1) {
    drupal_set_message(t('There are no date fields in this database to import the data into. Please add a date field to the desired node types and be sure to indicate it uses both a "from" and a "to" date.'));
    return $form;
  }
  $type = $target ? 'target_type' : 'source_type';
  $label = $target ? t('Target type') : t('Source type');
  $form[$type] = array(
    '#type' => 'select',
    '#options' => $type_options,
    '#title' => $label,
    '#default_value' => '',
  );
  return $form;
}