You are here

function taxonomy_csv_export in Taxonomy CSV import/export 6.5

Same name and namespace in other branches
  1. 6.2 export/taxonomy_csv.export.api.inc \taxonomy_csv_export()
  2. 6.3 export/taxonomy_csv.export.api.inc \taxonomy_csv_export()
  3. 6.4 export/taxonomy_csv.export.api.inc \taxonomy_csv_export()
  4. 7.5 export/taxonomy_csv.export.api.inc \taxonomy_csv_export()
  5. 7.4 export/taxonomy_csv.export.api.inc \taxonomy_csv_export()

Process the export of a vocabulary.

If not used in a form, don't forget to use batch_process().

Parameters

$options: An associative array of options:

  • export_format : see _taxonomy_csv_values('export_format')
  • vocabulary_id : vocabulary id to export (default: 0, which means all)
  • delimiter : one character csv delimiter (default: ',')
  • enclosure : zero or one character csv enclosure (default: '"')
  • line_ending : 'Unix' (default), 'Mac' or 'MS-DOS'
  • order : order of terms: 'name' (default), 'tid' or 'weight'

// Specific to def_links:

  • def_links_terms_ids : 'name_if_needed' (default), 'name' or 'tid'
  • def_links_vocabularies_ids : 'none' (default), 'name' or 'vid'

// Level of result process infos:

  • check_options : boolean. check or not (default) this array of options
  • result_display: boolean. display or not (default). Only used with UI
  • result_duplicates: boolean. display or not (default) duplicate terms

All options have default values. Warning: default values are different with UI.

Return value

Array of errors or file object to download (need to execute batch process; result is logged in watchdog).

1 call to taxonomy_csv_export()
drush_taxonomy_csv_export in ./taxonomy_csv.drush.inc
Process the export of a vocabulary.

File

export/taxonomy_csv.export.api.inc, line 46
Validate export options and manage export process.

Code

function taxonomy_csv_export($options) {

  // Complete $options with default values if needed.
  // Default api and UI options are different.
  $options += _taxonomy_csv_values('export_default_api');

  // Presave a file in order to check access to temporary folder.
  $messages = _taxonomy_csv_export_output_presave($options);
  if (count($messages)) {
    return $messages;
  }

  // Process export.
  $messages = taxonomy_csv_vocabulary_export($options);

  // Return errors if any.
  if (count($messages)) {
    return $messages;
  }
  else {
    return $options['file'];
  }
}