function taxonomy_feeds_node_get_terms in Feeds 7.2
Finds all terms associated with the given node, within one vocabulary.
1 call to taxonomy_feeds_node_get_terms()
- taxonomy_feeds_get_source in mappers/
taxonomy.inc - Callback, returns taxonomy from feed node.
File
- mappers/
taxonomy.inc, line 219 - On behalf implementation of Feeds mapping API for taxonomy.module.
Code
function taxonomy_feeds_node_get_terms($node, $key = 'tid') {
$terms =& drupal_static(__FUNCTION__);
if (!isset($terms[$node->nid][$key])) {
// Get tids from all taxonomy_term_reference fields.
$tids = array();
$fields = field_info_fields();
foreach ($fields as $field_name => $field) {
if ($field['type'] == 'taxonomy_term_reference' && field_info_instance('node', $field_name, $node->type)) {
if (($items = field_get_items('node', $node, $field_name)) && is_array($items)) {
$tids = array_merge($tids, array_map('_taxonomy_feeds_extract_tid', $items));
}
}
}
// Load terms and cache them in static var.
$curr_terms = taxonomy_term_load_multiple($tids);
$terms[$node->nid][$key] = array();
foreach ($curr_terms as $term) {
$terms[$node->nid][$key][$term->{$key}] = $term;
}
}
return $terms[$node->nid][$key];
}