function taxonomy_xml_get_term_by_uri in Taxonomy import/export via XML 6
Special lookup for terms if they are saved with a URI or GUID
Very specific to certain ways of serializing terms, REQUIRES taxonomy_enhancer and a field called field_URI
2 calls to taxonomy_xml_get_term_by_uri()
- taxonomy_xml_add_all_children_to_queue in ./
taxonomy_xml.module - If the currently processing term refers to other terms by URI, set up a process to retrieve them recursively later.
- taxonomy_xml_set_term_relations in ./
taxonomy_xml.module - Given a list of terms, set the related-terms and structure, and save again
File
- ./
taxonomy_xml.module, line 1042 - taxonomy_xml.module This module makes it possible to import and export taxonomies as XML documents.
Code
function taxonomy_xml_get_term_by_uri($uri) {
if (!$uri) {
return NULL;
}
// taxonomy_enhancer.module, if available, may have more data about our terms. Hopefully including a GUID.
if (module_exists('taxonomy_enhancer')) {
$searchterm = (object) array(
'field_uri' => $uri,
);
$results = taxonomy_enhancer_get_term($searchterm);
if (!empty($results)) {
#drupal_set_message(t("Successfully found a known target term indexed by external <a href='!uri'>URI</a>.", array('!uri' => $uri)));
$term = array_pop($results);
}
else {
#dpm("Couldn't find a known item with a URI = $uri ");
}
}
return isset($term) ? $term : NULL;
}