You are here

function taxonomy_node_import_values_alter in Node import 6

Implementation of hook_node_import_values_alter().

File

supported/taxonomy.inc, line 589
Support file for the core taxonomy module.

Code

function taxonomy_node_import_values_alter(&$values, $type, $defaults, $options, $fields, $preview) {
  if (strpos($type, 'term:') === 0) {
    if (!$preview) {
      $values['synonyms'] = implode("\n", (array) $values['synonyms']);
      $values['parent'] = array(
        $values['parent'],
      );
    }
  }
  else {
    if (($node_type = node_import_type_is_node($type)) !== FALSE) {
      $taxonomy = isset($values['taxonomy']) ? $values['taxonomy'] : array();
      foreach ($fields as $fieldname => $fieldinfo) {
        if (strpos($fieldname, 'taxonomy:') === 0) {
          $vocab = $fieldinfo['vocabulary'];
          if ($vocab->tags) {
            $taxonomy['tags'] = isset($taxonomy['tags']) ? $taxonomy['tags'] : array();
            $taxonomy['tags'][$vocab->vid] = implode(',', (array) $values[$fieldname]);
          }
          else {
            $taxonomy[$vocab->vid] = $values[$fieldname];
          }
          unset($values[$fieldname]);
        }
      }
      $values['taxonomy'] = $taxonomy;
    }
  }
}