You are here

protected function WordPressMigrateWizard::reviewForm in WordPress Migrate 7.2

Show the user what they've chosen to migrate, and give them one last chance to say yay or nay.

File

./wordpress_migrate.migrate.inc, line 643

Class

WordPressMigrateWizard

Code

protected function reviewForm(&$form_state) {

  // In case we've been going back-and-forth with Previous, make sure we
  // start with no migrations - all migrations will be added here.
  $this->migrations = array();
  $blog = wordpress_migrate_blog($this->filename);
  $migration_classes = $blog
    ->migrationClasses();
  $this->groupArguments = array(
    'filename' => $this->filename,
    'source_system' => $this
      ->getSourceName(),
    'namespaces' => $this->namespaces,
  );
  $message = t('<p>Please review your migration configuration. When you submit this
      form, migration processes will be created and you will be left at the
      migration dashboard.</p>');
  $form['description'] = array(
    '#prefix' => '<div>',
    '#markup' => $message,
    '#suffix' => '</div>',
  );
  $migrations = '';
  $account = user_load($this->defaultAuthorUid);
  if ($this->authorMigration) {
    $migrations .= t('<li>WordPress authors will be imported.</li>');
  }
  else {
    $migrations .= t('<li>WordPress authors will not be imported. The default ' . 'author for any content whose author can\'t be identified will be %default.</li>', array(
      '%default' => $account->name,
    ));
  }
  $arguments = array(
    'default_author_uid' => $this->defaultAuthorUid,
    'import_users' => $this->authorMigration,
  );
  $this
    ->addMigration('Author', $migration_classes['WordPressAuthor'], $arguments);
  $attachment_arguments = array();
  if ($this->contentValues['blog']['post_type']) {
    $migrations .= t('<li>WordPress blog posts will be imported to %type nodes.</li>', array(
      '%type' => $this->contentValues['blog']['post_type'],
    ));
    $arguments = array(
      'dependencies' => array(
        'Author',
      ),
      'post_type' => $this->contentValues['blog']['post_type'],
      'tag_field' => $this->contentValues['blog']['tag_field'],
      'category_field' => $this->contentValues['blog']['category_field'],
      'attachment_field' => $this->contentValues['blog']['attachment_field'],
      'podcast_field' => $this->contentValues['blog']['podcast_field'],
      'text_format' => $this->contentValues['blog']['text_format'],
      'path_action' => $this->contentValues['blog']['path_action'],
      'generate_redirects' => $this->contentValues['blog']['generate_redirects'],
    );
    if ($arguments['tag_field']) {
      $tag_vocabulary = $this
        ->getVocabulary($arguments['tag_field']);
      $tag_arguments = array(
        'tag_vocabulary' => $tag_vocabulary,
      );
      $arguments['tag_migration'] = 'Tag' . $tag_vocabulary;
      $arguments['dependencies'][] = $arguments['tag_migration'];
      $this
        ->addMigration($arguments['tag_migration'], $migration_classes['WordPressTag'], $tag_arguments);
    }
    if ($arguments['category_field']) {
      $category_vocabulary = $this
        ->getVocabulary($arguments['category_field']);
      $category_arguments = array(
        'category_vocabulary' => $category_vocabulary,
      );
      $arguments['category_migration'] = 'Category' . $category_vocabulary;
      $arguments['dependencies'][] = $arguments['category_migration'];
      $this
        ->addMigration($arguments['category_migration'], $migration_classes['WordPressCategory'], $category_arguments);
    }
    $this
      ->addMigration('BlogPost', $migration_classes['WordPressBlogEntry'], $arguments);
    $attachment_arguments['dependencies'][] = 'BlogPost';
    $attachment_arguments['blog_attachment_field'] = $this->contentValues['blog']['attachment_field'];
    if ($this->contentValues['blog']['comments']) {
      $migrations .= t('<li>WordPress blog post comments will be imported.</li>');
      $arguments = array(
        'post_type' => $this->contentValues['blog']['post_type'],
        'source_post_type' => 'post',
        'dependencies' => array(
          'BlogPost',
        ),
        'text_format_comment' => $this->contentValues['blog']['text_format_comment'],
        'skip_pingbacks' => $this->contentValues['blog']['pingbacks'],
      );
      $this
        ->addMigration('BlogPostComment', $migration_classes['WordPressComment'], $arguments);
    }
    else {
      $migrations .= t('<li>WordPress blog post comments will not be imported.</li>');
    }
  }
  else {
    $migrations .= t('<li>WordPress blog posts and their comments will not be imported.</li>');
  }
  if ($this->contentValues['page']['page_type']) {
    $migrations .= t('<li>WordPress pages will be imported to %type nodes.</li>', array(
      '%type' => $this->contentValues['page']['page_type'],
    ));
    $arguments = array(
      'dependencies' => array(
        'Author',
      ),
      'page_type' => $this->contentValues['page']['page_type'],
      'tag_field' => $this->contentValues['page']['tag_field'],
      'category_field' => $this->contentValues['page']['category_field'],
      'attachment_field' => $this->contentValues['page']['attachment_field'],
      'podcast_field' => $this->contentValues['page']['podcast_field'],
      'text_format' => $this->contentValues['page']['text_format'],
      'path_action' => $this->contentValues['page']['path_action'],
      'generate_redirects' => $this->contentValues['page']['generate_redirects'],
    );
    $this
      ->addMigration('Page', $migration_classes['WordPressPage'], $arguments);
    $attachment_arguments['dependencies'][] = 'Page';
    $attachment_arguments['page_attachment_field'] = $this->contentValues['page']['attachment_field'];
    if ($this->contentValues['page']['comments']) {
      $migrations .= t('<li>WordPress page comments will be imported.</li>');
      $arguments = array(
        'post_type' => $this->contentValues['page']['page_type'],
        'source_post_type' => 'page',
        'dependencies' => array(
          'Page',
        ),
        'text_format_comment' => $this->contentValues['page']['text_format_comment'],
        'skip_pingbacks' => $this->contentValues['page']['pingbacks'],
      );
      $this
        ->addMigration('PageComment', $migration_classes['WordPressComment'], $arguments);
    }
    else {
      $migrations .= t('<li>WordPress page comments will not be imported.</li>');
    }
  }
  else {
    $migrations .= t('<li>WordPress pages and their comments will not be imported.</li>');
  }
  $this
    ->addMigration('Attachment', $migration_classes['WordPressAttachment'], $attachment_arguments);
  $form['migration_list'] = array(
    '#prefix' => '<ol>',
    '#markup' => $migrations,
    '#suffix' => '</ol>',
  );
  return $form;
}