You are here

function gathercontent_check_step in GatherContent 7.2

Used to get current step from the URL.

5 calls to gathercontent_check_step()
gathercontent_login_form in includes/login.inc
Form constructor for displaying login credentials.
gathercontent_media_form in includes/media.inc
Form constructor for displaying media import dialog.
gathercontent_pages_form in includes/pages.inc
Form constructor for selecting pages.
gathercontent_pages_import_form in includes/pages_import.inc
Form constructor for mapping fields.
gathercontent_project_form in includes/project.inc
Form constructor for selecting project.

File

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

Code

function gathercontent_check_step($step = '') {
  $checks = array(
    'projects',
    'login',
    'pages',
    'pages_import',
    'media',
    'finished',
  );
  $step = in_array($step, $checks) ? $step : 'projects';
  $checks = array(
    'projects' => array(
      'fields' => array(
        'api_key',
        'api_url',
      ),
      'prev' => 'login',
    ),
    'pages' => array(
      'fields' => array(
        'project_id',
      ),
      'prev' => 'projects',
    ),
    'pages_import' => array(
      'fields' => array(
        'project_id',
        'selected_pages',
      ),
      'prev' => 'projects',
    ),
    'media' => array(
      'fields' => array(
        'project_id',
        'selected_pages',
      ),
      'prev' => 'projects',
    ),
  );
  if (isset($checks[$step])) {
    $error = FALSE;
    foreach ($checks[$step]['fields'] as $chk) {
      if (variable_get('gathercontent_' . $chk, '') == '') {
        $error = TRUE;
      }
    }
    if ($error) {
      $step = $checks[$step]['prev'];
      drupal_goto('admin/config/content/gathercontent' . ($step == 'projects' ? '' : '/' . $step));
      return FALSE;
    }
  }
  $path = drupal_get_path('module', 'gathercontent');
  drupal_add_css($path . '/css/main.css');
  drupal_add_js($path . '/js/jquery-1.9.1.min.js');
  drupal_add_js($path . '/js/bootstrap.min.js');
  drupal_add_js($path . '/js/main.js');
  return TRUE;
}