@@ -, +, @@
and multiple 505$g fields.
---
C4/Record.pm | 33 +++++++++++++++++++-
installer/data/mysql/sysprefs.sql | 1 +
installer/data/mysql/updatedatabase.pl | 5 +++
.../en/modules/admin/preferences/cataloguing.pref | 9 +++++
4 files changed, 47 insertions(+), 1 deletions(-)
--- a/C4/Record.pm
+++ a/C4/Record.pm
@@ -709,7 +709,38 @@ sub marc2bibtex {
$tex .= "\@book{";
$tex .= join(",\n", $id, map { $bh{$_} ? qq(\t$_ = {$bh{$_}}) : () } keys %bh);
- $tex .= "\n}\n";
+ $tex .= "\n";
+
+ my $syspref = C4::Context->preference('BibtexExportAdditionalFields');
+ if ($syspref) {
+ $syspref = "$syspref\n\n";
+ my $yaml = eval { YAML::Load($syspref); };
+ if ($@) {
+ warn "Unable to parse BibtexExportAdditionalFields : $@";
+ }
+ else {
+ my $r;
+ foreach my $bibtex_tag ( keys %$yaml ) {
+ my @fields =
+ ref( $yaml->{$bibtex_tag} ) eq 'ARRAY'
+ ? @{ $yaml->{$bibtex_tag} }
+ : $yaml->{$bibtex_tag};
+ for my $tag_subfield (@fields) {
+ my ( $f, $sf ) = split /\$/, $tag_subfield;
+ if ( $f && $sf ) {
+ foreach my $field ( $record->field($f) ) {
+ my @values = $field->subfield($sf);
+ foreach my $v (@values) {
+ $tex .= qq(\t$bibtex_tag = {$v}\n);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ $tex .= "}\n";
return $tex;
}
--- a/installer/data/mysql/sysprefs.sql
+++ a/installer/data/mysql/sysprefs.sql
@@ -64,6 +64,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
('BasketConfirmations','1','always ask for confirmation.|do not ask for confirmation.','When closing or reopening a basket,','Choice'),
('BiblioAddsAuthorities','0',NULL,'If ON, adding a new biblio will check for an existing authority record and create one on the fly if one doesn\'t exist','YesNo'),
('BiblioDefaultView','normal','normal|marc|isbd','Choose the default detail view in the catalog; choose between normal, marc or isbd','Choice'),
+('BibtexExportAdditionalFields', '', NULL , 'Define additional BibTex tags to export from MARC records in YAML format as an associative array with either a marc tag/subfield combination as the value, or a list of tag/subfield combinations.', 'textarea'),
('BlockExpiredPatronOpacActions','1',NULL,'Set whether an expired patron can perform opac actions such as placing holds or renew books, can be overridden on a per patron-type basis','YesNo'),
('BlockReturnOfWithdrawnItems','1','0','If enabled, items that are marked as withdrawn cannot be returned.','YesNo'),
('BorrowerMandatoryField','surname|cardnumber',NULL,'Choose the mandatory fields for a patron\'s account','free'),
--- a/installer/data/mysql/updatedatabase.pl
+++ a/installer/data/mysql/updatedatabase.pl
@@ -8572,6 +8572,11 @@ if ( CheckVersion($DBversion) ) {
('RisUseItemtypeAsType', '0', NULL , 'Use biblio.itemtype for RIS export type if set', 'YesNo')
});
+ $dbh->do(q{
+ INSERT INTO systempreferences (variable,value,options,explanation,type)
+ VALUES ('BibtexExportAdditionalFields', '', NULL , 'Define additional BibTex tags to export from MARC records in YAML format as an associative array with either a marc tag/subfield combination as the value, or a list of tag/subfield combinations.', 'textarea')
+ });
+
print "Upgrade to $DBversion done (Bug XXX - Add ability to export arbitrary MARC fields for RIS and BibTex)\n";
SetVersion($DBversion);
}
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref
@@ -201,6 +201,15 @@ Cataloging:
- attempt to match aggressively by trying all variations of the ISBNs in the imported record as a phrase in the ISBN fields of already cataloged records. Note that this preference has no effect if UseQueryParser is on.
Exporting:
-
+ - Include following fields when exporting BibTeX,
+ - pref: BibtexExportAdditionalFields
+ type: textarea
+ - "Use one line per tag in the format BT_TAG: TAG$SUBFIELD ( e.g. lccn: 010$a )"
+ - "
"
+ - "To specificy multiple marc tags/subfields as targets for a repeating BibTex tag, use the following format: BT_TAG: [TAG2$SUBFIELD1, TAG2$SUBFIELD2] ( e.g. notes: [501$a, 505$g] )"
+ - "
"
+ - "All values of repeating tags and subfields will be printed with the given BibTeX tag."
+ -
- Include following fields when exporting RIS,
- pref: RisExportAdditionalFields
type: textarea
--