You are here

function bulk_export_export_form in Chaos Tool Suite (ctools) 7

Same name and namespace in other branches
  1. 6 bulk_export/bulk_export.module \bulk_export_export_form()

FAPI definition for the bulk exporter form.

1 string reference to 'bulk_export_export_form'
bulk_export_export in bulk_export/bulk_export.module
FAPI gateway to the bulk exporter.

File

bulk_export/bulk_export.module, line 197
Perform bulk exports.

Code

function bulk_export_export_form($form, &$form_state) {
  $files = system_rebuild_module_data();
  $form['additional_settings'] = array(
    '#type' => 'vertical_tabs',
  );
  $options = $tables = array();
  foreach ($form_state['exportables'] as $table => $list) {
    if (empty($list)) {
      continue;
    }
    foreach ($list as $id => $title) {
      $options[$table][$id] = array(
        $title,
      );
      $options[$table][$id]['#attributes'] = array(
        'class' => array(
          'bulk-selection',
        ),
      );
    }
    $module = $form_state['export_tables'][$table];
    $header = array(
      $table,
    );
    $module_name = $files[$module]->info['name'];
    $tables[] = $table;
    if (!isset($form[$module_name])) {
      $form[$files[$module]->info['name']] = array(
        '#type' => 'fieldset',
        '#group' => 'additional_settings',
        '#title' => $module_name,
      );
    }
    $form[$module_name]['tables'][$table] = array(
      '#prefix' => '<div class="export-container">',
      '#suffix' => '</div>',
      '#type' => 'tableselect',
      '#header' => $header,
      '#options' => $options[$table],
    );
  }
  $form['tables'] = array(
    '#type' => 'value',
    '#value' => $tables,
  );
  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Module name'),
    '#description' => t('Enter the module name to export code to.'),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Export'),
  );
  $form['#action'] = url('admin/structure/bulk-export/results');
  $form['#attached']['css'][] = drupal_get_path('module', 'bulk_export') . '/bulk_export.css';
  $form['#attached']['js'][] = drupal_get_path('module', 'bulk_export') . '/bulk_export.js';
  return $form;
}