function ds_display_overview_form_submit in Display Suite 6
Same name and namespace in other branches
- 6.3 includes/ds.display.inc \ds_display_overview_form_submit()
- 6.2 includes/ds.display.inc \ds_display_overview_form_submit()
Save fields & plugins for a build mode.
File
- includes/
ds.display.inc, line 481 - Display overview form.
Code
function ds_display_overview_form_submit($form, &$form_state) {
$module = $form['#module'];
$build_mode = $form['#build_mode'];
$type = $form['#type_name'];
$extra = $form['#extra'];
$display_settings = variable_get($module . '_display_settings_' . $type, array());
unset($display_settings[$build_mode]);
// Fields.
$fields = ds_get_fields($module, $type, $build_mode, $extra);
if (!empty($fields)) {
foreach ($fields as $key => $field) {
$region = $form_state['values'][$key][$build_mode]['region'];
$display_settings[$build_mode]['fields'][$key]['region'] = $region;
$display_settings[$build_mode]['fields'][$key]['weight'] = $form_state['values'][$key]['ds_weight'];
$display_settings[$build_mode]['fields'][$key]['format'] = $form_state['values'][$key][$build_mode]['format'];
$class = implode(' ', $form_state['values'][$key][$build_mode]['css-class']);
$display_settings[$build_mode]['fields'][$key]['css-class'] = $class;
// Label value.
if (!empty($form_state['values'][$key][$build_mode]['label_value'])) {
$display_settings[$build_mode]['fields'][$key]['label_value'] = $form_state['values'][$key][$build_mode]['label_value'];
}
$display_settings[$build_mode]['fields'][$key]['labelformat'] = $form_state['values'][$key][$build_mode]['label']['format'];
// Parent.
$field_id = $form_state['values'][$key][$build_mode]['field_id'];
$parent_id = $form_state['values'][$key][$build_mode]['parent_id'];
if (!empty($parent_id)) {
$display_settings[$build_mode]['fields'][$key]['parent'] = $parent_id;
}
// Ditch this field, unless it has its storage in another module (ie CCK)
if (!isset($field['storage'])) {
unset($form_state['values'][$key]);
}
}
}
// Plugins.
if ($form['#plugins'] == TRUE) {
ds_plugins_display_submit($form, $form_state, $display_settings);
}
// Status.
$status = $form['#status'] == DS_SETTINGS_DEFAULT ? DS_SETTINGS_OVERRIDDEN : $form['#status'];
$display_settings[$build_mode]['status'] = $status;
// Sync / copy tab.
ds_sync_copy_form_submit($form, $form_state, $display_settings);
// Regions styles.
$region_styles = array();
foreach ($form['#regions'] as $region_key => $region_name) {
if ($region_key != 'disabled') {
$region_styles[$region_key] = implode(' ', $form_state['values']['region_styles_' . $region_key]);
}
}
$display_settings[$build_mode]['region_styles'] = $region_styles;
// Save all these settings.
variable_set($module . '_display_settings_' . $type, $display_settings);
drupal_set_message(t('Your settings have been saved.'));
}