function date_copy_type_fields_form in Date 6
Same name and namespace in other branches
- 5.2 date_copy/date_copy.module \date_copy_type_fields_form()
- 5 date_copy.module \date_copy_type_fields_form()
A form to select fields from a content type.
2 calls to date_copy_type_fields_form()
- date_copy_import_event_form in date_copy/
date_copy.module - Event import form.
- date_copy_import_ical_form in date_copy/
date_copy.module - iCal import form.
File
- date_copy/
date_copy.module, line 102
Code
function date_copy_type_fields_form($type, $extended = FALSE) {
$form = array();
$fields = content_fields();
$date_options = array();
$description_options = array(
'' => '',
);
$uid_options = array(
'' => '',
);
$url_options = array(
'' => '',
);
$location_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_name'] == $type) {
if ($field['type'] == 'date' || $field['type'] == 'datestamp') {
$date_options[$field_name] = $field['widget']['label'];
}
if ($field['type'] == 'text') {
$description_options[$field_name] = $field['widget']['label'];
$location_options[$field_name] = $field['widget']['label'];
$uid_options[$field_name] = $field['widget']['label'];
$url_options[$field_name] = $field['widget']['label'];
}
if ($field['type'] == 'link') {
$url_options[$field_name] = $field['widget']['label'];
}
}
}
// The body field is also available as an option for the description.
$description_options['body'] = t('body');
if (sizeof($date_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;
}
$form['date_field'] = array(
'#type' => 'select',
'#options' => $date_options,
'#title' => t('Date field'),
'#default_value' => '',
'#description' => t('The field which will contain the source dates in target content type.'),
);
$form['description_field'] = array(
'#type' => 'select',
'#options' => $description_options,
'#title' => t('Description field'),
'#default_value' => '',
'#description' => t('The text or body field which will contain the source description in the target content type.'),
);
if ($extended) {
$form['url_field'] = array(
'#type' => 'select',
'#options' => $url_options,
'#title' => t('Url field'),
'#default_value' => '',
'#description' => t('The text or link field which will contain the source url in the target content type.'),
);
$form['location_field'] = array(
'#type' => 'select',
'#options' => $location_options,
'#title' => t('Location field'),
'#default_value' => '',
'#description' => t('The text field which will contain the source location text in the target content type.'),
);
$form['uid_field'] = array(
'#type' => 'select',
'#options' => $uid_options,
'#title' => t('Uid field'),
'#default_value' => '',
'#description' => t('The text field which will contain the source uid in the target content type.'),
);
}
return $form;
}