You are here

function taxonomy_xml_invoke_import in Taxonomy import/export via XML 5.2

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

Do the actual importing from the given string, pased on the parameters passed from the form.

1 call to taxonomy_xml_invoke_import()
taxonomy_xml_import_form_validate in ./taxonomy_xml.module
Imports the actual XML.

File

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

Code

function taxonomy_xml_invoke_import($text, $form_values) {
  $vid = $form_values['vid'];
  if ($vid == -1) {

    // Requested to create new vocab.
    $vocabulary = _taxonomy_xml_get_vocabulary_placeholder(basename($form_values['file']->filename));
    $vid = $vocabulary->vid;
  }

  // Sitemenu implodes when I try to do bulk updates? Or is it pathauto
  // TODO figure this out
  module_disable(array(
    'sitemenu',
    'pathauto',
  ));

  // Conditionally include and invoke the appropriate format library
  $incfile = dirname(drupal_get_filename('module', 'taxonomy_xml')) . '/' . $form_values['format'] . '.inc';
  include_once $incfile;
  $format_name = preg_replace('/_format$/', '', $form_values['format']);
  $funcname = "taxonomy_xml_{$format_name}_parse";
  if (function_exists($funcname)) {
    $success = $funcname($text, $vid, NULL, $form_values['duplicate']);
    if ($success) {
      drupal_set_message(t("Taxonomy Import successful. %success terms created in vocabulary ", array(
        '%success' => $success,
      )));
    }
    else {
      drupal_set_message(t("Failed to import any new terms. This may be due to syntax or formattings errors in the import file.", array()), 'error');
    }
  }
  else {
    drupal_set_message("Unavailable format. {$funcname} was not found in formatting library {$incfile}.", 'error');
  }
}