You are here

function taxonomy_xml_file in Taxonomy import/export via XML 6.2

Same name and namespace in other branches
  1. 5.2 taxonomy_xml.module \taxonomy_xml_file()
  2. 5 taxonomy_xml.module \taxonomy_xml_file()
  3. 6 taxonomy_xml.module \taxonomy_xml_file()

Return a flat file representation of the requested vocab

Default format is the original custom Drupal XML file.

1 string reference to 'taxonomy_xml_file'
taxonomy_xml_menu in ./taxonomy_xml.module
Implementation of hook_menu: Define menu links.

File

./taxonomy_xml.module, line 250
This module makes it possible to import and export taxonomies as XML documents.

Code

function taxonomy_xml_file($vid, $format = 'xml') {

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

  // Load the appropriate library, guess at the format name file
  module_load_include('inc', 'taxonomy_xml', $format . '_format');
  taxonomy_xml_include_module_hooks();
  $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: ' . drupal_strlen($file));
  header("Content-Disposition: attachment; filename=taxonomy_{$vname}.{$format}.xml");
  echo $file;
}