plugin = $plugin; if ($function = ctools_plugin_get_function($plugin, 'default cache')) { $function($cache); } return $cache; } /** * Store changes to a task handler in the object cache. */ function page_manager_set_wizard_cache($cache) { ctools_include('object-cache'); ctools_object_cache_set('page_manager_page_wizard', $cache->plugin['name'], $cache); } /** * Remove an item from the object cache. */ function page_manager_clear_wizard_cache($name) { ctools_include('object-cache'); ctools_object_cache_clear('page_manager_page_wizard', $name); } /** * Menu callback for the page wizard. */ 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/structure/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, 'wizard 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; } /** * Callback generated when the add page process is finished. */ function page_manager_page_wizard_finish(&$form_state) { if ($function = ctools_plugin_get_function($form_state['plugin'], 'finish')) { $function($form_state); } page_manager_clear_wizard_cache($form_state['wizard cache']->plugin['name']); } /** * Callback generated when the 'next' button is clicked. * * All we do here is store the cache. */ function page_manager_page_wizard_next(&$form_state) { if ($function = ctools_plugin_get_function($form_state['plugin'], 'next')) { $function($form_state); } page_manager_set_wizard_cache($form_state['wizard cache']); } /** * Provide a simple administrative list of all wizards. * * This is called as a page callback, but can also be used by any module * that wants to get a list of wizards for its type. */ function page_manager_page_wizard_list($type = NULL) { $plugins = page_manager_get_page_wizards(); if (empty($plugins)) { return '
' . t('There are no wizards available at this time.') . '
'; } uasort($plugins, 'ctools_plugin_sort'); $output = '