You are here

function page_manager_handler_add_submit in Chaos Tool Suite (ctools) 7

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

Handler related forms.

File

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

Code

function page_manager_handler_add_submit(&$form, &$form_state) {
  $cache = $form_state['page'];
  $plugin = page_manager_get_task_handler($form_state['values']['handler']);

  // Create a new handler.
  $handler = page_manager_new_task_handler($plugin);
  if (!empty($form_state['values']['title'])) {
    $handler->conf['title'] = $form_state['values']['title'];
  }
  else {
    $handler->conf['title'] = $plugin['title'];
  }
  $handler->conf['name'] = $form_state['values']['name'];
  $cache->new_handler = $handler;

  // Figure out which forms to present them with
  $cache->forms = array();
  $features = $form_state['values']['features'];
  if (isset($features[$form_state['values']['handler']])) {
    $cache->forms = array_merge($cache->forms, array_keys(array_filter($features[$form_state['values']['handler']])));
  }
  if (isset($plugin['required forms'])) {
    $cache->forms = array_merge($cache->forms, array_keys($plugin['required forms']));
  }
  $form_state['no_rerender'] = TRUE;
  if (!empty($cache->forms)) {

    // Tell the form to go to the config page.
    drupal_set_message(t('Before this variant can be added, it must be configured. When you are finished, click "Create variant" at the end of this wizard to add this to your page.'));
    $form_state['new trail'] = array(
      'actions',
      'configure',
    );
  }
  else {

    // It has no forms at all. Add the variant and go to its first operation.
    page_manager_handler_add_finish($form_state);
  }
}