function _sf_contrib_add_fields in Salesforce Suite 6.2
1 call to _sf_contrib_add_fields()
- sf_contrib_fieldmap_objects_alter in sf_contrib/
sf_contrib.module - Implementation of hook_fieldmap_objects().
File
- sf_contrib/
sf_contrib.module, line 98 - Provides integration with Location and CCK.
Code
function _sf_contrib_add_fields(&$objects) {
if (!module_exists('content')) {
return;
}
// Loop through each of the content types.
foreach (content_types() as $type) {
// Add each of the fields to the node object definition.
$group = t('@type CCK fields', array(
'@type' => $type['name'],
));
$index = 'node_' . $type['type'];
foreach ((array) $type['fields'] as $field) {
switch ($field['type']) {
case 'location':
unset($objects['drupal'][$index]['fields'][$field['field_name']]);
$proceed = FALSE;
if (!module_exists('location')) {
break;
}
static $location_field_definitions;
if (empty($location_field_definitions)) {
$dummy = NULL;
$location_field_definitions = location_locationapi($dummy, 'fields');
}
// Location is special: add each of its fields individually
// and use a special import/export handler
if (empty($field['location_settings']['form']['fields']) || !is_array($field['location_settings']['form']['fields'])) {
break;
}
foreach ($field['location_settings']['form']['fields'] as $key => $loc_setting) {
if ($key == 'additional') {
// Salesforce street address is a textarea.
// Append "additional" to "address1" instead of using a separate field
continue;
}
$objects['drupal'][$index]['fields'][$field['field_name'] . ':' . $key] = array(
'group' => t('@group: @label', array(
'@group' => $group,
'@label' => $field['widget']['label'],
)),
'label' => isset($location_field_definitions[$key]) ? check_plain($location_field_definitions[$key]) : $key,
'export' => '_sf_node_export_cck_location',
'import' => '_sf_node_import_cck_location',
);
}
break;
case 'datetime':
case 'datestamp':
case 'date':
$objects['drupal'][$index]['fields'][$field['field_name'] . ':value2']['label'] = $objects['drupal'][$index]['fields'][$field['field_name']]['label'] . ' ' . t('(to date)');
$objects['drupal'][$index]['fields'][$field['field_name']]['export'] = $objects['drupal'][$index]['fields'][$field['field_name'] . ':value2']['export'] = '_sf_node_export_cck_date';
$objects['drupal'][$index]['fields'][$field['field_name']]['import'] = $objects['drupal'][$index]['fields'][$field['field_name'] . ':value2']['import'] = '_sf_node_import_cck_date';
break;
}
}
}
}