You are here

public function WordPressMigrateWizard::sourceDataForm in WordPress Migrate 7.2

First step - find out how to get the source data.

File

./wordpress_migrate.migrate.inc, line 66

Class

WordPressMigrateWizard

Code

public function sourceDataForm(&$form_state) {

  // Make sure we have a private directory configured
  if (!variable_get('wordpress_migrate_private_path', '') && !variable_get('file_private_path', '')) {
    $message = t('A private file system path must be <a href="@config">configured</a>
        to securely store your uploaded WordPress file.', array(
      '@config' => url('admin/config/media/file-system', array(
        'query' => array(
          'destination' => current_path(),
        ),
      )),
    ));
    $form['unconfigured'] = array(
      '#prefix' => '<div>',
      '#markup' => $message,
      '#suffix' => '</div>',
    );
    return $form;
  }
  $form['overview'] = array(
    '#prefix' => '<p>',
    '#markup' => t('This wizard supports importing into your Drupal site from ' . 'a WordPress blog. To be able to use this wizard, you must have the ' . 'address and credentials of the WordPress blog, or an XML file exported ' . 'from the blog.'),
    '#suffix' => '</p>',
  );
  $form['description'] = array(
    '#prefix' => '<p>',
    '#markup' => t('You will be led through a series of steps, allowing you to ' . 'customize what will be imported into Drupal and how it will be mapped. ' . 'At the end of this process, a migration job will be ' . 'generated and you will be left at the Migrate dashboard, from which ' . 'you can perform the import, monitor its progress, roll it back, etc.'),
    '#suffix' => '</p>',
  );
  if (module_exists('media') && !module_exists('migrate_extras')) {
    $form['need_extras'] = array(
      '#prefix' => '<div>',
      '#markup' => '<p>' . t('You have the <a href="@media">Media module</a> enabled - to
          take advantage of Media features, you need to also install and enable the
          <a href="@extras">Migrate Extras module</a>.' . '</p>', array(
        '@media' => url('http://drupal.org/project/media'),
        '@extras' => url('http://drupal.org/project/migrate_extras'),
      )),
      '#suffix' => '</div>',
    );
  }
  $form['source']['source_select'] = array(
    '#type' => 'radios',
    '#options' => array(
      0 => t('Import from a file'),
      1 => t('Import from a URL'),
    ),
    '#default_value' => 0,
    '#attributes' => array(
      'class' => array(
        'container-inline',
      ),
    ),
  );
  $form['#attributes'] = array(
    'enctype' => 'multipart/form-data',
  );
  $form['source']['wxr_file'] = array(
    '#type' => 'file',
    '#title' => t('WordPress exported file (WXR)'),
    '#description' => t('Select an exported WordPress file. Maximum file size is !size.', array(
      '!size' => format_size(file_upload_max_size()),
    )),
    '#states' => array(
      'visible' => array(
        ':input[name="source_select"]' => array(
          'value' => 0,
        ),
      ),
    ),
  );
  $form['source']['credentials']['domain'] = array(
    '#type' => 'textfield',
    '#title' => t('Blog URL'),
    '#description' => t('Enter the URL of the blog to import (e.g. example.my-server.com). Note that some servers (in particular wordpress.com) will block remote access, preventing direct access - if you get a "Could not login" error you must manually export your blog from WordPress and import the file here.'),
    '#field_prefix' => 'http://',
    '#states' => array(
      'visible' => array(
        ':input[name="source_select"]' => array(
          'value' => 1,
        ),
      ),
    ),
  );
  $form['source']['credentials']['username'] = array(
    '#type' => 'textfield',
    '#title' => t('Blog username'),
    '#description' => t(''),
    '#states' => array(
      'visible' => array(
        ':input[name="source_select"]' => array(
          'value' => 1,
        ),
      ),
    ),
  );
  $form['source']['credentials']['password'] = array(
    '#type' => 'password',
    '#title' => t('Blog password'),
    '#description' => t(''),
    '#states' => array(
      'visible' => array(
        ':input[name="source_select"]' => array(
          'value' => 1,
        ),
      ),
    ),
  );
  return $form;
}