You are here

function panels_renderer_editor::ajax_style_settings in Panels 7.3

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

AJAX entry point to configure the style for a display, region or pane.

Parameters

string $type: Either display, region or pane

$pid: The pane id, if a pane. The region id, if a region.

1 call to panels_renderer_editor::ajax_style_settings()
panels_renderer_editor::ajax_style_type in plugins/display_renderers/panels_renderer_editor.class.php
AJAX entry point to select the style for a display, region or pane.

File

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

Class

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

Code

function ajax_style_settings($type, $pid = '') {
  $info = $this
    ->get_style($type, $pid);
  $style = $info[0];
  $conf =& $info[1];
  switch ($type) {
    case 'display':
      $title = t('Style settings for @style (display)', array(
        '@style' => $style['title'],
      ));
      break;
    case 'region':
      $title = t('Style settings for style @style (Region "!region")', array(
        '@style' => $style['title'],
        '!region' => $this->plugins['layout']['regions'][$pid],
      ));
      break;
    case 'pane':
      ctools_include('content');
      $pane =& $this->display->content[$pid];
      $subtype = ctools_content_get_subtype($pane->type, $pane->subtype);
      $title = t('Style settings for style @style (Pane "!pane")', array(
        '@style' => $style['title'],
        '!pane' => $subtype['title'],
      ));
      break;
  }
  $form_state = array(
    'display' => &$this->display,
    'type' => $type,
    'pid' => $pid,
    'conf' => &$conf,
    'style' => $style,
    'ajax' => TRUE,
    'title' => $title,
    'url' => url($this
      ->get_url('style-settings', $type, $pid), array(
      'absolute' => TRUE,
    )),
    'renderer' => &$this,
  );
  $output = ctools_modal_form_wrapper('panels_edit_style_settings_form', $form_state);
  if (empty($form_state['executed'])) {
    $this->commands = $output;
    return;
  }
  if (isset($this->cache->style)) {
    unset($this->cache->style);
  }
  if (!empty($form_state['cancel'])) {

    // The cache must be saved prior to dismissing the modal.
    panels_edit_cache_set($this->cache);
    $this->commands[] = ctools_modal_command_dismiss();
    return;
  }

  // Copy settings from form state back into the cache.
  if (!empty($form_state['values']['settings'])) {
    if ($type == 'pane') {
      $this->cache->display->content[$pid]->style['settings'] = $form_state['values']['settings'];
    }
    elseif ($type == 'region') {
      $this->cache->display->panel_settings['style_settings'][$pid] = $form_state['values']['settings'];
    }
  }
  panels_edit_cache_set($this->cache);
  $this->commands[] = ctools_modal_command_dismiss();
  if ($type == 'pane') {
    $this
      ->command_update_pane($pane);
  }
  elseif ($type == 'region') {
    $this
      ->command_update_region_links($pid);
  }
  else {
    $this
      ->command_update_display_links();
  }
}