You are here

function ds_panels_display_settings_save in Display Suite 7

Submit callback: save custom display settings.

1 string reference to 'ds_panels_display_settings_save'
ds_panels_display_settings in modules/ds_extras/ds_extras.panels.inc
Form callback: Show custom display settings.

File

modules/ds_extras/ds_extras.panels.inc, line 194
Administrative functions for DS panels.

Code

function ds_panels_display_settings_save($form, $form_state) {
  $entity_type = $form['#entity_type'];
  $bundle = $form['#bundle'];
  module_load_include('inc', 'field_ui', 'field_ui.admin');

  // Get current bundle settings.
  $bundle_settings = field_bundle_settings($entity_type, $bundle);
  $entity_info = entity_get_info($entity_type);
  foreach ($form_state['values']['view_modes_custom'] as $view_mode_name => $value) {

    // Display a message for each view mode newly configured to use custom
    // settings.
    $view_mode_settings = field_view_mode_settings($entity_type, $bundle);
    if (!empty($value) && empty($view_mode_settings[$view_mode_name]['custom_settings'])) {
      $view_mode_label = $entity_info['view modes'][$view_mode_name]['label'];
      $path = _field_ui_bundle_admin_path($entity_type, $bundle) . "/display/{$view_mode_name}";
      drupal_set_message(t('The %view_mode mode now uses custom display settings. You might want to <a href="@url">configure them</a>.', array(
        '%view_mode' => $view_mode_label,
        '@url' => url($path),
      )));

      // Initialize the newly customized view mode with the display settings
      // from the default view mode.
      _field_ui_add_default_view_mode_settings($entity_type, $bundle, $view_mode_name, $bundle_settings);
    }
    $bundle_settings['view_modes'][$view_mode_name]['custom_settings'] = !empty($value);
  }

  // Save updated bundle settings.
  field_bundle_settings($entity_type, $bundle, $bundle_settings);
  drupal_set_message(t('Your settings have been saved.'));
}