You are here

function panels_renderer_editor::ajax_cache_settings 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_cache_settings()

AJAX entry point to configure the cache settings for a pane or the display.

Parameters

string $pid: Either a pane id for a pane in the display, or 'display' to edit the display cache settings.

1 call to panels_renderer_editor::ajax_cache_settings()
panels_renderer_editor::ajax_cache_method in plugins/display_renderers/panels_renderer_editor.class.php
AJAX entry point to configure the cache method for a pane or the display.

File

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

Class

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

Code

function ajax_cache_settings($pid = 0) {
  ctools_include('content');

  // This lets us choose whether we're doing the display's cache or
  // a pane's.
  if ($pid == 'display') {
    $conf =& $this->display->cache;
    $title = t('Cache settings for this display');
  }
  else {
    if (!empty($this->display->content[$pid])) {
      $pane =& $this->display->content[$pid];
      $subtype = ctools_content_get_subtype($pane->type, $pane->subtype);
      $conf =& $pane->cache;
      $title = t('Cache settings for !subtype_title', array(
        '!subtype_title' => $subtype['title'],
      ));
    }
    else {
      ctools_modal_render(t('Error'), t('Invalid pane id.'));
    }
  }
  if (isset($this->cache->method) && (empty($conf['method']) || $conf['method'] != $this->cache->method)) {
    $conf['method'] = $this->cache->method;
    $info = panels_get_cache($conf['method']);
    $conf['settings'] = isset($info['defaults']) ? $info['defaults'] : array();
  }
  $form_state = array(
    'display' => &$this->display,
    'pid' => $pid,
    'conf' => &$conf,
    'ajax' => TRUE,
    'title' => $title,
    'url' => url($this
      ->get_url('cache-settings', $pid), array(
      'absolute' => TRUE,
    )),
  );
  $output = ctools_modal_form_wrapper('panels_edit_cache_settings_form', $form_state);
  if (!empty($output)) {
    $this->commands = $output;
    return;
  }
  panels_edit_cache_set($this->cache);
  $this->commands[] = ctools_modal_command_dismiss();
  if ($pid != 'display') {
    $this
      ->command_update_pane($pane);
  }
  else {
    $this
      ->command_update_display_links();
  }
}