function taxonomy_xml_export_term in Taxonomy import/export via XML 7
Same name and namespace in other branches
- 6.2 taxonomy_xml.module \taxonomy_xml_export_term()
Return a representation of the requested term.
Constructs and prints result to the screen, with appropriate headers.
@todo UNFINISHED, currently a stub copy from full vocab export
2 calls to taxonomy_xml_export_term()
- taxonomy_server_export_term in taxonomy_server/
taxonomy_server.module - Returns an RDF representation of the term
- taxonomy_server_term_page in taxonomy_server/
taxonomy_server.module - An override of taxonomy_term_page. Checks if we can give the client another version of this data.
File
- ./
taxonomy_xml.export.inc, line 86 - Helper functions for vocab exports.
Code
function taxonomy_xml_export_term($term, $format = 'rdf') {
$term = is_numeric($term) ? taxonomy_term_load($term) : $term;
if (empty($term)) {
trigger_error("NULL term loaded");
dpm(func_get_args());
return "Failed";
}
// Retrieving Vocabulary name.
$vocabulary = taxonomy_vocabulary_load($term->vid);
$vname = drupal_strtolower(str_replace(' ', '_', trim($vocabulary->name)));
module_load_include('inc', 'taxonomy_xml', 'formats/' . $format . '_format');
$create_funcname = "taxonomy_xml_{$format}_create_term";
if (!function_exists($create_funcname)) {
trigger_error("The {$format} format does not currently support exporting individual terms");
return "Failed to export term '{$term->name}' ({$term->tid}) as {$format}";
}
$file = $create_funcname($term);
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;
}