You are here

function page_manager_page_new_page_cache in Chaos Tool Suite (ctools) 7

Same name and namespace in other branches
  1. 6 page_manager/plugins/tasks/page.inc \page_manager_page_new_page_cache()

When adding or cloning a new page, this creates a new page cache and adds our page to it.

This does not check to see if the existing cache is already locked. This must be done beforehand.

Parameters

&$page: The page to create.

&$cache: The cache to use. If the cache has any existing task handlers, they will be marked for deletion. This may be a blank object.

3 calls to page_manager_page_new_page_cache()
page_manager_page_add_subtask in page_manager/plugins/tasks/page.admin.inc
Page callback to add a subtask.
page_manager_page_form_clone_submit in page_manager/plugins/tasks/page.admin.inc
Submit clone page form.
page_manager_page_import_subtask_submit in page_manager/plugins/tasks/page.admin.inc
Submit the import page to create the new page and redirect.

File

page_manager/plugins/tasks/page.inc, line 737
Handle the 'page' task, which creates pages with arbitrary tasks and lets handlers decide how they will be rendered.

Code

function page_manager_page_new_page_cache(&$page, &$cache) {

  // Does a page already exist? If so, we are overwriting it so
  // take its pid.
  if (!empty($cache->subtask) && !empty($cache->subtask['subtask']) && !empty($cache->subtask['subtask']->pid)) {
    $page->pid = $cache->subtask['subtask']->pid;
  }
  else {
    $cache->new = TRUE;
  }
  $cache->task_name = page_manager_make_task_name('page', $page->name);
  $cache->task_id = 'page';
  $cache->task = page_manager_get_task('page');
  $cache->subtask_id = $page->name;
  $page->export_type = EXPORT_IN_DATABASE;
  $page->type = t('Normal');
  $cache->subtask = page_manager_page_build_subtask($cache->task, $page);
  if (isset($cache->handlers)) {
    foreach ($cache->handlers as $id => $handler) {
      $cache->handler_info[$id]['changed'] = PAGE_MANAGER_CHANGED_DELETED;
    }
  }
  else {
    $cache->handlers = array();
    $cache->handler_info = array();
  }
  if (!empty($page->default_handlers)) {
    foreach ($page->default_handlers as $id => $handler) {
      page_manager_handler_add_to_page($cache, $handler);
    }
  }
  $cache->locked = FALSE;
  $cache->changed = TRUE;
}