You are here

function taxonomy_xml_formats in Taxonomy import/export via XML 6.2

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

Return a list of available file formats.

Scan the module directory for appropriate inc files. More can be added as appropriate.

A taxonomy_xml *_format.inc file should prvide an implimentation of the hooks taxonomy_xml_FORMAT_parse() and/or taxonomy_xml_FORMAT_create() to support reading or writing respectively.

It may also check for further dependencies (ARC) as needed.

Return value

an Array ( [csv_format] => CSV [rdf_format] => RDF [xml_format] => XML )

1 call to taxonomy_xml_formats()
taxonomy_xml_import_form in ./taxonomy_xml.module
Builds the import form.

File

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

Code

function taxonomy_xml_formats() {
  $module_dir = drupal_get_path('module', 'taxonomy_xml');
  $incs = file_scan_directory($module_dir, '.*_format.inc');
  $formats = array();
  foreach ($incs as $filepath => $file) {
    include_once $file->filename;
    $format_name = preg_replace('/_format$/', '', $file->name);
    $funcname = "taxonomy_xml_{$format_name}_requirements";
    $error = function_exists($funcname) ? $funcname() : NULL;
    if (empty($error)) {
      $formats[$format_name] = drupal_strtoupper($format_name);
    }
    else {
      drupal_set_message($error['taxonomy_xml_' . $format_name]['description'], 'warning');
    }
  }
  return $formats;
}