function globallink_insert_fc_fields in GlobalLink Connect for Drupal 7.6
Same name and namespace in other branches
- 7.7 globallink_field_configuration.inc \globallink_insert_fc_fields()
- 7.5 globallink_field_configuration.inc \globallink_insert_fc_fields()
Inserts field collection fields.
Parameters
string $node_type: The node type.
2 calls to globallink_insert_fc_fields()
- globallink_insert_all_fields in ./
globallink.module - Adds all fields of content type to field config.
- globallink_insert_gl_field_config in ./
globallink_field_configuration.inc - Inserts GlobalLink field configuration.
File
- ./
globallink_field_configuration.inc, line 499 - globallink_field_configuration.inc is a file that contains most functions needed on the Field Configuration UI.
Code
function globallink_insert_fc_fields($node_type) {
$entity_type = 'node';
$bean_type = $node_type;
if (strpos($node_type, 'bean:') !== false) {
$bean_type = str_replace('bean:', '', $node_type);
$entity_type = 'bean';
}
$field_arr = field_info_instances($entity_type, $bean_type);
$keys = array_keys($field_arr);
foreach ($keys as $field_name) {
$field_info = field_info_field($field_name);
if ($field_info['type'] != 'field_collection' || $field_info['translatable'] == 0) {
continue;
}
if (globallink_is_field_configured_for_translation($entity_type, $node_type, $field_name, $node_type)) {
continue;
}
db_insert('globallink_field_config')
->fields(array(
'content_type' => $node_type,
'entity_type' => $entity_type,
'bundle' => $node_type,
'field_name' => $field_name,
'field_type' => $field_info['type'],
'field_label' => $field_arr[$field_name]['label'],
'translatable' => 1,
))
->execute();
$fc_field_infos = field_info_instances('field_collection_item');
if (isset($fc_field_infos) && isset($fc_field_infos[$field_name]) && is_array($fc_field_infos[$field_name])) {
$fc_items = array_keys($fc_field_infos[$field_name]);
foreach ($fc_items as $fc_item) {
if (globallink_is_field_configured_for_translation('field_collection_item', $field_name, $fc_item, $node_type)) {
continue;
}
globallink_insert_fc_item_fields($node_type, $field_name, $fc_item);
}
}
}
}