You are here

function ds_panels_layout_change_submit in Display Suite 7

Submit callback: update the layout.

1 string reference to 'ds_panels_layout_change_submit'
ds_extras_form_panels_change_layout_alter in modules/ds_extras/ds_extras.panels.inc
Implements hook_form_FORM_ID_alter().

File

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

Code

function ds_panels_layout_change_submit($form, $form_state) {
  $menu = menu_get_item();
  $entity_type = $menu['page_arguments'][0];
  $bundle = field_extract_bundle($entity_type, $menu['page_arguments'][1]);
  $view_mode = $menu['page_arguments'][2];
  ctools_include('export');
  $args = array(
    'entity_type' => $entity_type,
    'bundle' => $bundle,
    'view_mode' => $view_mode,
  );
  $record = ctools_export_load_object('ds_layout_settings', 'conditions', $args);
  if ($record) {
    $lid = $entity_type . '|' . $bundle . '|' . $view_mode;
    $record = $record[$lid];
    $layout = $form_state['layout'];

    // Determine the theme function / template for this display.
    $panel_layout = panels_get_layout($layout);

    // Update record object.
    $record->layout = $layout;
    $record->settings['layout'] = $layout;
    $record->settings['theme'] = $panel_layout['theme'];
    $record->settings['layout'] = $layout;

    // Let other modules alter the layout settings.
    drupal_alter('ds_layout_settings', $record, $form_state);

    // Update record in database.
    drupal_write_record('ds_layout_settings', $record, array(
      'id',
    ));

    // Clear entity info cache.
    cache_clear_all('entity_info', 'cache', TRUE);
  }
}