You are here

function globallink_settings_export_process in GlobalLink Connect for Drupal 7.7

Export csv batch process start.

1 string reference to 'globallink_settings_export_process'
export_csv_button_submit in ./globallink_settings.inc
Export csv batch set.

File

./globallink_settings.inc, line 840

Code

function globallink_settings_export_process($progress, $limit, $resultArray, &$context) {
  $publicPath = variable_get('file_public_path', conf_path() . '/files/');
  $defaultPath = $publicPath . 'export/';
  if (!is_dir($defaultPath)) {
    drupal_mkdir($defaultPath, NULL, TRUE);
  }
  $fileNameCore = $defaultPath . 'globallink_core.csv';
  $filePathCore = fopen($fileNameCore, 'w') or die('Cant open file!');
  fputcsv($filePathCore, array(
    'rid',
    'nid',
    'vid',
    'source',
    'target',
    'last modified',
    'changed',
  ));
  foreach ($resultArray['resultCore'] as $record) {
    fputcsv($filePathCore, array(
      $record->rid,
      $record->nid,
      $record->vid,
      $record->source,
      $record->target,
      $record->last_modified,
      $record->changed,
    ));
  }
  fclose($filePathCore);
  $fileNameSubmission = $defaultPath . 'globallink_submission.csv';
  $filePathSubmission = fopen($fileNameSubmission, 'w') or die('Cant open file!');
  fputcsv($filePathSubmission, array(
    'rid',
    'submission',
    'submission_ticket',
    'source_lang_code',
    'source_lang_name',
    'sub_target_lang_code',
    'sub_target_lang_name',
    'project_code',
    'project_name',
    'due_date',
    'status',
    'created',
    'updated',
  ));
  foreach ($resultArray['resultCoreSubmission'] as $record) {
    fputcsv($filePathSubmission, array(
      $record->rid,
      $record->submission,
      $record->submission_ticket,
      $record->souce_lang_code,
      $record->source_lang_name,
      $record->sub_target_lang_code,
      $record->sub_target_lang_name,
      $record->project_code,
      $record->project_name,
      $record->due_date,
      $record->status,
      $record->created,
      $record->updated,
    ));
  }
  fclose($filePathSubmission);
  $fileNameDocument = $defaultPath . 'globallink_document.csv';
  $filePathDocument = fopen($fileNameDocument, 'w') or die('Cant open file!');
  fputcsv($filePathDocument, array(
    'rid',
    'submission_rid',
    'document_ticket',
    'entity_type',
    'entity_type_name',
    'object_type',
    'object_type_name',
    'object_id',
    'object_parent_id',
    'object_version_id',
    'object_title',
    'target_lang_code',
    'target_status',
    'target_ticket',
    'target_last_sent',
    'target_last_updated',
  ));
  foreach ($resultArray['resultCoreDocument'] as $record) {
    fputcsv($filePathDocument, array(
      $record->rid,
      $record->submission_rid,
      $record->document_ticket,
      $record->entity_type,
      $record->entity_type_name,
      $record->object_type,
      $record->object_type_name,
      $record->object_id,
      $record->object_parent_id,
      $record->object_version_id,
      $record->object_title,
      $record->target_lang_code,
      $record->target_status,
      $record->target_ticket,
      $record->target_last_sent,
      $record->target_last_updated,
    ));
  }
  fclose($filePathDocument);
  $fileNameFieldConfig = $defaultPath . 'globallink_field_config.csv';
  $filePathFieldConfig = fopen($fileNameFieldConfig, 'w') or die('Cant open file!');
  fputcsv($filePathFieldConfig, array(
    'fid',
    'contect type',
    'entity type',
    'node type',
    'filed name',
    'filed type',
    'filed lable',
    'filed formate',
    'translatable',
  ));
  foreach ($resultArray['resultFieldConfig'] as $record) {
    fputcsv($filePathFieldConfig, array(
      $record->fid,
      $record->content_type,
      $record->entity_type,
      $record->bundle,
      $record->field_name,
      $record->field_type,
      $record->field_label,
      $record->field_format,
      $record->translatable,
    ));
  }
  fclose($filePathFieldConfig);
  $fileNameLocale = $defaultPath . 'globallink_locale.csv';
  $filePathLocale = fopen($fileNameLocale, 'w') or die('Cant open file!');
  fputcsv($filePathLocale, array(
    'local code',
    'local description',
    'drupal local code',
    'drupal local description',
  ));
  foreach ($resultArray['resultLocale'] as $record) {
    fputcsv($filePathLocale, array(
      $record->locale_code,
      $record->locale_desc,
      $record->drupal_locale_code,
      $record->drupal_locale_desc,
    ));
  }
  fclose($filePathLocale);
  $progress = $progress + $limit;
  $context['message'] = 'Now processing ' . $progress . ' - ' . $context['results'][0] . ' Updated';
}