You are here

function page_manager_page_save in Chaos Tool Suite (ctools) 7

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

Write a page subtask to the database.

1 call to page_manager_page_save()
page_manager_page_save_subtask in page_manager/plugins/tasks/page.inc
Call back from the administrative system to save a page.

File

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

Code

function page_manager_page_save(&$page) {
  $update = isset($page->pid) ? array(
    'pid',
  ) : array();
  $task = page_manager_get_task($page->task);
  if ($function = ctools_plugin_get_function($task, 'save')) {
    $function($page, $update);
  }
  drupal_write_record('page_manager_pages', $page, $update);

  // If this was a default page we may need to write default task
  // handlers that we provided as well.
  if (!$update && isset($page->default_handlers)) {
    $handlers = page_manager_load_task_handlers(page_manager_get_task('page'), $page->name);
    foreach ($page->default_handlers as $name => $handler) {
      if (!isset($handlers[$name]) || !($handlers[$name]->export_type & EXPORT_IN_DATABASE)) {

        // Make sure this is right, as exports can wander a bit.
        $handler->subtask = $page->name;
        page_manager_save_task_handler($handler);
      }
    }
  }
  return $page;
}