You are here

function panels_change_layout_submit in Panels 7.3

Same name and namespace in other branches
  1. 6.3 includes/display-layout.inc \panels_change_layout_submit()
  2. 6.2 includes/display-layout.inc \panels_change_layout_submit()

Handle submission of the change layout form.

This submit handler will move panes around and save the display.

1 call to panels_change_layout_submit()
panels_mini_ui::edit_form_move_submit in panels_mini/plugins/export_ui/panels_mini_ui.class.php
2 string references to 'panels_change_layout_submit'
panels_change_layout in includes/display-layout.inc
Form definition for the display layout converter.
panel_context.inc in plugins/task_handlers/panel_context.inc
This is the task handler plugin to handle attaching a panel to any task that advertises itself as a 'context' type, which all of the basic page tasks provided by page_manager.module do by default.

File

includes/display-layout.inc, line 281
Handle the forms for changing a display's layout.

Code

function panels_change_layout_submit($form, &$form_state) {
  $display = $form_state['display'];
  $layout_display = $form_state['layout_display'];
  $switch = array();

  // Calculate the pids submitted by the display and make a list of
  // translation to the regions. Remember the 'pid' of the pane
  // is the region id in the old layout.
  if (!empty($form_state['values']['panel']['pane'])) {
    foreach ($form_state['values']['panel']['pane'] as $region_id => $panes) {
      if ($panes) {
        $pids = explode(',', $panes);

        // Need to filter the array, b/c passing it in a hidden field can generate trash.
        foreach (array_filter($pids) as $pid) {
          $switch[$pid] = $region_id;
        }
      }
    }
  }
  $content = array();
  foreach ($switch as $region_id => $new_region_id) {
    if (isset($display->panels[$region_id])) {
      if (!isset($content[$new_region_id])) {
        $content[$new_region_id] = array();
      }
      $content[$new_region_id] = array_merge($content[$new_region_id], $display->panels[$region_id]);
    }
  }

  // Go through each pane and make sure its region id is correct.
  foreach ($content as $region_id => $region) {
    foreach ($region as $pid) {
      $display->content[$pid]->panel = $region_id;
    }
  }
  $display->panels = $content;
  $display->layout = $form_state['layout'];
  panels_edit_display_settings_form_submit($form, $form_state);
}