You are here

function _panels_edit in Panels 6.2

Same name and namespace in other branches
  1. 5.2 includes/display_edit.inc \_panels_edit()
  2. 6.3 includes/display-edit.inc \_panels_edit()
  3. 7.3 includes/display-edit.inc \_panels_edit()

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

Helper function for panels_edit().

See also

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

1 call to _panels_edit()
panels_edit in ./panels.module
Main API entry point to edit a panel display.

File

includes/display-edit.inc, line 17

Code

function _panels_edit($display, $destination, $content_types) {
  $did = $display->did;
  if (!$did) {
    $display->did = $did = 'new';
  }

  // Load the display being edited from cache, if possible.
  if (!empty($_POST) && is_object($cache = panels_cache_get('display', $did))) {
    $display = $cache->display;
  }
  else {
    panels_cache_clear('display', $did);
    $cache = new stdClass();
    $cache->display = $display;
    $cache->content_types = $content_types;
    panels_cache_set('display', $did, $cache);
  }
  $form_state = array(
    'display' => &$display,
    're_render' => FALSE,
    'no_redirect' => TRUE,
  );
  $output = drupal_build_form('panels_edit_display_form', $form_state);

  // no output == submit
  if (!$output) {
    if (!empty($form_state['clicked_button']['#save-display'])) {
      drupal_set_message(t('Panel content has been updated.'));
      panels_save_display($display);
    }
    else {
      drupal_set_message(t('Your changes have been discarded.'));
    }
    panels_cache_clear('display', $display->did);
    if ($destination) {
      return drupal_goto($destination);
    }
    return $form_state['display'];
  }
  return $output;
}