Bugzilla – Attachment 25358 Details for
Bug 8992
Add an interfacing with the idref webservice
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8992: Interfacing with the Idref webservice
Bug-8992-Interfacing-with-the-Idref-webservice.patch (text/plain), 14.69 KB, created by
Jonathan Druart
on 2014-02-18 08:45:05 UTC
(
hide
)
Description:
Bug 8992: Interfacing with the Idref webservice
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2014-02-18 08:45:05 UTC
Size:
14.69 KB
patch
obsolete
>From b1ec8bb07f4c7e551841fe643b6898ecf1d81c50 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Mon, 16 Sep 2013 14:18:02 +0200 >Subject: [PATCH] Bug 8992: Interfacing with the Idref webservice > >On the detail page (in the opac), if the biblio comes from the Sudoc, >you must have a link (on the right of the author link) which open a popup with >informations about this author (publications by role). > >To test: > >1/ Switch on the Idref system preference > >2/ Simulate a SUDOC record: > Fill a 7..$3 field with a ppn (032581270 for example). > Fill the 009 field with an integer > >3/ Go to the opac detail page of this notice. >You should see the IDREF link. >If you click on it, a popup displays a loading icon and after a few >seconds (depending of the productivity of the authority :)), a list of >roles. For each role, a table displays all his corresponding publications. > >4/ On the right, you have 2 links: 1 for a koha search for this result >and 1 for a SUDOC link >--- > C4/Biblio.pm | 6 ++ > etc/zebradb/marc_defs/unimarc/biblios/record.abs | 7 ++ > installer/data/mysql/updatedatabase.pl | 16 ++++ > .../en/modules/admin/preferences/web_services.pref | 7 ++ > koha-tmpl/opac-tmpl/prog/en/css/opac.css | 10 +++ > koha-tmpl/opac-tmpl/prog/en/includes/greybox.inc | 7 ++ > koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt | 10 ++- > koha-tmpl/opac-tmpl/prog/en/modules/opac-idref.tt | 63 ++++++++++++++ > opac/opac-detail.pl | 13 +++ > opac/opac-idref.pl | 91 ++++++++++++++++++++ > 10 files changed, 229 insertions(+), 1 deletion(-) > create mode 100644 koha-tmpl/opac-tmpl/prog/en/includes/greybox.inc > create mode 100644 koha-tmpl/opac-tmpl/prog/en/modules/opac-idref.tt > create mode 100755 opac/opac-idref.pl > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index 330951d..69f1543 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -1928,9 +1928,14 @@ sub GetMarcAuthors { > } > > # other subfields >+ my $unimarc3; > for my $authors_subfield (@subfields) { > next if ( $authors_subfield->[0] eq '9' ); > >+ # unimarc3 contains the $3 of the author for UNIMARC. >+ # For french academic libraries, it's the "ppn", and it's required for idref webservice >+ $unimarc3 = $authors_subfield->[1] if $marcflavour eq 'UNIMARC' and $authors_subfield->[0] =~ /3/; >+ > # don't load unimarc subfields 3, 5 > next if ( $marcflavour eq 'UNIMARC' and ( $authors_subfield->[0] =~ /3|5/ ) ); > >@@ -1966,6 +1971,7 @@ sub GetMarcAuthors { > push @marcauthors, { > MARCAUTHOR_SUBFIELDS_LOOP => \@subfields_loop, > authoritylink => $subfield9, >+ unimarc3 => $unimarc3 > }; > } > return \@marcauthors; >diff --git a/etc/zebradb/marc_defs/unimarc/biblios/record.abs b/etc/zebradb/marc_defs/unimarc/biblios/record.abs >index c4ce025..60a1603 100644 >--- a/etc/zebradb/marc_defs/unimarc/biblios/record.abs >+++ b/etc/zebradb/marc_defs/unimarc/biblios/record.abs >@@ -151,14 +151,21 @@ melm 701 Author,Personal-name,Author:p,Personal-name:p,Personal-name:p > melm 702$9 Koha-Auth-Number,Koha-Auth-Number:n > melm 702 Author,Personal-name,Author:p,Personal-name:p,Personal-name:p > >+melm 700$3 Identified-standard >+melm 701$3 Identified-standard >+melm 702$3 Identified-standard >+ > # collective Author > melm 710$9 Koha-Auth-Number,Koha-Auth-Number:n > melm 710 Author,Author-name-corporate,Author-name-conference,Corporate-name,Conference-name,Author:p,Author-name-corporate:p,Author-name-conference:p,Corporate-name:p,Conference-name:p >+melm 710$3 Identified-standard > melm 711$9 Koha-Auth-Number,Koha-Auth-Number:n > melm 711 Author,Author-name-corporate,Author-name-conference,Corporate-name,Conference-name,Author:p,Author-name-corporate:p,Author-name-conference:p,Corporate-name:p,Conference-name:p >+melm 711$3 Identified-standard > > melm 712$9 Koha-Auth-Number,Koha-Auth-Number:n > melm 712 Author,Author-name-corporate,Author-name-conference,Corporate-name,Conference-name,Author:p,Author-name-corporate:p,Author-name-conference:p,Corporate-name:p,Conference-name:p >+melm 712$3 Identified-standard > > # trademark Author : 716 > melm 716$9 Koha-Auth-Number,Koha-Auth-Number:n >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index f043d0b..920b5dc 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -7953,6 +7953,22 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { > SetVersion($DBversion); > } > >+ >+ >+ >+$DBversion = "3.15.00.XXX"; >+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { >+ $dbh->do(q{ >+ INSERT INTO systempreferences (variable,value,explanation,options,type) >+ VALUES('IdRef','0','Disable/enable the IdRef webservice from the OPAC detail page.',NULL,'YesNo') >+ }); >+ print "Upgrade to $DBversion done (Bug 8992: Add system preference IdRef))\n"; >+ SetVersion($DBversion); >+} >+ >+ >+ >+ > =head1 FUNCTIONS > > =head2 TableExists($table) >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref >index 7244675..21e1a0b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref >@@ -44,3 +44,10 @@ Web services: > - pref: SvcMaxReportRows > class: integer > - rows of a report requested via the reports web service. >+ IdRef: >+ - >+ - pref: IdRef >+ choices: >+ yes: Enable >+ no: Disable >+ - the IdRef webservice from the opac detail page >diff --git a/koha-tmpl/opac-tmpl/prog/en/css/opac.css b/koha-tmpl/opac-tmpl/prog/en/css/opac.css >index 9e15cee..ef7e992 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/css/opac.css >+++ b/koha-tmpl/opac-tmpl/prog/en/css/opac.css >@@ -3074,3 +3074,13 @@ padding: 0.1em 0; > width: 35%; > font-size: 111%; > } >+ >+/* IDREF */ >+#idref h2.role { >+ background-color: #DDDEEE; >+ cursor: pointer; >+} >+ >+#idref table { >+ margin: 0; >+} >diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/greybox.inc b/koha-tmpl/opac-tmpl/prog/en/includes/greybox.inc >new file mode 100644 >index 0000000..b955b44 >--- /dev/null >+++ b/koha-tmpl/opac-tmpl/prog/en/includes/greybox.inc >@@ -0,0 +1,7 @@ >+<script type="text/javascript"> >+ var GB_ROOT_DIR = "[% themelang %]/lib/greybox/"; >+</script> >+<script type="text/javascript" src="[% themelang %]/lib/greybox/AJS.js"></script> >+<script type="text/javascript" src="[% themelang %]/lib/greybox/AJS_fx.js"></script> >+<script type="text/javascript" src="[% themelang %]/lib/greybox/gb_scripts.js"></script> >+<link href="[% themelang %]/lib/greybox/gb_styles.css" rel="stylesheet" type="text/css" /> >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt >index a4003cb..af34c88 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt >@@ -30,6 +30,7 @@ > [% END %] > [% IF ( OpacStarRatings != 'disable' ) %]<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.rating.js"></script> > <link rel="stylesheet" type="text/css" href="[% themelang %]/css/jquery.rating.css" />[% END %] >+[% INCLUDE greybox.inc %] > > [% IF ( OpacHighlightedWords ) %]<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.highlight-3.js"></script>[% END %] > [% IF ( bidi ) %] >@@ -558,7 +559,11 @@ YAHOO.util.Event.onContentReady("furtherm", function () { > [% XSLTBloc %] > [% ELSE %] > <h1 class="title">[% title |html %][% IF ( subtitle ) %] <span class="subtitle">[% FOREACH subtitl IN subtitle %][% subtitl.subfield |html %] [% END %]</span>[% END %]</h1> >- [% IF ( author ) %]<h5 class="author">by <a href="/cgi-bin/koha/opac-search.pl?q=au:[% author |url %]">[% author |html %]</a></h5>[% END %] >+ [% IF ( author ) %] >+ <h5 class="author"> >+ by <a href="/cgi-bin/koha/opac-search.pl?q=au:[% author |url %]">[% author |html %]</a> >+ </h5> >+ [% END %] > > <span class="results_summary">[% UNLESS ( item_level_itypes ) %] > [ >@@ -618,6 +623,9 @@ YAHOO.util.Event.onContentReady("furtherm", function () { > [% IF (MARCAUTHOR.authoritylink) %] > <a class='authlink' href="/cgi-bin/koha/opac-authoritiesdetail.pl?authid=[% MARCAUTHOR.authoritylink %]"><img style="vertical-align:middle" height="15" width="15" src="[% interface %]/[% theme %]/images/filefind.png"></a> > [% END %] >+ [% IF ( IDREF and MARCAUTHOR.unimarc3) %] >+ <a href="/cgi-bin/koha/opac-idref.pl?unimarc3=[% MARCAUTHOR.unimarc3 %]" title="IdRef" rel="gb_page_center[600,500]">IdRef</a> >+ [% END %] > [% UNLESS ( loop.last ) %]|[% END %] > [% END %] > </span> >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-idref.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-idref.tt >new file mode 100644 >index 0000000..6b10ffb >--- /dev/null >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-idref.tt >@@ -0,0 +1,63 @@ >+[% INCLUDE 'doc-head-open.inc' %] >+[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › Your search IDREF for ppn [% unimarc3 %] >+[% INCLUDE 'doc-head-close.inc' %] >+[% INCLUDE 'datatables.inc' %] >+<script type="text/javascript"> >+ $(document).ready(function (){ >+ $("table").dataTable($.extend(true, {}, dataTablesDefaults, { >+ "oLanguage": { >+ "sSearch": _("Search all columns:") >+ }, >+ 'bFilter': false, >+ 'sPaginationType': 'four_button', >+ 'aoColumnDefs': [ >+ { 'aTargets': [-1, -2], 'bSortable': false } >+ ], >+ 'aLengthMenu': [[10, 25, 50, 100, 250, 500, 1000, -1], [10, 25, 50, 100, 250, 500, 1000, _("All")]], >+ })); >+ >+ $(".role").click(function(){ >+ var docs_node = $(this).parent().find("div.docs"); >+ if ( $(docs_node).is(":visible") ) { >+ $(".docs").hide(); >+ } else { >+ $(".docs").hide(); >+ docs_node.show(); >+ } >+ }); >+ $(".docs").hide(); >+ }); >+</script> >+</head> >+<body> >+<div id="idref"> >+ [% IF error %] >+ This ppn is not found on the idref service. >+ [% ELSE %] >+ [% FOREACH role IN content %] >+ <div> >+ <h2 class="role" title="Click to expand this role">[% role.role_name %] ([% role.count %])</h2> >+ <div class="docs"> >+ <table> >+ <thead> >+ <th>Citation</th> >+ <th>Koha</th> >+ <th>Sudoc</th> >+ </thead> >+ <tbody> >+ [% FOREACH doc IN role.docs %] >+ <tr> >+ <td>[% doc.citation %]</td> >+ <td><a href="/cgi-bin/koha/opac-search.pl?q=kw,phr=[% doc.ppn %]" target="_blank">Koha</a></td> >+ <td><a href="http://www.sudoc.fr/[% doc.ppn %]" target="_blank">Sudoc</a></td> >+ </tr> >+ [% END %] >+ </tbody> >+ </table> >+ </div> >+ </div> >+ [% END %] >+ [% END %] >+</div> >+[% INCLUDE 'opac-bottom.inc' %] >+ >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index 0f6906b..e628297 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -1032,6 +1032,19 @@ if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){ > $template->param('OPACSearchForTitleIn' => $search_for_title); > } > >+#IDREF >+if ( C4::Context->preference("IDREF") ) { >+ # If the record comes from the SUDOC >+ if ( $record->field('009') ) { >+ my $unimarc3 = $record->field("009")->data; >+ if ( $unimarc3 =~ /^\d+$/ ) { >+ $template->param( >+ IDREF => 1, >+ ); >+ } >+ } >+} >+ > # We try to select the best default tab to show, according to what > # the user wants, and what's available for display > my $opac_serial_default = C4::Context->preference('opacSerialDefaultTab'); >diff --git a/opac/opac-idref.pl b/opac/opac-idref.pl >new file mode 100755 >index 0000000..8980a41 >--- /dev/null >+++ b/opac/opac-idref.pl >@@ -0,0 +1,91 @@ >+#!/usr/bin/perl >+ >+use Modern::Perl; >+ >+use CGI; >+use LWP::UserAgent; >+use HTTP::Request::Common; >+use JSON; >+use Encode; >+ >+use C4::Auth; >+use C4::Context; >+use C4::Search; >+use C4::Output; >+ >+my $cgi = new CGI; >+my ( $template, $borrowernumber, $cookie ) = get_template_and_user( >+ { >+ template_name => "opac-idref.tt", >+ query => $cgi, >+ type => "opac", >+ authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ), >+ flagsrequired => { borrow => 1 }, >+ } >+); >+ >+my $ua = LWP::UserAgent->new; >+ >+my $base = 'http://www.idref.fr/services/biblio/'; >+my $unimarc3 = $cgi->param('unimarc3'); >+ >+my $request = HTTP::Request->new( >+ 'GET', >+ $base . $unimarc3 . ".json", >+); >+$request->protocol('HTTP/1.1'); >+my $response = $ua->request($request); >+if ( not $response->is_success) { >+ $template->param(error => $base.$unimarc3.'.json'); >+ output_html_with_http_headers $cgi, $cookie, $template->output; >+ exit; >+} >+ >+my $content = Encode::decode("utf8", $response->content); >+my $json = from_json( $content ); >+my $r; >+my $role_name; >+my @unimarc3; >+my @results = ref $json->{sudoc}{result} eq "ARRAY" >+ ? @{ $json->{sudoc}{result} } >+ : ($json->{sudoc}{result}); >+ >+for my $role_node ( @results ) { >+ while ( my ( $k, $v ) = each %$role_node ) { >+ next unless $k eq "role"; >+ my $role_name; >+ my $count = 0; >+ my $role_data = {}; >+ my @nodes = ref $v eq "ARRAY" >+ ? @$v >+ : ($v); >+ for my $node ( @nodes ) { >+ while ( ( $k, $v ) = each %$node ) { >+ given ( $k ) { >+ when ( "roleName" ) { >+ $role_name = $v; >+ $role_data->{role_name} = $role_name; >+ } >+ when ( "count" ) { >+ $role_data->{count} = $v; >+ } >+ when ( "doc" ) { >+ push @{ $role_data->{docs} }, $v; >+ } >+ default { >+ # unimarcCode and marc21Code >+ } >+ } >+ } >+ } >+ push @$r, $role_data; >+ } >+} >+ >+$template->param( >+ content => $r, >+ unimarc3 => $unimarc3, >+); >+ >+output_html_with_http_headers $cgi, $cookie, $template->output; >+ >-- >1.7.10.4
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 8992
:
13134
|
13142
|
21119
|
21182
|
21641
|
25358
|
25359
|
25365
|
25399
|
26998
|
26999
|
27000
|
27460
|
27462
|
27463
|
27464
|
29012
|
29165
|
29166
|
29167
|
29168
|
29169
|
30920
|
32123
|
35012
|
35013
|
35014
|
35015
|
35016
|
35017
|
35020
|
35022
|
35023
|
35024
|
35025
|
35026
|
35027
|
38639
|
39564
|
39565