You are here

function taxonomy_xml_export_vocabulary in Taxonomy import/export via XML 7

Return a flat file representation of the requested vocab.

Default format is the original custom Drupal XML file.

Constructs and prints result to the screen, with appropriate headers.

2 calls to taxonomy_xml_export_vocabulary()
taxonomy_server_export_vocabulary in taxonomy_server/taxonomy_server.module
Returns an RDF representation of the vocab
taxonomy_server_vocabulary_page in taxonomy_server/taxonomy_server.module
Display a page showing one or all available vocabularies
1 string reference to 'taxonomy_xml_export_vocabulary'
taxonomy_xml_menu in ./taxonomy_xml.module
Implements hook_menu().

File

./taxonomy_xml.export.inc, line 54
Helper functions for vocab exports.

Code

function taxonomy_xml_export_vocabulary($vocabulary, $format = 'xml') {
  $vocabulary = is_numeric($vocabulary) ? taxonomy_vocabulary_load($vocabulary) : $vocabulary;
  $vid = $vocabulary->vid;

  // Retrieving Vocabulary name.
  $vname = drupal_strtolower(str_replace(' ', '_', trim($vocabulary->name)));

  // Load the appropriate library, guess at the format name file.
  module_load_include('inc', 'taxonomy_xml', 'formats/' . $format . '_format');
  $create_funcname = "taxonomy_xml_{$format}_create";
  $file = $create_funcname($vid);
  if (!empty($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 5.5') || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera'))) {
    header('Content-Type: application/dummy');
  }
  else {
    header('Content-Type: text/xml; charset=UTF-8');
  }
  if (headers_sent()) {
    echo 'Some data has already been output to browser, can\'t send file';
  }
  header('Content-Length: ' . strlen($file));
  header("Content-Disposition: attachment; filename=taxonomy_{$vname}.{$format}.xml");
  echo $file;
}