You are here

function taxonomy_xml_get_term_guid in Taxonomy import/export via XML 7

Same name and namespace in other branches
  1. 6.2 taxonomy_xml.module \taxonomy_xml_get_term_guid()

Return (and remember) the guid associated with this term.

Abstracted into a getter, because it may be serialized in different ways.

If the term has an internal field storing someone elses guid, return that. Otherwise, return our local path for it.

3 calls to taxonomy_xml_get_term_guid()
taxonomy_xml_rdf_add_terms in formats/rdf_format.inc
Append definitions of a list of terms on to a DOM container.
taxonomy_xml_rdf_make_term in formats/rdf_format.inc
Create the placeholder and fill in the values for this term.
taxonomy_xml_taxonomy_term_load in ./taxonomy_xml.module
Appends any missing data to the given term - by ref.

File

./taxonomy_xml.module, line 413
Make it possible to import and export taxonomies as XML documents.

Code

function taxonomy_xml_get_term_guid(&$term) {
  $term = is_numeric($term) ? taxonomy_term_load($term) : $term;
  if (isset($term->guid)) {
    return $term->guid;
  }

  // HERE is where we use the 'fieldable' term field to access our guid.
  if (!empty($term->field_guid)) {

    // What the hell is 'und'? - "Undefined language'!
    $term->guid = $term->field_guid['und'][0]['value'];
  }

  // Otherwise return a guid pointing to ourself as a source for this term.
  if (empty($term->guid)) {
    $term_guid = taxonomy_term_uri($term);
    $term->guid = url($term_guid['path'], array(
      'absolute' => TRUE,
    ));
  }
  return $term->guid;
}