Bugzilla – Attachment 29293 Details for
Bug 12357
Enhancements to RIS and BibTeX exporting
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12357 [3]- Add ability to export arbitrary fields for BibTex format
Bug-12357-3--Add-ability-to-export-arbitrary-field.patch (text/plain), 6.33 KB, created by
Kyle M Hall (khall)
on 2014-06-26 17:27:44 UTC
(
hide
)
Description:
Bug 12357 [3]- Add ability to export arbitrary fields for BibTex format
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2014-06-26 17:27:44 UTC
Size:
6.33 KB
patch
obsolete
>From b94910f1f3a2d6378e3ab2d596a60c9bc51b9f6b Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Tue, 3 Jun 2014 09:40:41 -0400 >Subject: [PATCH] Bug 12357 [3]- Add ability to export arbitrary fields for BibTex format > >Some libraries would like to be able to add arbitrary fields to both the >RIS and BibTeX citation formats that a record can be saved as from the >staff intranet and public catalog. In addition, they would like to be >able to override the default record type and use Koha's itemtype as the >record type for those formats as well. > >Test Plan: >1) Apply this patch >2) Run updatedatabase.pl >3) Add the following to the new syspref BibtexExportAdditionalFields: >lccn: 010$a >notes: [501$a, 505$g] >4) Find or create a record with an 010$a (lccn) field, a 501$a field > and multiple 505$g fields. >5) Locate the record in the catalog, choose "Save" and select BIBTEX >6) Inspect the downloaded file, note the lccn and multiple note 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(-) > >diff --git a/C4/Record.pm b/C4/Record.pm >index e291486..ff88f93 100644 >--- a/C4/Record.pm >+++ b/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; > } >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 04ddbd0..d21740f 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/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'), >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 90f852b..e43c759 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/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); > } >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref >index a946fd8..fc8d27e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref >+++ b/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 )" >+ - "<br/>" >+ - "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] )" >+ - "<br/>" >+ - "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 >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12357
:
28646
|
28647
|
28648
|
28649
|
28650
|
29291
|
29292
|
29293
|
29294
|
29295
|
29296
|
29297
|
31677
|
31678
|
31679
|
31680
|
33123
|
33124
|
33125
|
33126
|
35485
|
35487
|
35489
|
35826
|
35827
|
35828
|
38602
|
38604
|
39469
|
39471
|
39773
|
39774
|
39775
|
39776
|
39803
|
39804
|
39805
|
39806