function biblio_create_imported_keywords in Bibliography Module 7.2
1 call to biblio_create_imported_keywords()
- biblio_save_node in includes/
biblio.import.export.inc
File
- includes/
biblio.import.export.inc, line 960 - Functions that are used to import and export biblio data.
Code
function biblio_create_imported_keywords(&$biblio) {
$vocab = taxonomy_vocabulary_machine_name_load('biblio_keywords');
if (isset($biblio->biblio_keywords) && $vocab) {
$wrapper = biblio_wrapper($biblio);
foreach ($biblio->biblio_keywords as $delta => $keyword) {
$existing_terms = taxonomy_get_term_by_name($keyword, 'biblio_keywords');
$first_existing_term = reset($existing_terms);
$term = new stdClass();
$term->vid = $vocab->vid;
$term->name = $keyword;
if ($first_existing_term) {
// Term already exists.
$term->tid = $first_existing_term->tid;
}
else {
taxonomy_term_save($term);
}
$wrapper->biblio_keywords[$delta]
->set($term->tid);
}
}
}