function taxonomy_csv_import_line in Taxonomy CSV import/export 5
1 call to taxonomy_csv_import_line()
- taxonomy_csv_import_submit in ./
taxonomy_csv.module - Handles CSV import form submission.
File
- ./
taxonomy_csv.module, line 214 - Quick import of lists of terms from a csv file.
Code
function taxonomy_csv_import_line($line, $options) {
// Convert line to UTF-8.
$line = array_map('_taxonomy_csv_import_line_to_utf8', $line);
if ($options['columns'] == TAXONOMY_CSV_CHILDREN) {
$parent = 0;
for ($c = 0; $c < count($line); $c++) {
if (empty($line[$c])) {
break;
}
$term = array(
'name' => $line[$c],
'vid' => $options['vid'],
'parent' => $parent,
);
// Parent terms (so all terms but the last on this line) are always updated.
$term = taxonomy_csv_import_term($term, $options['update'] || $c < count($line) - 1);
$parent = $term['tid'];
}
}
else {
if ($options['columns'] == TAXONOMY_CSV_WEIGHTS) {
if (count($line) > 1 && !empty($line[1])) {
$term = array(
'name' => $line[0],
'vid' => $options['vid'],
'weight' => $line[1],
);
taxonomy_csv_import_term($term, $options['update']);
}
}
else {
if (!empty($line[0])) {
$term = array(
'name' => $line[0],
'vid' => $options['vid'],
);
if ($options['columns'] == TAXONOMY_CSV_FIELDS) {
if (count($line) > 1 && !empty($line[1])) {
$term['description'] = $line[1];
}
if (count($line) > 2) {
$term['synonyms'] = implode("\n", array_filter(array_slice($line, 2)));
}
}
taxonomy_csv_import_term($term, $options['update']);
}
}
}
}