function exif_custom_import_map in EXIF Custom 7
Custom function for import mappings from code.
1 call to exif_custom_import_map()
- exif_custom_features_rebuild in ./
exif_custom.features.inc - Implements COMPONENT_features_rebuild().
File
- ./
exif_custom.features.inc, line 125 - Features file for the exif_custom module.
Code
function exif_custom_import_map($map) {
if ($mid = exif_custom_get_mid($map['name'])) {
// Delete the old field mappings to be updated.
db_delete('exif_custom_mapped_fields')
->condition('mid', $mid)
->execute();
}
else {
// Create new map.
db_insert('exif_custom_maps')
->fields(array(
'name',
))
->values(array(
'name' => $map['name'],
))
->execute();
// Fetch mid.
$mid = exif_custom_get_mid($map['name']);
}
// Insert fields.
$insert = db_insert('exif_custom_mapped_fields');
$field_names = array_keys($map['fields'][0]);
$field_names[] = 'mid';
$insert
->fields($field_names);
// Add mid to field array.
foreach ($map['fields'] as $field) {
$field['mid'] = $mid;
$insert
->values($field);
}
$insert
->execute();
}