You are here

function _panels_edit_layout in Panels 6.3

Same name and namespace in other branches
  1. 5.2 includes/display_edit.inc \_panels_edit_layout()
  2. 6.2 includes/display-layout.inc \_panels_edit_layout()
  3. 7.3 includes/display-layout.inc \_panels_edit_layout()

Handle calling and processing of the form for editing display layouts.

Helper function for panels_edit_layout().

See also

panels_edit_layout() for details on the various behaviors of this function.

1 call to _panels_edit_layout()
panels_edit_layout in ./panels.module
API entry point for selecting a layout for a given display.

File

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

Code

function _panels_edit_layout($display, $finish, $destination, $allowed_layouts) {
  ctools_include('common', 'panels');
  ctools_include('form');
  $form_state = array(
    'display' => &$display,
    'finish' => $finish,
    'destination' => $destination,
    'allowed_layouts' => $allowed_layouts,
    're_render' => FALSE,
    'no_redirect' => TRUE,
  );
  $change_form_state = $form_state;
  $change_form = FALSE;

  // Examine $_POST to see which form they're currently using.
  if (empty($_POST) || empty($_POST['form_id']) || $_POST['form_id'] != 'panels_change_layout') {
    $output = ctools_build_form('panels_choose_layout', $form_state);
    if (empty($output)) {

      // upon submission go to next form.
      $change_form_state['layout'] = $_SESSION['layout'][$display->did] = $form_state['layout'];
      $change_form = TRUE;
    }
  }
  else {
    $change_form_state['layout'] = $_SESSION['layout'][$display->did];
    $change_form = TRUE;
  }
  if ($change_form) {
    $output = ctools_build_form('panels_change_layout', $change_form_state);
    if (empty($output)) {
      if (isset($change_form_state['back'])) {
        $_POST = array();
        return _panels_edit_layout($display, $finish, $destination, $allowed_layouts);
      }
      if (!empty($change_form_state['clicked_button']['#save-display'])) {
        drupal_set_message(t('Panel layout has been updated.'));
        panels_save_display($display);
      }
      if ($destination) {
        return panels_goto($destination);
      }
      return $change_form_state['display'];
    }
  }
  return $output;
}