From a4fecfbefab041d924f07db5e49b791388eaa2db Mon Sep 17 00:00:00 2001 From: Nahuel ANGELINETTI Date: Fri, 2 Jan 2009 15:39:35 +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: Henri-Damien LAURENT --- C4/Biblio.pm | 118 ++++++++++++++++++ .../prog/en/modules/opac-detail.tmpl | 15 ++- .../prog/en/modules/opac-results.tmpl | 4 +- opac/opac-detail.pl | 7 +- opac/opac-search.pl | 1 + 5 files changed, 132 insertions(+), 13 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 3f361a11c2..3b2ffd4642 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -64,6 +64,7 @@ BEGIN { GetMarcUrls &GetUsedMarcStructure &GetXmlBiblio + &GetCOinSBiblio &GetAuthorisedValueDesc &GetMarcStructure @@ -886,6 +887,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'); + $publisher = $record->subfield('260','b'); + $isbn = $record->subfield('020','a'); + $issn = $record->subfield('022','a'); + + } + 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/\ /\+/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 f808bc3636..f6ebfcfa93 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl @@ -113,11 +113,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: @@ -152,7 +155,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 02d44fa54e..7706a9eca0 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tmpl +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tmpl @@ -203,6 +203,8 @@ $(document).ready(function(){ + "> + @@ -223,7 +225,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 de61ce3369..794dea739d 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -188,13 +188,8 @@ foreach ( keys %{$dat} ) { } # 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 21dc131311..459d018cf6 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -436,6 +436,7 @@ for (my $i=0;$i<=@servers;$i++) { next; } $_ ->{'clean_isbn'} = $1; + $_->{'coins'} = GetCOinSBiblio($_->{'biblionumber'}); } $total = $total + $results_hashref->{$server}->{"hits"}; ## If there's just one result, redirect to the detail page -- 2.20.1