You are here

function panels_renderer_editor::ajax_edit_pane in Panels 6.3

Same name and namespace in other branches
  1. 7.3 plugins/display_renderers/panels_renderer_editor.class.php \panels_renderer_editor::ajax_edit_pane()

AJAX entry point to edit a pane.

File

plugins/display_renderers/panels_renderer_editor.class.php, line 762
Class file to control the main Panels editor.

Class

panels_renderer_editor
@file Class file to control the main Panels editor.

Code

function ajax_edit_pane($pid = NULL, $step = NULL) {
  if (empty($this->cache->display->content[$pid])) {
    ctools_modal_render(t('Error'), t('Invalid pane id.'));
  }
  $pane =& $this->cache->display->content[$pid];
  $content_type = ctools_get_content_type($pane->type);
  $subtype = ctools_content_get_subtype($content_type, $pane->subtype);
  $form_state = array(
    'display' => &$this->cache->display,
    'contexts' => $this->cache->display->context,
    'pane' => &$pane,
    'cache' => &$this->cache,
    'ajax' => TRUE,
    'modal' => TRUE,
    'modal return' => TRUE,
    'commands' => array(),
  );
  $form_info = array(
    'path' => $this
      ->get_url('edit-pane', $pid, '%step'),
    'show cancel' => TRUE,
    'next callback' => 'panels_ajax_edit_pane_next',
    'finish callback' => 'panels_ajax_edit_pane_finish',
    'cancel callback' => 'panels_ajax_edit_pane_cancel',
  );
  $output = ctools_content_form('edit', $form_info, $form_state, $content_type, $pane->subtype, $subtype, $pane->configuration, $step);

  // If $rc is FALSE, there was no actual form.
  if ($output === FALSE || !empty($form_state['cancel'])) {

    // Dismiss the modal.
    $this->commands[] = ctools_modal_command_dismiss();
  }
  else {
    if (!empty($form_state['complete'])) {
      panels_edit_cache_set($this->cache);
      $this
        ->command_update_pane($pid);
      $this->commands[] = ctools_modal_command_dismiss();
    }
    else {

      // This overwrites any previous commands.
      $this->commands = ctools_modal_form_render($form_state, $output);
    }
  }
}