public function BiblioStyleBibtex::importData in Bibliography Module 7.3
@inheritdoc
Overrides BiblioStyleImportInterface::importData
File
- plugins/
biblio_style/ bibtex/ BiblioStyleBibtex.class.php, line 13 - BibTeX style.
Class
- BiblioStyleBibtex
- @file BibTeX style.
Code
public function importData($data, $options = array()) {
$bibtex = new PARSEENTRIES();
$bibtex
->loadBibtexString($data);
$bibtex
->extractEntries();
if (!$bibtex->count) {
return;
}
$entries = $bibtex
->getEntries();
$map = $this
->getMapping();
$map = $map['field'];
// Array of Biblios.
$biblios = array();
foreach ($entries as $entry) {
$biblio_type = $this
->getBiblioType($entry['bibtexEntryType']);
$biblio = biblio_create($biblio_type);
$wrapper = entity_metadata_wrapper('biblio', $biblio);
foreach (array_keys($map) as $key) {
if (in_array($key, array(
'author',
'editor',
))) {
continue;
}
$property_name = $map[$key]['property'];
if (!isset($wrapper->{$property_name})) {
biblio_create_field($property_name, 'biblio', $biblio_type);
}
$method = $map[$key]['import_method'];
$this
->{$method}($wrapper, $key, $entry);
}
$this
->importContributors($wrapper, $entry);
$biblios['success'][] = $wrapper
->value();
}
return $biblios;
}