function globallink_insert_gl_field_config in GlobalLink Connect for Drupal 7.7
Same name and namespace in other branches
- 7.5 globallink_field_configuration.inc \globallink_insert_gl_field_config()
- 7.6 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 465 - 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 == GLOBALLINK_ENTITY_TYPE_NODE) {
$p_arr = globallink_get_pending_fields($content_type, $entity_type);
}
elseif ($entity_type == 'fieldable_panels_pane') {
$fpp_type = str_replace('fpp:', '', $content_type);
$p_arr = globallink_get_pending_fields($fpp_type, $entity_type);
}
elseif ($entity_type == 'taxonomy_term') {
$tax_type = str_replace('tax:', '', $content_type);
$p_arr = globallink_get_pending_fields($tax_type, $entity_type);
}
elseif ($entity_type == GLOBALLINK_ENTITY_TYPE_BEAN) {
$bean_type = str_replace('bean:', '', $content_type);
$p_arr = globallink_get_pending_fields($bean_type, $entity_type);
}
elseif ($entity_type == 'file') {
$file_type = str_replace('file:', '', $content_type);
$p_arr = globallink_get_pending_fields($file_type, $entity_type);
}
elseif ($entity_type == GLOBALLINK_ENTITY_TYPE_COM) {
$file_type = str_replace('cp:', '', $content_type);
$p_arr = globallink_get_pending_fields($file_type, $entity_type);
}
elseif ($entity_type == 'custom_entity') {
$machine_name = str_replace('ce:', '', $content_type);
$entity_type = globallink_get_entity_type_for_bundle($machine_name);
$content_type = globallink_get_bundle_for_field($machine_name);
$p_arr = globallink_get_pending_fields($content_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 '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 'list_integer':
case 'taxonomy_term_reference':
break;
case 'field_collection':
$bl = $content_type;
if ($entity_type == GLOBALLINK_ENTITY_TYPE_COM) {
$bl = str_replace('cp:', '', $content_type);
}
globallink_insert_fc($entity_type, $field_name, $content_type, $bl);
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();
}
}
}