function ds_field_ui_layout_clone in Display Suite 7.2
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 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 includes/
ds.field_ui.inc - Add the layouts fieldset on the Field UI screen.
File
- includes/
ds.field_ui.inc, line 884 - 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.'));
}
else {
drupal_set_message(t('No layout was cloned.'));
}
}