function ds_field_ui_layout_clone in Display Suite 7
Same name and namespace in other branches
- 8.4 includes/field_ui.inc \ds_field_ui_layout_clone()
- 8.2 includes/field_ui.inc \ds_field_ui_layout_clone()
- 8.3 includes/field_ui.inc \ds_field_ui_layout_clone()
- 7.2 includes/ds.field_ui.inc \ds_field_ui_layout_clone()
Clone a fields layout.
1 string reference to 'ds_field_ui_layout_clone'
- _ds_field_ui_table_layouts in ./
ds.field_ui.inc - Add the layouts fieldset on the Field UI screen.
File
- ./
ds.field_ui.inc, line 709 - Field UI functions for Display Suite.
Code
function ds_field_ui_layout_clone($form, &$form_state) {
$clone = $form_state['values']['additional_settings']['clone'];
$entity_type = $form['#entity_type'];
$bundle = $form['#bundle'];
$view_mode = $form['#view_mode'];
ctools_include('export');
$layout = ctools_export_crud_load('ds_layout_settings', $clone);
// Delete previous layout settings configuration.
db_delete('ds_layout_settings')
->condition('entity_type', $entity_type)
->condition('bundle', $bundle)
->condition('view_mode', $view_mode)
->execute();
// Delete previous field configuration configuration.
db_delete('ds_field_settings')
->condition('entity_type', $entity_type)
->condition('bundle', $bundle)
->condition('view_mode', $view_mode)
->execute();
// Save new layout record for ds.
if ($layout) {
$record = new stdClass();
$record->id = $form['#export_id'];
$record->entity_type = $entity_type;
$record->bundle = $bundle;
$record->view_mode = $view_mode;
$record->layout = $layout->layout;
$record->settings = $layout->settings;
// Let other modules alter the layout settings.
drupal_alter('ds_layout_settings', $record, $form_state);
// Save layout record.
drupal_write_record('ds_layout_settings', $record);
// Copy the view mode settings.
list($ce, $cb, $cv) = explode('|', $clone);
_ds_field_ui_clone_view_mode_settings($entity_type, $bundle, $view_mode, $cv);
// Clear entity info cache.
cache_clear_all('entity_info', 'cache', TRUE);
// Show message.
drupal_set_message(t('The layout has been cloned. Note that not all settings for all fields have been copied over, you need to check those and save this screen again.'));
}
else {
drupal_set_message(t('No layout was cloned.'));
}
}