From 6b8992ef0fba87e5e7f81a3e0cf984d97dbc07a1 Mon Sep 17 00:00:00 2001 From: Nahuel ANGELINETTI Date: Thu, 8 Jan 2009 11:41:57 +0100 Subject: [PATCH] (bug #1578) Add the (quasi)full COinS(Zotero) support this patch do a lot of things : * Add the function GetCOinSBiblio in C4::Biblio, return the COinS value that must be put in a span title This will be usefull for OpenURL support. * Replace the span in opac-detail, and put the var get from GetCOinSBiblio * Fix an tag that wasn't autoclosed * Add the COinS in search result * Full COinS support of UNIMARC, the MARC21 support should be improved to provide all kind of document types Signed-off-by: Galen Charlton --- C4/Biblio.pm | 118 ++++++++++++++++++ .../prog/en/modules/opac-detail.tmpl | 15 ++- .../prog/en/modules/opac-results.tmpl | 6 +- opac/opac-detail.pl | 7 +- opac/opac-search.pl | 6 +- 5 files changed, 138 insertions(+), 14 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 0a702a31ea..e071c18677 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -67,6 +67,7 @@ BEGIN { GetMarcUrls &GetUsedMarcStructure &GetXmlBiblio + &GetCOinSBiblio &GetAuthorisedValueDesc &GetMarcStructure @@ -1027,6 +1028,123 @@ sub GetXmlBiblio { return $marcxml; } +=head2 GetCOinSBiblio + +=over 4 + +my $coins = GetCOinSBiblio($biblionumber); + +Returns the COinS(a span) which can be included in a biblio record + +=back + +=cut + +sub GetCOinSBiblio { + my ( $biblionumber ) = @_; + my $record = GetMarcBiblio($biblionumber); + + # get the coin format + my $pos7 = substr $record->leader(), 7,1; + my $pos6 = substr $record->leader(), 6,1; + my $mtx; + my $genre; + my ($aulast, $aufirst) = ('',''); + my $oauthors; + my $title; + my $pubyear; + my $isbn; + my $issn; + my $publisher; + + if ( C4::Context->preference("marcflavour") eq "UNIMARC" ){ + my $fmts6; + my $fmts7; + %$fmts6 = ( + 'a' => 'book', + 'b' => 'manuscript', + 'c' => 'book', + 'd' => 'manuscript', + 'e' => 'map', + 'f' => 'map', + 'g' => 'film', + 'i' => 'audioRecording', + 'j' => 'audioRecording', + 'k' => 'artwork', + 'l' => 'document', + 'm' => 'computerProgram', + 'r' => 'document', + + ); + %$fmts7 = ( + 'a' => 'journalArticle', + 's' => 'journal', + ); + + $genre = $fmts6->{$pos6} ? $fmts6->{$pos6} : 'book' ; + + if( $genre eq 'book' ){ + $genre = $fmts7->{$pos7} if $fmts7->{$pos7}; + } + + ##### We must transform mtx to a valable mtx and document type #### + if( $genre eq 'book' ){ + $mtx = 'book'; + }elsif( $genre eq 'journal' ){ + $mtx = 'journal'; + }elsif( $genre eq 'journalArticle' ){ + $mtx = 'journal'; + $genre = 'article'; + }else{ + $mtx = 'dc'; + } + + $genre = ($mtx eq 'dc') ? "&rft.type=$genre" : "&rft.genre=$genre"; + + # Setting datas + $aulast = $record->subfield('700','a'); + $aufirst = $record->subfield('700','b'); + $oauthors = "&rft.au=$aufirst $aulast"; + # others authors + if($record->field('200')){ + for my $au ($record->field('200')->subfield('g')){ + $oauthors .= "&rft.au=$au"; + } + } + $title = ( $mtx eq 'dc' ) ? "&rft.title=".$record->subfield('200','a') : + "&rft.title=".$record->subfield('200','a')."&rft.btitle=".$record->subfield('200','a'); + $pubyear = $record->subfield('210','d'); + $publisher = $record->subfield('210','c'); + $isbn = $record->subfield('010','a'); + $issn = $record->subfield('011','a'); + }else{ + # MARC21 need some improve + my $fmts; + $mtx = 'book'; + $genre = "&rft.genre=book"; + + # Setting datas + $oauthors .= "&rft.au=".$record->subfield('100','a'); + # others authors + if($record->field('700')){ + for my $au ($record->field('700')->subfield('a')){ + $oauthors .= "&rft.au=$au"; + } + } + $title = "&rft.btitle=".$record->subfield('245','a'); + $pubyear = $record->subfield('260','c') or ""; + $publisher = $record->subfield('260','b') or ""; + $isbn = $record->subfield('020','a') or ""; + $issn = $record->subfield('022','a') or ""; + + } + my $coins_value = "ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3A$mtx$genre$title&rft.isbn=$isbn&rft.issn=$issn&rft.aulast=$aulast&rft.aufirst=$aufirst$oauthors&rft.pub=$publisher&rft.date=$pubyear"; + $coins_value =~ s/(\ |&[^a])/\+/g; + #&rft.au=&rft.btitle=&rft.date=&rft.pages=&rft.isbn=&rft.aucorp=&rft.place=&rft.pub=&rft.edition=&rft.series=&rft.genre=" + + return $coins_value; +} + =head2 GetAuthorisedValueDesc =over 4 diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl index f7dfc19bda..f02a1a7ce2 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl @@ -111,11 +111,14 @@ Physical details: - - &rft.au=&rft.btitle= &rft.date=&rft.pages=&rft.isbn=&rft.aucorp=&rft.place=&rft.pub=&rft.edition=&rft.series=&rft.genre="> - - - ISBN: "> + + "> + + + + ISBN: "> + + ISSN: @@ -150,7 +153,7 @@ Year : - " alt="" title=""> + " alt="" title="" /> Item type : diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tmpl index 1d592d1211..244c3d524e 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tmpl +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tmpl @@ -331,6 +331,10 @@ $(document).ready(function(){ + + "> + + @@ -351,7 +355,7 @@ $(document).ready(function(){ (modified on ) - Date:&rft.btitle=&rft.date=&rft.tpages=&rft.isbn=&rft.aucorp=&rft.place=&rft.pub=&rft.edition=&rft.series=&rft.genre="> + Date: Availability: diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 3e032def79..b7818aae2e 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -224,13 +224,8 @@ $template->param( ); # COinS format FIXME: for books Only -my $coins_format; -my $fmt = substr $record->leader(), 6,2; -my $fmts; -$fmts->{'am'} = 'book'; -$coins_format = $fmts->{$fmt}; $template->param( - ocoins_format => $coins_format, + ocoins => GetCOinSBiblio($biblionumber), ); my $reviews = getreviews( $biblionumber, 1 ); diff --git a/opac/opac-search.pl b/opac/opac-search.pl index 71cc28d5c0..c2e9250d6b 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -379,6 +379,7 @@ my $total = 0; # the total results for the whole set my $facets; # this object stores the faceted results that display on the left-hand of the results page my @results_array; my $results_hashref; +my @coins; if ($tag) { my $taglist = get_tags({term=>$tag, approved=>1}); @@ -439,7 +440,10 @@ for (my $i=0;$i<=@servers;$i++) { $_ ->{'TagLoop'} = get_tags({biblionumber=>$bibnum, approved=>1, 'sort'=>'-weight', limit=>$tag_quantity }); } - } + } + foreach (@newresults) { + $_->{coins} = GetCOinSBiblio($_->{'biblionumber'}); + } $total = $total + $results_hashref->{$server}->{"hits"} if $results_hashref->{$server}->{"hits"}; ## If there's just one result, redirect to the detail page if ($total == 1) { -- 2.39.5