function biblio_bibtex_export in Bibliography Module 6
Export data in bibtex format.
Parameters
$result: a database result set pointer
Return value
none
1 call to biblio_bibtex_export()
File
- ./
biblio.import.export.inc, line 759 - Functions that are used to import and export biblio data.
Code
function biblio_bibtex_export($node) {
$bibtex = '';
$type = "article";
$journal = $series = $booktitle = $school = $organization = $institution = null;
$type = _bibtex_type_map($node->biblio_type);
switch ($node->biblio_type) {
case 100:
$series = $node->biblio_secondary_title;
$organization = $node->biblio_publisher;
break;
case 101:
case 103:
$booktitle = $node->biblio_secondary_title;
$organization = $node->biblio_publisher;
$series = $node->biblio_tertiary_title;
break;
case 108:
$school = $node->biblio_publisher;
$node->biblio_publisher = null;
if (stripos($node->biblio_type_of_work, 'masters')) {
$type = "mastersthesis";
}
break;
case 109:
$institution = $node->biblio_publisher;
$node->biblio_publisher = null;
break;
case 102:
default:
$journal = $node->biblio_secondary_title;
break;
}
$bibtex .= '@' . $type . ' {';
$bibtex .= $node->biblio_citekey ? $node->biblio_citekey : "";
$bibtex .= _bibtex_format_entry('title', $node->title);
$bibtex .= _bibtex_format_entry('journal', $journal);
$bibtex .= _bibtex_format_entry('booktitle', $booktitle);
$bibtex .= _bibtex_format_entry('series', $series);
$bibtex .= _bibtex_format_entry('volume', $node->biblio_volume);
$bibtex .= _bibtex_format_entry('number', $node->biblio_number);
$bibtex .= _bibtex_format_entry('year', $node->biblio_year);
$bibtex .= _bibtex_format_entry('note', $node->biblio_notes);
$bibtex .= _bibtex_format_entry('month', $node->biblio_date);
$bibtex .= _bibtex_format_entry('pages', $node->biblio_pages);
$bibtex .= _bibtex_format_entry('publisher', $node->biblio_publisher);
$bibtex .= _bibtex_format_entry('school', $school);
$bibtex .= _bibtex_format_entry('organization', $organization);
$bibtex .= _bibtex_format_entry('institution', $institution);
$bibtex .= _bibtex_format_entry('type', $node->biblio_type_of_work);
$bibtex .= _bibtex_format_entry('edition', $node->biblio_edition);
$bibtex .= _bibtex_format_entry('chapter', $node->biblio_section);
$bibtex .= _bibtex_format_entry('address', $node->biblio_place_published);
$bibtex .= _bibtex_format_entry('abstract', $node->biblio_abst_e);
$kw_array = array();
if (!empty($node->terms)) {
foreach ($node->terms as $term) {
$kw_array[] = $term->name;
}
}
if (!empty($node->biblio_keywords)) {
foreach ($node->biblio_keywords as $term) {
$kw_array[] = $term;
}
}
if (!empty($kw_array)) {
$kw_array = array_unique($kw_array);
$bibtex .= _bibtex_format_entry('keywords', implode(', ', $kw_array));
}
$bibtex .= _bibtex_format_entry('isbn', $node->biblio_isbn);
$bibtex .= _bibtex_format_entry('issn', $node->biblio_issn);
$bibtex .= _bibtex_format_entry('doi', $node->biblio_doi);
$bibtex .= _bibtex_format_entry('url', $node->biblio_url);
if (!empty($node->files) && count($node->files) && user_access('view uploaded files')) {
foreach ($node->files as $file) {
$attachments[] = file_create_url($file->filepath);
}
$bibtex .= _bibtex_format_entry('attachments', implode(' , ', $attachments));
}
$a = $e = array();
foreach ((array) $node->biblio_contributors[1] as $auth) {
$a[] = trim($auth['name']);
}
foreach ((array) $node->biblio_contributors[2] as $auth) {
$e[] = trim($auth['name']);
}
$a = implode(' and ', $a);
$e = implode(' and ', $e);
if (!empty($a)) {
$bibtex .= _bibtex_format_entry('author', $a);
}
if (!empty($e)) {
$bibtex .= _bibtex_format_entry('editor', $e);
}
$bibtex .= "\n}\n";
//now convert any special characters to the latex equivelents...
module_load_include('php', 'biblio', 'bibtexParse/PARSEENTRIES');
include drupal_get_path('module', 'biblio') . '/bibtexParse/transtab_unicode_bibtex.inc.php';
$converter = new PARSEENTRIES();
$bibtex = $converter
->searchReplaceText($transtab_unicode_bibtex, $bibtex, false);
return $bibtex;
}