You are here

function page_manager_page_wizard in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 includes/page-wizard.inc \page_manager_page_wizard()

Menu callback for the page wizard.

4 string references to 'page_manager_page_wizard'
ctools_page_wizard_menu in includes/page-wizard.menu.inc
@file Contains menu item registration for the page manager page wizards tool.
page_manager_clear_wizard_cache in includes/page-wizard.inc
Remove an item from the object cache.
page_manager_get_wizard_cache in includes/page-wizard.inc
Get the cached changes to a given wizard.
page_manager_set_wizard_cache in includes/page-wizard.inc
Store changes to a task handler in the object cache.

File

includes/page-wizard.inc, line 84

Code

function page_manager_page_wizard($name, $step = NULL) {
  $plugin = page_manager_get_page_wizard($name);
  if (!$plugin) {
    return MENU_NOT_FOUND;
  }

  // Check for simple access string on plugin.
  if (!empty($plugin['access']) && !user_access($plugin['access'])) {
    return MENU_ACCESS_DENIED;
  }

  // Check for possibly more complex access callback on plugin.
  if ($function = ctools_plugin_get_function($plugin, 'access callback') && !$function($plugin)) {
    return MENU_ACCESS_DENIED;
  }

  // Create a basic wizard.in form info array and merge it with the
  // plugin's.
  $form_info = array(
    'id' => 'page_manager_page_wizard',
    'show trail' => TRUE,
    'show back' => TRUE,
    'show return' => FALSE,
    'show cancel' => FALSE,
    'next callback' => 'page_manager_page_wizard_next',
    'finish callback' => 'page_manager_page_wizard_finish',
    'path' => "admin/build/pages/wizard/{$name}/%step",
  );
  $form_info = array_merge_recursive($form_info, $plugin['form info']);

  // If step is unset, go with the basic step.
  if (!isset($step)) {
    $step = current(array_keys($form_info['order']));
    $cache = page_manager_make_wizard_cache($plugin);
  }
  else {
    $cache = page_manager_get_wizard_cache($plugin);
  }
  ctools_include('wizard');
  $form_state = array(
    'plugin' => $plugin,
    'cache' => $cache,
    'type' => 'edit',
    'rerender' => TRUE,
    'step' => $step,
  );
  if (isset($plugin['page title'])) {
    drupal_set_title($plugin['page title']);
  }
  if ($function = ctools_plugin_get_function($form_state['plugin'], 'start')) {
    $function($form_info, $step, $form_state);
  }
  $output = ctools_wizard_multistep_form($form_info, $step, $form_state);
  return $output;
}