You are here

function configuration_migrate_form in Configuration Management 7

Menu Callback Form.

1 string reference to 'configuration_migrate_form'
configuration_menu in ./configuration.module
Implements hook_menu().

File

./configuration.admin.inc, line 248

Code

function configuration_migrate_form($form, &$form_state) {
  module_load_include('inc', 'configuration', 'configuration.export');
  configuration_include();
  $form['header'] = array(
    '#markup' => t('Choose all the configurations you would like to package up to import into another site.'),
    '#prefix' => '<div>',
    '#suffix' => '</div>',
  );
  $form['packages'] = array(
    '#type' => 'vertical_tabs',
  );
  $form['#attached']['css'] = array(
    drupal_get_path('module', 'configuration') . '/theme/configuration.css',
  );
  $components = configuration_get_components();
  ksort($components);
  $js_settings = array();
  foreach ($components as $component => $component_info) {
    $options = configuration_invoke($component, 'configuration_export_options');
    if (is_array($options)) {
      $form[$component] = array(
        '#type' => 'fieldset',
        '#group' => 'packages',
        '#title' => check_plain($component_info['name']),
        '#description' => t('Choose the %config_type configurations that you would like to track.', array(
          '%config_type' => $component_info['name'],
        )),
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
        '#tree' => TRUE,
        '#attached' => array(
          'js' => array(
            'vertical-tabs' => drupal_get_path('module', 'configuration') . '/theme/vertical-tabs.js',
          ),
        ),
      );

      // Get the defaults not in activestore. Can't export these until they
      // are put into the activestore.
      $map = configuration_get_default_map($component);
      $has_items = FALSE;
      $items = $noactive_items = array();
      foreach ($options as $option => $label) {
        $items[$option] = array(
          'name' => $label,
        );
        $has_items = TRUE;
      }
      if (!$has_items) {
        $form[$component]['#description'] = t('No configurations.');
      }
      $header = array(
        'name' => t('Configuration Name'),
      );
      if ($has_items) {
        $form[$component]['items'] = array(
          '#type' => 'tableselect',
          '#header' => $header,
          '#options' => configuration_dom_encode_options($items),
          '#attributes' => array(
            'id' => 'configuration-export-table-select-' . $component,
          ),
        );
      }
    }

    // Set variables in in js for setting the tab summaries
    $js_settings['configuration'][$component] = $component;
  }
  drupal_add_js($js_settings, 'setting');
  $form['buttons'] = array(
    '#theme' => 'configuration_form_buttons',
    '#tree' => FALSE,
  );
  $form['buttons']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Download Configurations'),
    '#weight' => 10,
  );
  $form['#validate'][] = 'configuration_notracking_form_validate';
  return $form;
}