You are here

function page_manager_save_page_cache in Chaos Tool Suite (ctools) 7

Same name and namespace in other branches
  1. 6 page_manager/page_manager.module \page_manager_save_page_cache()

Write all changes from the page cache and clear it out.

3 calls to page_manager_save_page_cache()
page_manager_edit_page_finish in page_manager/page_manager.admin.inc
Callback generated when the an operation edit finished.
page_manager_page_add_subtask in page_manager/plugins/tasks/page.admin.inc
Page callback to add a subtask.
page_manager_save_page_form_submit in page_manager/page_manager.admin.inc
Save the page.

File

page_manager/page_manager.module, line 381
The page manager module provides a UI and API to manage pages.

Code

function page_manager_save_page_cache($cache) {

  // Save the subtask:
  if ($function = ctools_plugin_get_function($cache->task, 'save subtask callback')) {
    $function($cache->subtask, $cache);
  }

  // Iterate through handlers and save/delete/update as necessary.
  // Go through each of the task handlers, check to see if it needs updating,
  // and update it if so.
  foreach ($cache->handler_info as $id => $info) {
    $handler =& $cache->handlers[$id];

    // If it has been marked for deletion, delete it.
    if ($info['changed'] & PAGE_MANAGER_CHANGED_DELETED) {
      page_manager_delete_task_handler($handler);
    }
    elseif ($info['changed'] & PAGE_MANAGER_CHANGED_CACHED) {

      // Make sure we get updated weight from the form for this.
      $handler->weight = $info['weight'];
      page_manager_save_task_handler($handler);
    }
    elseif ($info['weight'] != $handler->weight) {

      // Theoretically we could only do this for in code objects, but since our
      // load mechanism checks for all, this is less database work.
      page_manager_update_task_handler_weight($handler, $info['weight']);
    }

    // Set enable/disabled status.
    if ($info['changed'] & PAGE_MANAGER_CHANGED_STATUS) {
      ctools_include('export');
      ctools_export_set_object_status($cache->handlers[$id], $info['disabled']);
    }
  }
  page_manager_clear_page_cache($cache->task_name);
  if (!empty($cache->path_changed) || !empty($cache->new)) {

    // Force a menu rebuild to make sure the menu entries are set.
    menu_rebuild();
  }
  cache_clear_all();
}