function panels_renderer_ipe::ajax_save_form in Panels 6.3
Same name and namespace in other branches
- 7.3 panels_ipe/plugins/display_renderers/panels_renderer_ipe.class.php \panels_renderer_ipe::ajax_save_form()
AJAX entry point to create the controller form for an IPE.
File
- panels_ipe/
plugins/ display_renderers/ panels_renderer_ipe.class.php, line 118
Class
- panels_renderer_ipe
- Renderer class for all In-Place Editor (IPE) behavior.
Code
function ajax_save_form($break = NULL) {
ctools_include('form');
if (!empty($this->cache->locked)) {
if ($break != 'break') {
$account = user_load($this->cache->locked->uid);
$name = theme('username', $account);
$lock_age = format_interval(time() - $this->cache->locked->updated);
$message = t("This panel is being edited by user !user, and is therefore locked from editing by others. This lock is !age old.\n\nClick OK to break this lock and discard any changes made by !user.", array(
'!user' => $name,
'!age' => $lock_age,
));
$this->commands[] = array(
'command' => 'unlockIPE',
'message' => $message,
'break_path' => url($this
->get_url('save-form', 'break')),
);
return;
}
// Break the lock.
panels_edit_cache_break_lock($this->cache);
}
$form_state = array(
'display' => &$this->display,
'content_types' => $this->cache->content_types,
'rerender' => FALSE,
'no_redirect' => TRUE,
// Panels needs this to make sure that the layout gets callbacks
'layout' => $this->plugins['layout'],
);
$output = ctools_build_form('panels_ipe_edit_control_form', $form_state);
if ($output) {
// At this point, we want to save the cache to ensure that we have a lock.
panels_edit_cache_set($this->cache);
$this->commands[] = array(
'command' => 'initIPE',
'key' => $this->clean_key,
'data' => $output,
);
return;
}
// no output == submit
if (!empty($form_state['clicked_button']['#save-display'])) {
// Saved. Save the cache.
panels_edit_cache_save($this->cache);
}
else {
// Cancelled. Clear the cache.
panels_edit_cache_clear($this->cache);
}
$this->commands[] = array(
'command' => 'endIPE',
'key' => $this->clean_key,
'data' => $output,
);
}