You are here

function page_manager_edit_page_finish in Chaos Tool Suite (ctools) 7

Same name and namespace in other branches
  1. 6 page_manager/page_manager.admin.inc \page_manager_edit_page_finish()

Callback generated when the an operation edit finished.

1 call to page_manager_edit_page_finish()
page_manager_handler_add_finish in page_manager/page_manager.admin.inc
Finish the add process and make the new handler official.
1 string reference to 'page_manager_edit_page_finish'
_page_manager_get_operation_content in page_manager/page_manager.admin.inc
Fetch the content for an operation, after it's been discovered from arguments.

File

page_manager/page_manager.admin.inc, line 996
Administrative functions for the page manager.

Code

function page_manager_edit_page_finish(&$form_state) {
  if (empty($form_state['operation']['silent'])) {
    if (empty($form_state['clicked_button']['#save'])) {
      drupal_set_message(t('The page has been updated. Changes will not be permanent until you save.'));
    }
    else {
      drupal_set_message(t('The page has been updated and saved.'));
    }
    $path = array();
    foreach ($form_state['trail'] as $operation) {
      $path[] = $operation;
      $form_state['page']->changes[implode('/', $path)] = TRUE;
    }
  }

  // If a handler was modified, set it to changed so we know to overwrite it.
  if (isset($form_state['handler_id'])) {
    $form_state['page']->handler_info[$form_state['handler_id']]['changed'] |= PAGE_MANAGER_CHANGED_CACHED;
  }

  // While we make buttons go away on locked pages, it is still possible to
  // have a lock a appear while you were editing, and have your changes
  // disappear. This at least warns the user that this has happened.
  if (!empty($page->locked)) {
    drupal_set_message(t('Unable to update changes due to lock.'));
  }

  // If the 'Update and Save' button was selected, write our cache out.
  if (!empty($form_state['clicked_button']['#save'])) {
    page_manager_save_page_cache($form_state['page']);
    page_manager_clear_page_cache($form_state['page']->task_name);
    $form_state['page'] = page_manager_get_page_cache($form_state['page']->task_name);
  }
  else {
    if (empty($form_state['do not cache'])) {
      page_manager_set_page_cache($form_state['page']);
    }
  }

  // We basically always want to force a rerender when the forms
  // are finished, so make sure there is a new trail.
  if (empty($form_state['new trail'])) {

    // force a rerender to get rid of old form items that may have changed
    // during save.
    $form_state['new trail'] = $form_state['trail'];
  }
  if (isset($form_state['new trail']) && empty($form_state['ajax'])) {
    $form_state['redirect'] = page_manager_edit_url($form_state['page']->task_name, $form_state['new trail']);
  }
  $form_state['complete'] = TRUE;
}