You are here

function dbtng_migrator_settings in DBTNG Migrator 7

Form function, called by drupal_get_form() in dbtng_migrator_menu().

1 call to dbtng_migrator_settings()
dbtng_migrator_check_form in ./dbtng_migrator.admin.inc
Form function, called by drupal_get_form() in dbtng_migrator_menu().
2 string references to 'dbtng_migrator_settings'
dbtng_migrator_menu in ./dbtng_migrator.module
Implements hook_menu().
drush_dbtng_migrator_dbtng_replicate_validate in ./dbtng_migrator.drush.inc
Validation callback to 'dbtng-replicate'.

File

./dbtng_migrator.admin.inc, line 124

Code

function dbtng_migrator_settings($form, &$form_state) {
  $form['description']['#markup'] = t('Below are the database connections defined in Drupal. You can use this interface to migrate database to another assuming it is a Drupal database.');
  global $databases;
  foreach (array_keys($databases) as $key) {
    $connection_info = Database::getConnectionInfo($key);
    $info = $connection_info['default'];

    // Make the information display safe.
    $rows[] = array(
      check_plain($key),
      check_plain($info['driver']),
      check_plain($info['database']),
    );
    $options[$key] = $key;
  }
  if (count($options) < 2) {
    drupal_set_message(t('You must specify more than one database connection in the settings.php file.'), 'error');
  }
  $form['how_to'] = array(
    '#title' => 'Instructions',
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['how_to']['details'] = array(
    '#markup' => '<p>' . t('To migrate this Drupal install to another database you\'ll
                    need to add the database connection creditials to your settings.php file. Below is an example:') . '</p>',
  );
  $form['how_to']['example']['#markup'] = '<pre>
  &lt;?php
    // Settings.php contents above....

    // You\'re new database to migrate to. This will appear as "example" in the Migrator admin UI.
    $databases[\'example\'][\'default\'] = array(
      \'driver\' => \'mysql\',
      \'database\' => \'databasename\',
      \'username\' => \'username\',
      \'password\' => \'password\',
      \'host\' => \'localhost\',
      \'prefix\' => \'\',
    );
  ?&gt;
</pre>';
  $headers = array(
    'Key',
    'Driver',
    'Database',
  );
  $form['databases']['#markup'] = theme('table', array(
    'header' => $headers,
    'rows' => $rows,
  ));
  $form['migrate_origin'] = array(
    '#title' => 'Origin Database',
    '#type' => 'select',
    '#options' => $options,
    '#description' => t('The database the data will be replicated from.'),
    '#disabled' => count($options) < 2,
  );
  $form['migrate_destination'] = array(
    '#title' => 'Destination Database',
    '#type' => 'select',
    '#options' => $options,
    '#description' => t('The database the origin data will be replicated too.'),
    '#access' => count($options) > 1,
    '#default_value' => $key,
  );
  $form['migrate_submit'] = array(
    '#type' => 'submit',
    '#value' => t('Migrate'),
    '#access' => count($options) > 1,
  );
  return $form;
}