function globallink_insert_gl_field_config in GlobalLink Connect for Drupal 7.6
Same name and namespace in other branches
- 7.7 globallink_field_configuration.inc \globallink_insert_gl_field_config()
- 7.5 globallink_field_configuration.inc \globallink_insert_gl_field_config()
Inserts GlobalLink field configuration.
Parameters
string $field_name: The field name.
string $content_type: The content type.
1 call to globallink_insert_gl_field_config()
- globallink_field_submit in ./
globallink_field_configuration.inc - Handles submission of globallink_field form.
File
- ./
globallink_field_configuration.inc, line 378 - globallink_field_configuration.inc is a file that contains most functions needed on the Field Configuration UI.
Code
function globallink_insert_gl_field_config($field_name, $content_type, $entity_type) {
if ($entity_type == 'node') {
$p_arr = globallink_get_pending_fields($content_type, $entity_type);
}
else {
if ($entity_type == 'fieldable_panels_pane') {
$fpp_type = str_replace('fpp:', '', $content_type);
$p_arr = globallink_get_pending_fields($fpp_type, $entity_type);
}
else {
if ($entity_type == 'taxonomy_term') {
$tax_type = str_replace('tax:', '', $content_type);
$p_arr = globallink_get_pending_fields($tax_type, $entity_type);
}
else {
if ($entity_type == 'bean') {
$bean_type = str_replace('bean:', '', $content_type);
$p_arr = globallink_get_pending_fields($bean_type, $entity_type);
}
}
}
}
if ($field_name == '[all]') {
$f_keys = array_keys($p_arr);
foreach ($f_keys as $f_key) {
if ($f_key == '[all]') {
continue;
}
$sum_field = '';
if (strpos($f_key, '@summary') !== false) {
$sum_field = $f_key;
}
if ($f_key != 'title' && $f_key != 'metatags' && empty($sum_field)) {
$field = field_info_field($f_key);
switch ($field['type']) {
case 'list_boolean':
case 'file':
case 'taxonomy_term_reference':
case 'entityreference':
case 'list_integer':
case 'field_collection':
break;
default:
db_insert('globallink_field_config')
->fields(array(
'content_type' => $content_type,
'entity_type' => $entity_type,
'bundle' => $content_type,
'field_name' => $f_key,
'field_type' => $field['type'],
'field_label' => $p_arr[$f_key],
'translatable' => 1,
))
->execute();
}
}
else {
db_insert('globallink_field_config')
->fields(array(
'content_type' => $content_type,
'entity_type' => $entity_type,
'bundle' => $content_type,
'field_name' => $f_key,
'field_type' => 'text',
'field_label' => $p_arr[$f_key],
'translatable' => 1,
))
->execute();
}
}
if (module_exists('field_collection')) {
globallink_insert_fc_fields($content_type);
}
}
else {
$sum_field = '';
if (strpos($field_name, '@summary') !== false) {
$sum_field = $field_name;
}
if ($field_name != 'title' && $field_name != 'metatags' && empty($sum_field)) {
$field = field_info_field($field_name);
switch ($field['type']) {
case 'list_boolean':
case 'file':
case 'entityreference':
case 'list_integer':
case 'taxonomy_term_reference':
break;
case 'field_collection':
globallink_insert_fc('node', $field_name, $content_type, $content_type);
break;
default:
db_insert('globallink_field_config')
->fields(array(
'content_type' => $content_type,
'entity_type' => $entity_type,
'bundle' => $content_type,
'field_name' => $field_name,
'field_type' => $field['type'],
'field_label' => $p_arr[$field_name],
'translatable' => 1,
))
->execute();
}
}
else {
db_insert('globallink_field_config')
->fields(array(
'content_type' => $content_type,
'entity_type' => $entity_type,
'bundle' => $content_type,
'field_name' => $field_name,
'field_type' => 'text',
'field_label' => $p_arr[$field_name],
'translatable' => 1,
))
->execute();
}
}
}