You are here

function page_manager_edit_page_operation in Chaos Tool Suite (ctools) 6

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

Entry point to edit a single operation for a page.

Parameters

$js: Whether or not the page was called via javascript.

$page: The cached page that is being edited.

...: A number of items used to drill down into the actual operation called.

1 string reference to 'page_manager_edit_page_operation'
page_manager_menu in page_manager/page_manager.module
Delegated implementation of hook_menu().

File

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

Code

function page_manager_edit_page_operation() {
  $args = func_get_args();
  $js = array_shift($args);
  $page = array_shift($args);
  $operations = page_manager_get_operations($page);
  $content = page_manager_get_operation_content($js, $page, $args, $operations);

  // If the operation requested we go somewhere else afterward, oblige it.
  if (isset($content['new trail'])) {
    $args = $content['new trail'];

    // Get operations again, for the operation may have changed their availability.
    $operations = page_manager_get_operations($page);
    $content = page_manager_get_operation_content($js, $page, $args, $operations);
  }

  // Rendering the content may have been a form submission that changed the
  // operations, such as renaming or adding a handler. Thus we get a new set
  // of operations.
  $operations = page_manager_get_operations($page);
  $rendered_operations = page_manager_render_operations($page, $operations, $args, array(
    'class' => 'operations-main',
  ), 'nav');

  // Since this form should never be submitted to this page, process it late so
  // that we can be sure it notices changes.
  ctools_include('form');
  $form_state = array(
    'page' => &$page,
  );
  $form = ctools_build_form('page_manager_save_page_form', $form_state);
  $output = theme('page_manager_edit_page', $page, $form, $rendered_operations, $content);
  if ($js) {
    $commands = array();
    if (isset($content['js settings'])) {
      $commands[] = ctools_ajax_command_settings($content['js settings']);
    }
    $commands[] = ctools_ajax_command_replace('#page-manager-edit', $output);
    ctools_ajax_render($commands);
  }
  drupal_set_title($page->subtask['admin title']);
  return $output;
}