function globallink_entity_install in GlobalLink Connect for Drupal 7.6
Same name and namespace in other branches
- 7.5 globallink_entity/globallink_entity.install \globallink_entity_install()
Implements hook_install().
File
- globallink_entity/
globallink_entity.install, line 133 - GlobalLink entity translation install file.
Code
function globallink_entity_install() {
/**
* Insert Entity enabled fields
*/
$node_types = node_type_get_types();
foreach ($node_types as $node_type) {
if (!entity_translation_node_supported_type($node_type->type)) {
return;
}
$field_arr = field_info_instances('node', $node_type->type);
$keys = array_keys($field_arr);
// If the field exists in the table, ignore the insert.
$results = db_select('globallink_field_config', 'tfc')
->fields('tfc')
->condition('content_type', $node_type->type)
->condition('bundle', $node_type->type)
->condition('field_name', 'title_field')
->execute();
if ($results
->rowCount() == 0) {
db_insert('globallink_field_config')
->fields(array(
'content_type' => $node_type->type,
'entity_type' => 'node',
'bundle' => $node_type->type,
'field_name' => 'title',
'field_type' => 'text',
'field_label' => 'Title',
'translatable' => 1,
))
->execute();
}
if (module_exists('metatag')) {
db_insert('globallink_field_config')
->fields(array(
'content_type' => $node_type->type,
'entity_type' => 'node',
'bundle' => $node_type->type,
'field_name' => 'metatags',
'field_type' => 'text',
'field_label' => 'Meta tags',
'translatable' => 1,
))
->execute();
}
foreach ($keys as $field_name) {
$field = field_info_field($field_name);
switch ($field['type']) {
case 'list_boolean':
case 'image':
case 'file':
case 'taxonomy_term_reference':
case 'list_boolean':
continue 2;
}
$results = db_select('globallink_field_config', 'tfc')
->fields('tfc')
->condition('content_type', $node_type->type)
->condition('bundle', $node_type->type)
->condition('field_name', $field_name)
->execute();
if ($results
->rowCount() == 0) {
db_insert('globallink_field_config')
->fields(array(
'content_type' => $node_type->type,
'entity_type' => 'node',
'bundle' => $node_type->type,
'field_name' => $field_name,
'field_type' => $field['type'],
'field_label' => $field_arr[$field_name]['label'],
'translatable' => 1,
))
->execute();
}
}
}
}