You are here

function gathercontent_import_form in GatherContent 7.3

Multistep form function.

@inheritdoc

1 string reference to 'gathercontent_import_form'
gathercontent_menu in ./gathercontent.module
Implements hook_menu().

File

./gathercontent.import.inc, line 20

Code

function gathercontent_import_form($step = NULL) {

  // Define array for ctools multistep wizard.
  $form_info = array(
    'id' => 'gathercontent_import',
    'path' => "admin/config/gathercontent/import/%step",
    'show trail' => FALSE,
    'show back' => TRUE,
    'show cancel' => FALSE,
    'show return' => FALSE,
    'next callback' => 'gathercontent_import_wizard_next',
    'finish callback' => 'gathercontent_import_wizard_finish',
    'finish text' => t('Import'),
    'back text' => t('Back'),
    'no back validate' => TRUE,
    // Define forms order.
    'order' => array(
      'select-project' => t('Select project'),
      'select-content' => t('Select content'),
      'confirm' => t('Confirmation'),
    ),
    // Define forms.
    'forms' => array(
      'select-project' => array(
        'form id' => 'gathercontent_import_form_project_select',
      ),
      'select-content' => array(
        'form id' => 'gathercontent_import_form_content_select',
      ),
      'confirm' => array(
        'form id' => 'gathercontent_import_form_confirm',
      ),
    ),
  );
  $object_id = 1;
  if (empty($step) || $step === 'select-project') {

    // We reset the form when $step is NULL because that means they have
    // for whatever reason started over.
    gathercontent_import_cache_clear($object_id);
    $step = 'select-project';
  }

  // This automatically gets defaults if there wasn't anything saved.
  $object = gathercontent_import_cache_get($object_id);

  // Live $form_state changes.
  $form_state = array(
    // Put our object and ID into the form state cache so we can easily find it.
    'object_id' => $object_id,
    'object' => &$object,
  );

  // Send this all off to our form. This is like drupal_get_form only wizardy.
  ctools_include('wizard');
  $form = ctools_wizard_multistep_form($form_info, $step, $form_state);
  $output = drupal_render($form);
  if ($output === FALSE || !empty($form_state['complete'])) {
    drupal_set_message(t('New mapping has been saved.'));
    drupal_goto("admin/config/gathercontent/mapping");
  }
  return $output;
}