function bib2node($terms = array(), $batch = FALSE, $session_id = NULL, $save = TRUE, $start = 0, $limit = 0) { //list($preamble, $strings, $entries, $undefinedStrings) = $this->returnArrays(); $limit = $limit ? $limit : count($this->entries); if ($start + $limit > count($this->entries)) { $limit = count($this->entries) - $start; } for ($i = $start; $i < $limit; $i++) { $node = array(); $entry = $this->entries[$i]; if ($this->removeDelimit || $this->expandMacro && $this->fieldExtract) { foreach ($entry as $key => $value) { if ($key != 'bibtexCitation' && $key != 'bibtexEntryType') { $entry[$key] = trim($this->removeDelimitersAndExpand($entry[$key])); } } } // hook_biblio_bibtex_import_pre. Allows to define new or change // types, e.g. split @incollection from @book and put in a custom type. // We don't use module_invoke_all to enable passing by reference. foreach (module_implements('biblio_bibtex_import_pre') as $module) { $function = $module . '_biblio_bibtex_import_pre'; $function($entry, $node); } //foreach($entries as $entry){ $node['biblio_contributors'] = array(); $node['biblio_type'] = $this->bibtex_type_map($entry['bibtexEntryType']); switch ($entry['bibtexEntryType']) { case 'mastersthesis': $node['biblio_type_of_work'] = 'masters'; break; case 'phdthesis': $node['biblio_type_of_work'] = 'phd'; break; } if (!empty($entry['author'])) { // split on ' and ' $authorArray = preg_split("/\\s(and|&)\\s/i", trim($entry['author'])); foreach ($authorArray as $key => $author) { $node['biblio_contributors'][1][] = array('name' => $author, 'auth_type' => _biblio_get_auth_type(1, $node['biblio_type'])); } } $node['biblio_citekey'] = !empty($entry['bibtexCitation']) ? $entry['bibtexCitation'] : NULL; if (!empty($entry['editor'])) { $authorArray = preg_split("/\\s(and|&)\\s/i", trim($entry['editor'])); foreach ($authorArray as $key => $author) { $node['biblio_contributors'][2][] = array('name' => $author, 'auth_type' => _biblio_get_auth_type(2, $node['biblio_type'])); } } $node['biblio_secondary_title'] = !empty($entry['journal']) ? $entry['journal'] : NULL; if (!empty($entry['booktitle'])) { $node['biblio_secondary_title'] = $entry['booktitle']; } if (!empty($entry['series'])) { $node['biblio_tertiary_title'] = $entry['series']; } $node['biblio_volume'] = !empty($entry['volume']) ? $entry['volume'] : NULL; $node['biblio_number'] = !empty($entry['number']) ? $entry['number'] : NULL; $node['biblio_year'] = !empty($entry['year']) ? $entry['year'] : NULL; $node['biblio_notes'] = !empty($entry['note']) ? $entry['note'] : NULL; $node['biblio_date'] = !empty($entry['month']) ? $entry['month'] : NULL; $node['biblio_pages'] = !empty($entry['pages']) ? $entry['pages'] : NULL; $node['biblio_publisher'] = !empty($entry['publisher']) ? $entry['publisher'] : NULL; if (!empty($entry['organization'])) { $node['biblio_publisher'] = $entry['organization']; } if (!empty($entry['school'])) { $node['biblio_publisher'] = $entry['school']; } if (!empty($entry['institution'])) { $node['biblio_publisher'] = $entry['institution']; } $node['title'] = !empty($entry['title']) ? $entry['title'] : NULL; $node['biblio_type_of_work'] .= !empty($entry['type']) ? $entry['type'] : NULL; $node['biblio_edition'] = !empty($entry['edition']) ? $entry['edition'] : NULL; $node['biblio_section'] = !empty($entry['chapter']) ? $entry['chapter'] : NULL; $node['biblio_place_published'] = !empty($entry['address']) ? $entry['address'] : NULL; $node['biblio_abst_e'] = !empty($entry['abstract']) ? $entry['abstract'] : NULL; if (!empty($entry['keywords'])) { if (strpos($entry['keywords'], ';')) { $entry['keywords'] = str_replace(';', ',', $entry['keywords']); } $node['biblio_keywords'] = explode(',', $entry['keywords']); } $node['biblio_isbn'] = !empty($entry['isbn']) ? $entry['isbn'] : NULL; $node['biblio_issn'] = !empty($entry['issn']) ? $entry['issn'] : NULL; $node['biblio_url'] = !empty($entry['url']) ? $entry['url'] : NULL; $node['biblio_doi'] = !empty($entry['doi']) ? $entry['doi'] : NULL; if (!empty($terms)) { if (!isset($node['taxonomy'])) { $node['taxonomy'] = array(); } $node['taxonomy'] = array_merge($terms, $node['taxonomy']); } // Allow other modules to adjust the bibtex entries. Functions must // be named modulename_biblio_bibtex_import. foreach (module_implements('biblio_bibtex_import') as $module) { $function = $module . '_biblio_bibtex_import'; $function($entry, $node); } $nid = biblio_save_node($node, $batch, $session_id, $save); if (isset($nid)) { $nids[] = $nid; } } return !empty($nids) ? $nids : NULL; }
function bib2node($terms = array(), $batch = FALSE, $session_id = NULL, $save = TRUE, $start = 0, $limit = 0) { //list($preamble, $strings, $entries, $undefinedStrings) = $this->returnArrays(); $limit = $limit ? $limit : count($this->entries); if ($start + $limit > count($this->entries)) { $limit = count($this->entries) - $start; } for ($i = $start; $i < $limit; $i++) { $node = array(); $entry = $this->entries[$i]; if ($this->removeDelimit || $this->expandMacro && $this->fieldExtract) { foreach ($entry as $key => $value) { if ($key != 'bibtexCitation' && $key != 'bibtexEntryType') { $entry[$key] = trim($this->removeDelimitersAndExpand($entry[$key])); } } } //foreach($entries as $entry){ $node['biblio_contributors'] = array(); $node['biblio_type'] = $this->bibtex_type_map($entry['bibtexEntryType']); switch ($entry['bibtexEntryType']) { case mastersthesis: $node['biblio_type_of_work'] = 'masters'; break; case phdthesis: $node['biblio_type_of_work'] = 'phd'; break; } if (!empty($entry['author'])) { // split on ' and ' $authorArray = preg_split("/\\s(and|&)\\s/i", trim($entry['author'])); foreach ($authorArray as $key => $author) { $node['biblio_contributors'][1][] = array('name' => $author, 'auth_type' => _biblio_get_auth_type(1, $node['biblio_type'])); } } $node['biblio_citekey'] = !empty($entry['bibtexCitation']) ? $entry['bibtexCitation'] : NULL; if (!empty($entry['editor'])) { $authorArray = preg_split("/\\s(and|&)\\s/i", trim($entry['editor'])); foreach ($authorArray as $key => $author) { $node['biblio_contributors'][2][] = array('name' => $author, 'auth_type' => _biblio_get_auth_type(2, $node['biblio_type'])); } } $node['biblio_secondary_title'] = !empty($entry['journal']) ? $entry['journal'] : NULL; if (!empty($entry['booktitle'])) { $node['biblio_secondary_title'] = $entry['booktitle']; } if (!empty($entry['series'])) { $node['biblio_tertiary_title'] = $entry['series']; } $node['biblio_volume'] = !empty($entry['volume']) ? $entry['volume'] : NULL; $node['biblio_number'] = !empty($entry['number']) ? $entry['number'] : NULL; $node['biblio_year'] = !empty($entry['year']) ? $entry['year'] : NULL; $node['biblio_notes'] = !empty($entry['note']) ? $entry['note'] : NULL; $node['biblio_date'] = !empty($entry['month']) ? $entry['month'] : NULL; $node['biblio_pages'] = !empty($entry['pages']) ? $entry['pages'] : NULL; $node['biblio_publisher'] = !empty($entry['publisher']) ? $entry['publisher'] : NULL; if (!empty($entry['organization'])) { $node['biblio_publisher'] = $entry['organization']; } if (!empty($entry['school'])) { $node['biblio_publisher'] = $entry['school']; } if (!empty($entry['institution'])) { $node['biblio_publisher'] = $entry['institution']; } $node['title'] = !empty($entry['title']) ? $entry['title'] : NULL; $node['biblio_type_of_work'] .= !empty($entry['type']) ? $entry['type'] : NULL; $node['biblio_edition'] = !empty($entry['edition']) ? $entry['edition'] : NULL; $node['biblio_section'] = !empty($entry['chapter']) ? $entry['chapter'] : NULL; $node['biblio_place_published'] = !empty($entry['address']) ? $entry['address'] : NULL; $node['biblio_abst_e'] = !empty($entry['abstract']) ? $entry['abstract'] : NULL; if (!empty($entry['keywords'])) { if (strpos($entry['keywords'], ';')) { $entry['keywords'] = str_replace(';', ',', $entry['keywords']); } $node['biblio_keywords'] = explode(',', $entry['keywords']); } $node['biblio_isbn'] = !empty($entry['isbn']) ? $entry['isbn'] : NULL; $node['biblio_issn'] = !empty($entry['issn']) ? $entry['issn'] : NULL; $node['biblio_url'] = !empty($entry['url']) ? $entry['url'] : NULL; $node['biblio_doi'] = !empty($entry['doi']) ? $entry['doi'] : NULL; if (!empty($terms)) { if (!isset($node['taxonomy'])) { $node['taxonomy'] = array(); } $node['taxonomy'] = array_merge($terms, $node['taxonomy']); } $nids[] = biblio_save_node($node, $batch, $session_id, $save); } return !empty($nids) ? $nids : NULL; }