You are here

function _taxonomy_xml_get_term_placeholder in Taxonomy import/export via XML 7

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

Either fetch the named term if it exists, or return a useful placeholder.

The returned term has a 'synonyms_array' because that's easier to work with than string concats in odd places.

If $new = TRUE, then always return a fresh placeholder, do not attempt a string name lookup. Default is $new = FALSE, which attempts re-use of existing terms.

6 calls to _taxonomy_xml_get_term_placeholder()
csvancestry_set_parent in formats/csvancestry_format.inc
Set the parent of this term. $term must be a valid term. parent term may be invented on the fly.
cvsancestry_import_row in formats/csvancestry_format.inc
taxonomy_xml_csv_parse in formats/csv_format.inc
Scan the input CSV file and create a taxonomy structure out of it.
taxonomy_xml_mesh_parse in formats/mesh_format.inc
Reads a XML file and creates the term definitions found in it.
taxonomy_xml_rdf_make_term in formats/rdf_format.inc
Create the placeholder and fill in the values for this term.

... See full list

File

./taxonomy_xml.process.inc, line 697
The workhorse processes for importing taxonomies.

Code

function _taxonomy_xml_get_term_placeholder($name, $vid = 0, $new = FALSE) {

  // dpm("Getting placeholder '$name' vocab:$vid");
  if (!$new) {

    // Look for a pre-existing term by that name.
    if ($name) {
      $term = taxonomy_xml_get_term_by_name_from_vocab($name, $vid);
    }
    else {

      // Assert input is OK. Just paranoia.
      drupal_set_message(t("Asked to make a term with no name ... that can't be right. I refuse!"), 'error');
      return NULL;
    }
  }
  if (empty($term)) {
    $term = (object) array(
      'name' => $name,
      'vid' => $vid,
      'description' => '',
      'weight' => 0,
      'predicates' => array(),
      'synonyms_array' => array(),
    );
  }
  else {

    #drupal_set_message(t("A term called '!name' already exists. We will just update information onto it.", array('!name' => l($term->name, TAXONOMY_XML_ADMIN . '/edit/term/' . $term->tid) )), 'trace');
  }
  return $term;
}