You are here

function gathercontent_import in GatherContent 7

Import wizard, built with CTools multistep form wizard.

4 string references to 'gathercontent_import'
gathercontent_import_cache_clear in ./gathercontent.module
Clears CTools' multistep form cache.
gathercontent_import_cache_get in ./gathercontent.module
Gets the current object from the cache, or default.
gathercontent_import_cache_set in ./gathercontent.module
Stores CTools' multistep form cache so we can retain data from form to form.
gathercontent_menu in ./gathercontent.module
Implements hook_menu().

File

./gathercontent.module, line 84
Imports pages from GatherContent (http://gathercontent.com/) into Drupal as nodes.

Code

function gathercontent_import($js = NULL, $step = NULL) {
  if ($js) {
    ctools_include('modal');
    ctools_include('ajax');
  }

  // Define array for ctools multistep wizard.
  $form_info = array(
    'id' => 'gathercontent-import-form',
    'path' => "admin/config/content/gathercontent/" . ($js ? 'ajax' : 'nojs') . "/import/%step",
    'show trail' => FALSE,
    'show back' => TRUE,
    'show cancel' => FALSE,
    'show return' => FALSE,
    'finish text' => 'Import pages',
    'next callback' => 'gathercontent_import_next',
    'finish callback' => 'gathercontent_import_finish',
    'cancel callback' => 'gathercontent_import_cancel',
    // Define forms order.
    'order' => array(
      'content_type' => t('Select content type'),
      'pages' => t('Import pages'),
    ),
    // Define forms.
    'forms' => array(
      'content_type' => array(
        'form id' => 'gathercontent_import_content_type',
      ),
      'pages' => array(
        'form id' => 'gathercontent_import_pages',
      ),
    ),
  );
  $object_id = 'gathercontent_import';
  if (empty($step)) {

    // Reset the form when $step is NULL.
    gathercontent_import_cache_clear($object_id);
    $step = 'content_type';
  }

  // This automatically gets defaults if nothing was saved.
  $object = gathercontent_import_cache_get($object_id);

  // Live $form_state changes.
  $form_state = array(
    'ajax' => $js,
    '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);
  return $output;
}