You are here

function export_csv_button_submit in GlobalLink Connect for Drupal 7.7

Export csv batch set.

1 string reference to 'export_csv_button_submit'
globallink_useful_tools in ./globallink_settings.inc
Globallink Useful Tools form.

File

./globallink_settings.inc, line 797

Code

function export_csv_button_submit($form, &$form_state) {
  $db_tables = array(
    'globallink_core',
    'globallink_core_block',
    'globallink_core_entity',
    'globallink_core_fieldable_panels',
    'globallink_core_interface',
    'globallink_core_menu',
    'globallink_core_taxonomy',
    'globallink_core_webform',
    'globallink_field_config',
    'globallink_locale',
  );
  $batch = array(
    'operations' => array(),
    'finished' => 'globallink_settings_export_batch_finished',
    'title' => t('Export Csv'),
    'init_message' => t('Export Csv is starting.'),
    'progress_message' => t('Processed @current out of @total.'),
    'error_message' => t('Export Csv has encountered an error.'),
    'file' => drupal_get_path('module', 'globallink') . '/globallink_settings.inc',
  );
  $progress = 0;
  $limit = 10;
  $resultCore = db_query("SELECT * FROM {globallink_core}")
    ->fetchAll();
  $resultSubmission = db_query("SELECT * FROM {globallink_submission}")
    ->fetchAll();
  $resultDocument = db_query("SELECT * FROM {globallink_document}")
    ->fetchAll();
  $resultFieldConfig = db_query("SELECT * FROM {globallink_field_config}")
    ->fetchAll();
  $resultLocale = db_query("SELECT * FROM {globallink_locale}")
    ->fetchAll();
  $countArray = array(
    count($resultCore),
    count($resultSubmission),
    count($resultDocument),
    count($resultFieldConfig),
    count($resultLocale),
  );
  $resultArray = array(
    'resultCore' => $resultCore,
    'resultCoreSubmission' => $resultSubmission,
    'resultCoreDocument' => $resultDocument,
    'resultFieldConfig' => $resultFieldConfig,
    'resultLocale' => $resultLocale,
  );
  $max = max($countArray);
  while ($progress <= $max) {
    $batch['operations'][] = array(
      'globallink_settings_export_process',
      array(
        $progress,
        $limit,
        $resultArray,
      ),
    );
    $progress = $progress + $limit;
  }
  batch_set($batch);
}