function panels_ajax_cache_settings in Panels 6.2
Same name and namespace in other branches
- 5.2 includes/display_edit.inc \panels_ajax_cache_settings()
Handle the cache settings form
Related topics
1 call to panels_ajax_cache_settings()
- panels_ajax_cache_method in includes/
display-edit.inc - Entry point for AJAX modal: configure pane cache method
1 string reference to 'panels_ajax_cache_settings'
- panels_menu in ./
panels.module - Implementation of hook_menu
File
- includes/
display-edit.inc, line 826
Code
function panels_ajax_cache_settings($did, $pid) {
panels_load_include('plugins');
panels_load_include('ajax');
if (is_object($did)) {
// This is safe: Objects cannot be passed via URL.
$cache = $did;
$did = $cache->display->did;
}
else {
if (!is_numeric($did) && $did != 'new' || !($cache = panels_cache_get('display', $did))) {
panels_ajax_render(t('Invalid display id.'));
}
}
// This lets us choose whether we're doing the display's cache or
// a pane's.
if ($pid == 'display') {
$conf =& $cache->display->cache;
$title = t('Cache settings for this display');
}
else {
if (!empty($cache->display->content[$pid])) {
$pane = $cache->display->content[$pid];
$subtypes = panels_ct_get_types($pane->type);
$conf =& $cache->display->content[$pid]->configuration;
$title = t('Cache settings for !subtype_title', array(
'!subtype_title' => $subtypes[$pane->subtype]['title'],
));
}
else {
panels_ajax_render(t('Invalid pane id.'));
}
}
$conf['method'] = $cache->method;
$form_state = array(
'display' => &$cache->display,
'pid' => $pid,
'conf' => &$conf,
'ajax' => TRUE,
'title' => $title,
'url' => url("panels/ajax/cache-settings/{$did}/{$pid}", array(
'absolute' => TRUE,
)),
);
$output = panels_ajax_form_wrapper('panels_edit_cache_settings_form', $form_state);
if (empty($output)) {
// Preserve this; this way we don't actually change the method until they
// have saved the form.
if ($pid == 'display') {
$cache->display->cache = $conf;
}
else {
$cache->display->content[$pid]->configuration = $conf;
}
panels_cache_set('display', $did, $cache);
$output = new stdClass();
$output->type = 'dismiss';
$output->output = 'dummy';
if ($pid != 'display') {
$output->id = "panel-pane-{$pid}";
}
}
panels_ajax_render($output);
}