You are here

function _taxonomy_csv_term_format_regular in Taxonomy CSV import/export 7.4

Format an internal term to a regular term (synonyms and relations).

Use of real values is simpler to manage than field subarrays.

Parameters

$term: The term object to format.

Return value

Formatted term object.

1 call to _taxonomy_csv_term_format_regular()
_taxonomy_csv_term_save in ./taxonomy_csv.term.api.inc
Save by reference an internally formatted term object.

File

./taxonomy_csv.term.api.inc, line 331
Find, get and set full or detail term items.

Code

function _taxonomy_csv_term_format_regular($term) {
  $langcode = 'und';
  if (isset($term->parents) && count($term->parents) > 0) {
    $term->parent = $term->parents;
    unset($term->parents);
  }
  else {
    $term->parent = array(
      0,
    );
    unset($term->parents);
  }
  if (isset($term->synonyms)) {
    $field = taxonomy_csv_term_set_field_values($term, 'synonyms', $langcode);
    $term->taxonomy_synonym[$langcode] = $field ? array_shift($field) : array();
    unset($term->synonyms);
  }
  if (isset($term->relations)) {
    $field = taxonomy_csv_term_set_field_values($term, 'relations', $langcode);
    $term->taxonomy_relation[$langcode] = $field ? array_shift($field) : array();
    unset($term->relations);
  }
  return $term;
}