You are here

function panels_renderer_ipe::ajax_set_layout in Panels 7.3

File

panels_ipe/plugins/display_renderers/panels_renderer_ipe.class.php, line 426

Class

panels_renderer_ipe
Renderer class for all In-Place Editor (IPE) behavior.

Code

function ajax_set_layout($layout) {
  ctools_include('context');
  ctools_include('display-layout', 'panels');
  $form_state = array(
    'layout' => $layout,
    'display' => $this->display,
    'finish' => t('Save'),
    'no_redirect' => TRUE,
  );

  // Reset the $_POST['ajax_html_ids'] values to preserve
  // proper IDs on form elements when they are rebuilt
  // by the Panels IPE without refreshing the page.
  $_POST['ajax_html_ids'] = array();
  $output = drupal_build_form('panels_change_layout', $form_state);
  $output = drupal_render($output);
  if (!empty($form_state['executed'])) {
    if (isset($form_state['back'])) {
      return $this
        ->ajax_change_layout();
    }
    if (!empty($form_state['clicked_button']['#save-display'])) {

      // Saved. Save the cache.
      panels_edit_cache_save($this->cache);
      $this->display->skip_cache = TRUE;

      // Since the layout changed, we have to update these things in the
      // renderer in order to get the right settings.
      $layout = panels_get_layout($this->display->layout);
      $this->plugins['layout'] = $layout;
      if (!isset($layout['regions'])) {
        $this->plugins['layout']['regions'] = panels_get_regions($layout, $this->display);
      }
      $this->meta_location = 'inline';
      $this->commands[] = ajax_command_replace("#panels-ipe-display-{$this->clean_key}", panels_render_display($this->display, $this));
      $this->commands[] = ctools_modal_command_dismiss();
      return;
    }
  }
  $this->commands[] = ctools_modal_command_display(t('Change layout'), $output);
}