Bugzilla – Attachment 23365 Details for
Bug 11361
Add a Z39.50 search page in the OPAC to let members search for records on remote Koha instances
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Add a Z39.50 search page to the OPAC to let users search for records on a remote Koha instance.
0001-Add-a-Z39.50-search-page-to-the-OPAC-to-let-users-se.patch (text/plain), 39.93 KB, created by
Frédérick Capovilla
on 2013-12-09 22:43:03 UTC
(
hide
)
Description:
Add a Z39.50 search page to the OPAC to let users search for records on a remote Koha instance.
Filename:
MIME Type:
Creator:
Frédérick Capovilla
Created:
2013-12-09 22:43:03 UTC
Size:
39.93 KB
patch
obsolete
>From 082aa35b122b5e682c46abb15fe0b8793f90aa62 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Fr=C3=A9d=C3=A9rick?= <frederick.capovilla@libeo.com> >Date: Mon, 9 Dec 2013 17:19:22 -0500 >Subject: [PATCH] Add a Z39.50 search page to the OPAC to let users search for records on > a remote Koha instance. > >--- > C4/Auth.pm | 1 + > admin/z3950servers.pl | 22 +- > installer/data/mysql/sysprefs.sql | 1 + > installer/data/mysql/updatedatabase.pl | 8 + > .../prog/en/modules/admin/preferences/opac.pref | 6 + > .../prog/en/modules/admin/z3950servers.tt | 12 +- > koha-tmpl/opac-tmpl/ccsr/en/css/datatables.css | 10 +- > koha-tmpl/opac-tmpl/ccsr/en/includes/masthead.inc | 1 + > koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc | 1 + > .../opac-tmpl/prog/en/modules/opac-z3950-search.tt | 253 +++++++++++++++ > opac/opac-z3950-search.pl | 323 ++++++++++++++++++++ > 11 files changed, 622 insertions(+), 16 deletions(-) > create mode 100644 koha-tmpl/opac-tmpl/prog/en/modules/opac-z3950-search.tt > create mode 100755 opac/opac-z3950-search.pl > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index 00eeeef..c4d5b5b 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -412,6 +412,7 @@ sub get_template_and_user { > OPACMobileUserCSS => "". C4::Context->preference("OPACMobileUserCSS"), > OPACViewOthersSuggestions => "" . C4::Context->preference("OPACViewOthersSuggestions"), > OpacAuthorities => C4::Context->preference("OpacAuthorities"), >+ OpacZ3950 => C4::Context->preference("OpacZ3950"), > OPACBaseURL => ($in->{'query'}->https() ? "https://" : "http://") . $ENV{'SERVER_NAME'} . > ($ENV{'SERVER_PORT'} eq ($in->{'query'}->https() ? "443" : "80") ? '' : ":$ENV{'SERVER_PORT'}"), > opac_css_override => $ENV{'OPAC_CSS_OVERRIDE'}, >diff --git a/admin/z3950servers.pl b/admin/z3950servers.pl >index 1dbd118..ad23d43 100755 >--- a/admin/z3950servers.pl >+++ b/admin/z3950servers.pl >@@ -40,7 +40,7 @@ sub StringSearch { > $searchstring = ''; > } > >- my $query = "SELECT host,port,db,userid,password,name,id,checked,rank,syntax,encoding,timeout,recordtype"; >+ my $query = "SELECT host,port,db,userid,password,name,id,checked,rank,syntax,encoding,timeout,recordtype,opac"; > $query .= " FROM z3950servers"; > if ( $searchstring ne '' ) { $query .= " WHERE (name like ?)" } > $query .= " ORDER BY rank,name"; >@@ -93,14 +93,14 @@ if ( $op eq 'add_form' ) { > if ($searchfield) { > my $dbh = C4::Context->dbh; > my $sth = $dbh->prepare( >-"select host,port,db,userid,password,name,id,checked,rank,syntax,encoding,timeout,recordtype from z3950servers where (name = ?) order by rank,name" >+"select host,port,db,userid,password,name,id,checked,rank,syntax,encoding,timeout,recordtype,opac from z3950servers where (name = ?) order by rank,name" > ); > $sth->execute($searchfield); > $data = $sth->fetchrow_hashref; > $sth->finish; > } > $template->param( $_ => $data->{$_} ) >- for (qw( host port db userid password checked rank timeout encoding )); >+ for (qw( host port db userid password checked rank timeout encoding opac )); > $template->param( $_ . $data->{$_} => 1 ) for (qw( syntax recordtype )); > > # END $OP eq ADD_FORM >@@ -113,7 +113,7 @@ if ( $op eq 'add_form' ) { > my $checked = $input->param('checked') ? 1 : 0; > if ($sth->rows) { > $template->param(confirm_update => 1); >- $sth=$dbh->prepare("update z3950servers set host=?, port=?, db=?, userid=?, password=?, name=?, checked=?, rank=?,syntax=?,encoding=?,timeout=?,recordtype=? where name=?"); >+ $sth=$dbh->prepare("update z3950servers set host=?, port=?, db=?, userid=?, password=?, name=?, checked=?, rank=?,syntax=?,encoding=?,timeout=?,recordtype=?,opac=? where name=?"); > $sth->execute($input->param('host'), > $input->param('port'), > $input->param('db'), >@@ -126,6 +126,7 @@ if ( $op eq 'add_form' ) { > $input->param('encoding'), > $input->param('timeout'), > $input->param('recordtype'), >+ ($input->param('opac') || 0), > $input->param('searchfield'), > ); > } >@@ -133,15 +134,16 @@ if ( $op eq 'add_form' ) { > $template->param(confirm_add => 1); > $sth=$dbh->prepare( > "INSERT INTO z3950servers " . >- "(host,port,db,userid,password,name,checked,rank,syntax,encoding,timeout,recordtype) " . >- "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" ); >+ "(host,port,db,userid,password,name,checked,rank,syntax,encoding,timeout,recordtype,opac) " . >+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" ); > $sth->execute( > $input->param('host'), $input->param('port'), > $input->param('db'), $input->param('userid'), > $input->param('password'), $input->param('searchfield'), > $checked, $input->param('rank'), > $input->param('syntax'), $input->param('encoding'), >- $input->param('timeout'), $input->param('recordtype') >+ $input->param('timeout'), $input->param('recordtype'), >+ ($input->param('opac') || 0), > ); > } > $sth->finish; >@@ -154,7 +156,7 @@ if ( $op eq 'add_form' ) { > my $dbh = C4::Context->dbh; > > my $sth2 = $dbh->prepare( >-"select host,port,db,userid,password,name,id,checked,rank,syntax,encoding,timeout,recordtype from z3950servers where (name = ?) order by rank,name" >+"select host,port,db,userid,password,name,id,checked,rank,syntax,encoding,timeout,recordtype,opac from z3950servers where (name = ?) order by rank,name" > ); > $sth2->execute($searchfield); > my $data = $sth2->fetchrow_hashref; >@@ -171,6 +173,7 @@ if ( $op eq 'add_form' ) { > syntax => $data->{'syntax'}, > timeout => $data->{'timeout'}, > recordtype => $data->{'recordtype'}, >+ opac => $data->{'opac'}, > encoding => $data->{'encoding'} > ); > >@@ -203,7 +206,8 @@ if ( $op eq 'add_form' ) { > rank => $results->[$i]{'rank'}, > syntax => $results->[$i]{'syntax'}, > encoding => $results->[$i]{'encoding'}, >- timeout => $results->[$i]{'timeout'}, >+ timeout => $results->[$i]{'timeout'}, >+ opac => $results->[$i]{'opac'}, > recordtype => $results->[$i]{'recordtype'}); > push @loop, \%row; > >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 6438483..1711cfc 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -424,4 +424,5 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('yuipath','local','local|http://yui.yahooapis.com/2.5.1/build','Insert the path to YUI libraries, choose local if you use koha offline','Choice'), > ('z3950AuthorAuthFields','701,702,700',NULL,'Define the MARC biblio fields for Personal Name Authorities to fill biblio.author','free'), > ('z3950NormalizeAuthor','0','','If ON, Personal Name Authorities will replace authors in biblio.author','YesNo') >+('OPACZ3950','0','','Allow patrons to search for bibliographic records in other libraries via Z39.50.','YesNo') > ; >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 19893b4..d3e07c3 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -7824,6 +7824,14 @@ if ( CheckVersion($DBversion) ) { > SetVersion($DBversion); > } > >+$DBversion = "XXX"; >+if(CheckVersion($DBversion)) { >+ $dbh->do("ALTER TABLE z3950servers ADD COLUMN opac TINYINT(1);"); >+ $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES('OPACZ3950','0','','Allow patrons to search for bibliographic records in other libraries via Z39.50.','YesNo')"); >+ print "Add opac column to z3950servers table.\nAdd OPACZ3950 preference.\n"; >+ SetVersion($DBversion); >+} >+ > > =head1 FUNCTIONS > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >index a75c7ef..b9358e3 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >@@ -338,6 +338,12 @@ OPAC: > no: "Don't allow" > - patrons to search your authority records. > - >+ - pref: OpacZ3950 >+ choices: >+ yes: Allow >+ no: "Don't allow" >+ - patrons to search for bibliographic records in other libraries via Z39.50. >+ - > - pref: opacbookbag > choices: > yes: Allow >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt >index 915e531..2149f56 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt >@@ -137,6 +137,13 @@ > <input type="checkbox" name="checked" id="checked" value="1" /> > [% END %] > </li> >+ <li><label for="opac">OPAC (Shown in OPAC Z39.50 search): </label> >+ [% IF ( opac ) %] >+ <input type="checkbox" size="1" name="opac" id="opac" value="1" checked="" /> >+ [% ELSE %] >+ <input type="checkbox" size="1" name="opac" id="opac" value="1" /> >+ [% END %] >+ </li> > <li><label for="rank">Rank (display order): </label> <input type="text" name="rank" id="rank" size="4" value="[% rank %]" onblur="isNum(this)" /> > </li> > <li><label for="syntax">Syntax (z3950 can send<br /> records in various format. Choose one): </label> >@@ -289,6 +296,7 @@ > <li><strong>Encoding: </strong>[% encoding %]</li> > <li><strong>Timeout: </strong>[% timeout %]</li> > <li><strong>Record type: </strong>[% recordtype %]</li> >+ <li><strong>OPAC: </strong>[% opac %]</li> > </ul> <form action="[% script_name %]" method="post"><input type="hidden" name="op" value="delete_confirmed" /><input type="hidden" name="searchfield" value="[% searchfield %]" /><input type="submit" value="Delete this server" /></form> <form action="[% script_name %]" method="post"><input type="submit" value="Do not delete" /></form> > > >@@ -314,7 +322,7 @@ > You searched for [% searchfield %] > [% END %] > <table id="serverst"> >- <thead><tr><th>Target</th><th>Hostname/Port</th><th>Database</th><th>Userid</th><th>Password</th><th>Checked</th><th>Rank</th><th>Syntax</th><th>Encoding</th><th>Timeout</th><th>Record type</th><th> </th><th> </th> >+ <thead><tr><th>Target</th><th>Hostname/Port</th><th>Database</th><th>Userid</th><th>Password</th><th>Checked</th><th>Rank</th><th>Syntax</th><th>Encoding</th><th>Timeout</th><th>Record type</th><th>OPAC</th><th> </th><th> </th> > </tr></thead> > <tbody>[% FOREACH loo IN loop %] > [% UNLESS ( loop.odd ) %] >@@ -324,7 +332,7 @@ > [% END %] > <td><a href="[% loo.script_name %]?op=add_form&searchfield=[% loo.name |url %]">[% loo.name %]</a></td><td>[% loo.host %]:[% loo.port %]</td><td>[% loo.db %]</td><td>[% loo.userid %]</td><td>[% loo.password %]</td><td>[% IF ( loo.checked ) %]Yes[% ELSE %]No[% END %]</td><td>[% loo.rank %]</td> > >-<td>[% loo.syntax %]</td><td>[% loo.encoding %]</td><td>[% loo.timeout %]</td><td>[% loo.recordtype %]</td><td><a href="[% loo.script_name %]?op=add_form&searchfield=[% loo.name |url %]">Edit</a></td><td><a href="[% loo.script_name %]?op=delete_confirm&searchfield=[% loo.name |url %]">Delete</a></td> </tr> >+<td>[% loo.syntax %]</td><td>[% loo.encoding %]</td><td>[% loo.timeout %]</td><td>[% loo.recordtype %]</td><td>[% loo.opac %]</td><td><a href="[% loo.script_name %]?op=add_form&searchfield=[% loo.name |url %]">Edit</a></td><td><a href="[% loo.script_name %]?op=delete_confirm&searchfield=[% loo.name |url %]">Delete</a></td> </tr> > [% END %]</tbody> > </table> > >diff --git a/koha-tmpl/opac-tmpl/ccsr/en/css/datatables.css b/koha-tmpl/opac-tmpl/ccsr/en/css/datatables.css >index e7b11bd..cd34861 100644 >--- a/koha-tmpl/opac-tmpl/ccsr/en/css/datatables.css >+++ b/koha-tmpl/opac-tmpl/ccsr/en/css/datatables.css >@@ -3,23 +3,23 @@ input.search_init { > } > .sorting_asc { > padding-right: 19px; >- background: url("../../img/asc.gif") no-repeat scroll right center #EEEEEE; >+ background: url("../../images/asc.gif") no-repeat scroll right center #EEEEEE; > } > .sorting_desc { > padding-right: 19px; >- background: url("../../img/desc.gif") no-repeat scroll right center #EEEEEE; >+ background: url("../../images/desc.gif") no-repeat scroll right center #EEEEEE; > } > .sorting { > padding-right: 19px; >- background: url("../../img/ascdesc.gif") no-repeat scroll right center #EEEEEE; >+ background: url("../../images/ascdesc.gif") no-repeat scroll right center #EEEEEE; > } > .sorting_asc_disabled { > padding-right: 19px; >- background: url("../../img/datatables/sort_asc_disabled.png") no-repeat scroll right center #EEEEEE; >+ background: url("../../images/datatables/sort_asc_disabled.png") no-repeat scroll right center #EEEEEE; > } > .sorting_desc_disabled { > padding-right: 19px; >- background: url("../../img/datatables/sort_desc_disabled.png") no-repeat scroll right center #EEEEEE; >+ background: url("../../images/datatables/sort_desc_disabled.png") no-repeat scroll right center #EEEEEE; > } > .sorting_disabled { > padding-right: 19px; >diff --git a/koha-tmpl/opac-tmpl/ccsr/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/ccsr/en/includes/masthead.inc >index eba9b78..d792f1c 100644 >--- a/koha-tmpl/opac-tmpl/ccsr/en/includes/masthead.inc >+++ b/koha-tmpl/opac-tmpl/ccsr/en/includes/masthead.inc >@@ -195,6 +195,7 @@ > [% IF Koha.Preference( 'UseCourseReserves' ) == 1 %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-course-reserves.pl">Course reserves</a>[% END %] > [% IF ( OpacBrowser ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-browser.pl">Browse by hierarchy</a>[% END %] > [% IF ( OpacAuthorities ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-authorities-home.pl">Authority search</a>[% END %] >+[% IF ( OpacZ3950 ) %]<span class="pipe"> | </span><a target="_blank" href="/cgi-bin/koha/opac-z3950-search.pl">Z39.50 Search</a>[% END %] > [% IF ( opacuserlogin && ( Koha.Preference( 'reviewson' ) == 1 ) && ( Koha.Preference( 'OpacShowRecentComments' ) == 1 ) ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-showreviews.pl">Recent comments</a>[% END %] > [% IF ( TagsEnabled ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-tags.pl">Tag cloud</a>[% END %] > [% IF ( OpacCloud ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-tags_subject.pl">Subject cloud</a>[% END %] >diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc >index 79eb1a1..8910eaa 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc >+++ b/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc >@@ -134,6 +134,7 @@ > [% IF Koha.Preference( 'UseCourseReserves' ) == 1 %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-course-reserves.pl">Course reserves</a>[% END %] > [% IF ( OpacBrowser ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-browser.pl">Browse by hierarchy</a>[% END %] > [% IF ( OpacAuthorities ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-authorities-home.pl">Authority search</a>[% END %] >+[% IF ( OpacZ3950 ) %]<span class="pipe"> | </span><a target="_blank" href="/cgi-bin/koha/opac-z3950-search.pl">Z39.50 Search</a>[% END %] > [% IF ( opacuserlogin && ( Koha.Preference( 'reviewson' ) == 1 ) && ( Koha.Preference( 'OpacShowRecentComments' ) == 1 ) ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-showreviews.pl">Recent comments</a>[% END %] > [% IF ( TagsEnabled ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-tags.pl">Tag cloud</a>[% END %] > [% IF ( OpacCloud ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-tags_subject.pl">Subject cloud</a>[% END %] >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-z3950-search.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-z3950-search.tt >new file mode 100644 >index 0000000..693e6b5 >--- /dev/null >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-z3950-search.tt >@@ -0,0 +1,253 @@ >+[% INCLUDE 'doc-head-open.inc' %] >+Koha › Z39.50 Search Results</title> >+ >+<!-- greybox.inc --> >+<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" /> >+<!-- /greybox.inc --> >+ >+[% INCLUDE 'doc-head-close.inc' %] >+<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script> >+<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" /> >+<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script> >+<script type="text/javascript"> >+//<![CDATA[ >+ var MSG_DT_FIRST = _("First"); >+ var MSG_DT_LAST = _("Last"); >+ var MSG_DT_NEXT = _("Next"); >+ var MSG_DT_PREVIOUS = _("Previous"); >+ var MSG_DT_EMPTY_TABLE = _("No data available in table"); >+ var MSG_DT_INFO = _("Showing _START_ to _END_ of _TOTAL_"); >+ var MSG_DT_INFO_EMPTY = _("No entries to show"); >+ var MSG_DT_INFO_FILTERED = _("(filtered from _MAX_ total entries)"); >+ var MSG_DT_LENGTH_MENU = _("Show _MENU_ entries"); >+ var MSG_DT_LOADING_RECORDS = _("Loading..."); >+ var MSG_DT_PROCESSING = _("Processing..."); >+ var MSG_DT_SEARCH = _("Search:"); >+ var MSG_DT_ZERO_RECORDS = _("No matching records found"); >+ var CONFIG_EXCLUDE_ARTICLES_FROM_SORT = _("a an the"); >+//]]> >+</script> >+<script type="text/javascript" src="[% themelang %]/js/datatables.js"></script> >+ >+<script type="text/javascript"> >+//<![CDATA[ >+function closemenu(){ >+ $(".linktools").hide(); >+ $("tr").removeClass("selected"); >+} >+$(document).ready(function(){ >+ $("#CheckAll").click(function(){ >+ $(".checkboxed").checkCheckboxes(); >+ return false; >+ }); >+ $("#CheckNone").click(function(){ >+ $(".checkboxed").unCheckCheckboxes(); >+ return false; >+ }); >+ /* Inline edit/delete links */ >+ $("td").click(function(event){ >+ var $tgt = $(event.target); >+ $(".linktools").hide(); >+ $("tr").removeClass("selected"); >+ var row = $(this).parent(); >+ row.addClass("selected"); >+ >+ if($tgt.is("a")||$tgt.is(":nth-child(7)")||$tgt.is(":nth-child(8)")||$tgt.is(":nth-child(9)")||$tgt.is(":nth-child(10)")){ >+ return true; >+ } else { >+ var position = $(this).offset(); >+ var top = position.top+5; >+ var left = position.left+5; >+ $(".linktools",row).show().css("position","absolute").css("top",top).css("left",left); >+ } >+ }); >+ $("#resultst").dataTable($.extend(true, {}, dataTablesDefaults, { >+ "sDom": 't', >+ "aoColumnDefs": [ >+ { "aTargets": [ -1,-2,-3 ], "bSortable": false, "bSearchable": false }, >+ { "aTargets": [ 1 ], "sType": "nsb-nse" }, >+ ], >+ "aaSorting": [[ 1, "asc" ]], >+ "bPaginate": false >+ })); >+ $("form[name='f']").submit(function(){ >+ if ($('input[type=checkbox]').filter(':checked').length == 0) { >+ alert(_("Please choose at least one Z39.50 target")); >+ return false; >+ } else >+ return true; >+ }); >+}); >+ >+[% IF ( total_pages ) %] >+function validate_goto_page(){ >+ var page = $('#goto_page').val(); >+ if(isNaN(page)) { >+ alert(_("The page entered is not a number.")); >+ return false; >+ } >+ else if(page < 1 || page > [% total_pages %] ) { >+ alert(_("The page should be a number between 1 and ") + [% total_pages %] + "."); >+ return false; >+ } >+ else { >+ return true; >+ } >+} >+[% END %] >+ >+//]]> >+</script> >+<style type="text/css"> >+.linktools { background-color:#FFF;border-top:1px solid #DDD; border-left: 1px solid #DDD; border-right: 1px solid #666; border-bottom:1px solid #666;display: none; white-space: nowrap;} >+.linktools a { font-size : 85%; text-decoration:none; padding:.3em;;background-color:#FFF; display:block;float:left;border-right:1px solid #DDD;} >+.linktools a:hover { background-color:#EEE;color:#CC3300;border-right:1px solid #CCC;} >+tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : transparent; } >+</style> >+ [% IF ( opsearch ) %] >+ <style type="text/css"> >+ #custom-doc { width:53em;*width:51.72em;min-width:689px; margin:auto; text-align:left; } >+ </style> >+</head> >+<body> >+ >+<div id="custom-doc" class="yui-t7"> >+[% ELSE %] >+</head> >+<body style="padding:.5em;"> >+<div> >+[% END %] >+ <div id="bd"> >+ [% IF ( opsearch ) %] >+<h2>Z39.50 Search Points</h2> >+ <form method="post" action="opac-z3950-search.pl" name="f" class="checkboxed"> >+ <input type="hidden" name="op" id="op" value="do_search" /> >+ <div class="yui-g"> >+ <div class="yui-u first"> >+ <fieldset class="rows"> >+ <ol><li><label for="title">Title: </label> <input type="text" id="title" name="title" value="[% title %]" /></li> >+ <li><label for="isbn">ISBN/ISSN: </label> <input type="text" id="isbn" name="isbn" value="[% isbn %]" /></li> >+ <li><label for="lccall">LC Call Number: </label> <input type="text" id="lccall" name="lccall" value="" /></li> >+ <li><label for="controlnumber">Control No.: </label> <input type="text" id="controlnumber" name="controlnumber" value="" /></li> >+ <li><label for="srchany">Raw (any): </label> <input type="text" id="srchany" name="srchany" value="" /></li></ol> >+ </fieldset> >+ </div> >+ <div class="yui-u"> >+ <fieldset class="rows"> <ol><li><label for="author">Author: </label> <input type="text" id="author" name="author" value="[% author %]" /><!-- <label for="Keyword">Keyword</label> <input type="text" name="keyword" value="" /> --></li> >+ <li> <label for="subject">Subject Heading: </label> <input type="text" id="subject" name="subject" value="" /></li> >+ <li><label for="dewey">Dewey: </label> <input type="text" id="dewey" name="dewey" value="" /></li> >+ <li><label for="stdid">Standard ID: </label> <input type="text" id="stdid" name="stdid" value="" /></li></ol> >+ </fieldset> >+ </div> >+</div> >+<div class="yui-g"> >+<h2>Search targets <span style="display: inline; font-size: 70%; padding-left: 1em;"><span class="checkall"><a id="CheckAll" href="#">Select all</a></span><span class="clearall"><a id="CheckNone" href="#">Clear all</a></span></span></h2> >+ >+ [% FOREACH serverloo IN serverloop %] >+ <p> >+ [% IF ( serverloo.checked ) %] >+ <input type="checkbox" name="id" id="z3950_[% serverloo.id %]" value="[% serverloo.id %]" checked="checked" /> >+ [% ELSE %] >+ <input type="checkbox" name="id" id="z3950_[% serverloo.id %]" value="[% serverloo.id %]" /> >+ [% END %] >+ <label for="z3950_[% serverloo.id %]">[% serverloo.name %]</label> >+ >+ </p> >+ [% END %] >+ </div> >+ <fieldset class="action"><input type="submit" class="submit" value="Search" onclick="cursor :'wait'"/> <a class="cancel close" href="#">Cancel</a></fieldset> >+ </form> >+ >+ >+[% ELSE %] >+ <h2>Results</h2> >+ [% IF ( breeding_loop ) %] >+ <table id="resultst"> >+<thead> <tr> >+ <th>Server</th> >+ <th>Title</th> >+ <th>Author</th> >+ <th>Date</th> >+ <th>Edition</th> >+ <th>ISBN</th> >+ <th>LCCN</th> >+ <th>MARC</th> >+ <th>Card</th> >+ <th> </th> >+ </tr></thead> >+ <tbody>[% FOREACH breeding_loo IN breeding_loop %] >+ [% IF ( breeding_loo.biblionumber ) %] >+ >+ <tr id="row[% breeding_loo.biblionumber %]"> >+ <td>[% breeding_loo.server %] <div class="linktools"> >+ <a href="http://[% breeding_loo.host %]/cgi-bin/koha/opac-showmarc.pl?id=[% breeding_loo.biblionumber %]" rel="gb_page_center[600,500]">Preview MARC</a> >+ <a href="http://[% breeding_loo.host %]/cgi-bin/koha/opac-showmarc.pl?viewas=card&id=[% breeding_loo.biblionumber %]" rel="gb_page_center[600,500]">Preview Card</a> >+ <a target="_blank" href="http://[% breeding_loo.host %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% breeding_loo.biblionumber %]">Show</a> >+ <a href="#" onclick="closemenu();return false;" title="Close this menu"> X </a></div> </td> >+ <td>[% breeding_loo.title |html %]</td> >+ <td>[% breeding_loo.author %]</td> >+ <td>[% breeding_loo.date %]</td> >+ <td>[% breeding_loo.edition %]</td> >+ <td>[% breeding_loo.isbn %]</td> >+ <td>[% breeding_loo.lccn %]</td> >+ <td><a href="http://[% breeding_loo.host %]/cgi-bin/koha/opac-showmarc.pl?id=[% breeding_loo.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">MARC</a></td> >+ <td><a href="http://[% breeding_loo.host %]/cgi-bin/koha/opac-showmarc.pl?viewas=card&id=[% breeding_loo.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">Card</a></td> >+ <td><a target="_blank" href="http://[% breeding_loo.host %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% breeding_loo.biblionumber %]">Show</a></td> >+ </tr> >+ [% END %] >+ [% END %]</tbody> >+</table> >+ >+ <form method="post" action="opac-z3950-search.pl" id="page_form" name="page_form" class="checkboxed"> >+ <input type="hidden" name="op" id="op" value="do_search" /> >+ <input type="hidden" name="current_page" id="current_page" value="[% current_page %]" /> >+ <input type="hidden" id="title" name="title" value="[% title %]" /> >+ <input type="hidden" id="isbn" name="isbn" value="[% isbn %]" /> >+ <input type="hidden" id="lccall" name="lccall" value="[% lccall %]" /> >+ <input type="hidden" id="controlnumber" name="controlnumber" value="[% controlnumber %]" /> >+ <input type="hidden" id="srchany" name="srchany" value="[% srchany %]" /> >+ <input type="hidden" id="author" name="author" value="[% author %]" /> >+ <input type="hidden" id="subject" name="subject" value="[% subject %]" /> >+ <input type="hidden" id="dewey" name="dewey" value="[% dewey %]" /> >+ <input type="hidden" id="stdid" name="stdid" value="[% stdid %]" /> >+ >+ [% FOREACH server IN servers %] >+ <input type="hidden" name="id" id="z3950_[% server.id %]" value="[% server.id %]" /> >+ [% END %] >+ >+ [% IF ( show_prevbutton ) %] >+ <input type="button" name="changepage_prev" value="Previous Page" onclick="$('#current_page').val([% current_page %]-1);$('#page_form').submit();" /> >+ [% END %] >+ Page [% current_page %] / [% total_pages %] >+ [% IF ( show_nextbutton ) %] >+ <input type="button" name="changepage_next" value="Next Page" onclick="$('#current_page').val([% current_page %]+1);$('#page_form').submit();" /> >+ [% END %] >+ <br />Go to page : <input id="goto_page" name="goto_page" value="[% current_page %]" size="4" /><input type="submit" name="changepage_goto" onclick="return validate_goto_page();" value="Go" /> >+ </form> >+ >+ [% ELSE %] >+ [% IF ( emptyserverlist ) %] >+ You didn't select any Z39.50 target. >+ [% ELSE %] >+ [% FOREACH errcon IN errconn %] >+ Connection failed to [% errcon.server %] >+ [% END %] >+ [% END %] >+ <p>Nothing found.</p> >+ <p><form method="get" action="/cgi-bin/koha/opac-z3950-search.pl"><input type="hidden" name="biblionumber" value="[% biblionumber %]"/><input type="hidden" name="frameworkcode" value="[% frameworkcode %]"/><input type="submit" value="Try Another Search"/></form></p> >+ [% END %] >+[% END %] >+ >+ </div> >+</div> >+[% IF ( numberpending ) %]<h3 align="center">Still [% numberpending %] servers to search</h3>[% END %] >+ >+</body> >+</html> >+ >diff --git a/opac/opac-z3950-search.pl b/opac/opac-z3950-search.pl >new file mode 100755 >index 0000000..a7316ca >--- /dev/null >+++ b/opac/opac-z3950-search.pl >@@ -0,0 +1,323 @@ >+#!/usr/bin/perl >+ >+# This is a completely new Z3950 clients search using async ZOOM -TG 02/11/06 >+# Copyright 2000-2002 Katipo Communications >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use strict; >+use warnings; >+use CGI; >+ >+use C4::Auth; >+use C4::Output; >+use C4::Biblio; >+use C4::Context; >+use C4::Koha; >+use C4::Charset; >+use ZOOM; >+ >+my $input = new CGI; >+my $dbh = C4::Context->dbh; >+my $error = $input->param('error'); >+my $title = $input->param('title'); >+my $author = $input->param('author'); >+my $isbn = $input->param('isbn'); >+my $issn = $input->param('issn'); >+my $lccn = $input->param('lccn'); >+my $lccall = $input->param('lccall'); >+my $subject = $input->param('subject'); >+my $dewey = $input->param('dewey'); >+my $controlnumber = $input->param('controlnumber'); >+my $stdid = $input->param('stdid'); >+my $srchany = $input->param('srchany'); >+my $random = $input->param('random') || rand(1000000000); # this var is not useful anymore just kept for rel2_2 compatibility >+my $op = $input->param('op'); >+ >+my $page = $input->param('current_page') || 1; >+$page = $input->param('goto_page') if $input->param('changepage_goto'); >+my $show_next = 0; >+my $total_pages = 0; >+ >+my $numberpending; >+my $attr = ''; >+my $term; >+my $host; >+my $server; >+my $database; >+my $port; >+my $marcdata; >+my @encoding; >+my @results; >+my $count; >+my $record; >+my $oldbiblio; >+my $errmsg; >+my @serverloop = (); >+my @serverhost; >+my @servername; >+my @breeding_loop = (); >+ >+my $DEBUG = 0; # if set to 1, many debug message are send on syslog. >+ >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user({ >+ template_name => "opac-z3950-search.tt", >+ query => $input, >+ type => "opac", >+ authnotrequired => 1, >+ debug => 1, >+}); >+ >+$template->param( >+ isbn => $isbn, >+ issn => $issn, >+ lccn => $lccn, >+ lccall => $lccall, >+ title => $title, >+ author => $author, >+ controlnumber=> $controlnumber, >+ stdid => $stdid, >+ srchany => $srchany, >+ dewey => $dewey, >+ subject => $subject, >+); >+ >+if ( $op ne "do_search" ) { >+ my $sth = $dbh->prepare("select id,host,name,checked from z3950servers where opac=1 order by host;"); >+ $sth->execute(); >+ my $serverloop = $sth->fetchall_arrayref( {} ); >+ $template->param( >+ serverloop => $serverloop, >+ opsearch => "search", >+ ); >+ output_html_with_http_headers $input, $cookie, $template->output; >+} >+else { >+ my @id = $input->param('id'); >+ >+ if ( not defined @id ) { >+ # empty server list -> report and exit >+ $template->param( emptyserverlist => 1 ); >+ output_html_with_http_headers $input, $cookie, $template->output; >+ exit; >+ } >+ >+ my @oConnection; >+ my @oResult; >+ my @errconn; >+ my $s = 0; >+ my $query; >+ my $nterms; >+ if ($isbn || $issn) { >+ $term=$isbn if ($isbn); >+ $term=$issn if ($issn); >+ $term =~ s/"/\\"/; >+ $query .= " \@or \@attr 1=8 \"$term\" \@attr 1=7 \"$term\" "; >+ $nterms++; >+ } >+ if ($title) { >+ utf8::decode($title); >+ $title =~ s/"/\\"/; >+ $query .= " \@attr 1=4 \"$title\" "; >+ $nterms++; >+ } >+ if ($author) { >+ utf8::decode($author); >+ $author =~ s/"/\\"/; >+ $query .= " \@attr 1=1003 \"$author\" "; >+ $nterms++; >+ } >+ if ($dewey) { >+ $dewey =~ s/"/\\"/; >+ $query .= " \@attr 1=16 \"$dewey\" "; >+ $nterms++; >+ } >+ if ($subject) { >+ utf8::decode($subject); >+ $subject =~ s/"/\\"/; >+ $query .= " \@attr 1=21 \"$subject\" "; >+ $nterms++; >+ } >+ if ($lccn) { >+ $lccn =~ s/"/\\"/; >+ $query .= " \@attr 1=9 \"$lccn\" "; >+ $nterms++; >+ } >+ if ($lccall) { >+ $lccall =~ s/"/\\"/; >+ $query .= " \@attr 1=16 \@attr 2=3 \@attr 3=1 \@attr 4=1 \@attr 5=1 \@attr 6=1 \"$lccall\" "; >+ $nterms++; >+ } >+ if ($controlnumber) { >+ $controlnumber =~ s/"/\\"/; >+ $query .= " \@attr 1=12 \"$controlnumber\" "; >+ $nterms++; >+ } >+ if ($stdid) { >+ $stdid =~ s/"/\\"/; >+ $query .= " \@attr 1=1007 \"$stdid\" "; >+ $nterms++; >+ } >+ if ($srchany) { >+ $srchany =~ s/"/\\"/; >+ $query .= " \@attr 1=1016 \"$srchany\" "; >+ $nterms++; >+ } >+for my $i (1..$nterms-1) { >+ $query = "\@and " . $query; >+} >+warn "query ".$query if $DEBUG; >+ >+ foreach my $servid (@id) { >+ my $sth = $dbh->prepare("select * from z3950servers where id=?"); >+ $sth->execute($servid); >+ while ( $server = $sth->fetchrow_hashref ) { >+ warn "serverinfo ".join(':',%$server) if $DEBUG; >+ my $option1 = new ZOOM::Options(); >+ $option1->option('async' => 1); >+ $option1->option('elementSetName', 'F'); >+ $option1->option('databaseName', $server->{db}); >+ $option1->option('user', $server->{userid} ) if $server->{userid}; >+ $option1->option('password', $server->{password}) if $server->{password}; >+ $option1->option('preferredRecordSyntax', $server->{syntax}); >+ $oConnection[$s] = create ZOOM::Connection($option1) >+ || $DEBUG >+ && warn( "" . $oConnection[$s]->errmsg() ); >+ warn( "server data", $server->{name}, $server->{port} ) if $DEBUG; >+ $oConnection[$s]->connect( $server->{host}, $server->{port} ) >+ || $DEBUG >+ && warn( "" . $oConnection[$s]->errmsg() ); >+ $serverhost[$s] = $server->{host}; >+ $servername[$s] = $server->{name}; >+ $encoding[$s] = ($server->{encoding}?$server->{encoding}:"iso-5426"); >+ $s++; >+ } ## while fetch >+ } # foreach >+ my $nremaining = $s; >+ my $firstresult = 1; >+ >+ for ( my $z = 0 ; $z < $s ; $z++ ) { >+ warn "doing the search" if $DEBUG; >+ $oResult[$z] = $oConnection[$z]->search_pqf($query) >+ || $DEBUG >+ && warn( "somthing went wrong: " . $oConnection[$s]->errmsg() ); >+ >+ # $oResult[$z] = $oConnection[$z]->search_pqf($query); >+ } >+ >+ AGAIN: >+ my $k; >+ my $event; >+ while ( ( $k = ZOOM::event( \@oConnection ) ) != 0 ) { >+ $event = $oConnection[ $k - 1 ]->last_event(); >+ warn( "connection ", $k - 1, ": event $event (", >+ ZOOM::event_str($event), ")\n" ) >+ if $DEBUG; >+ last if $event == ZOOM::Event::ZEND; >+ } >+ >+ if ( $k != 0 ) { >+ $k--; >+ warn $serverhost[$k] if $DEBUG; >+ my ( $error, $errmsg, $addinfo, $diagset ) = >+ $oConnection[$k]->error_x(); >+ if ($error) { >+ if ($error =~ m/^(10000|10007)$/ ) { >+ push(@errconn, {'server' => $serverhost[$k]}); >+ } >+ $DEBUG and warn "$k $serverhost[$k] error $query: $errmsg ($error) $addinfo\n"; >+ } >+ else { >+ my $numresults = $oResult[$k]->size(); >+ my $i; >+ my $result = ''; >+ if ( $numresults > 0 and $numresults >= (($page-1)*20)) { >+ $show_next = 1 if $numresults >= ($page*20); >+ $total_pages = int($numresults/20)+1 if $total_pages < ($numresults/20); >+ for ($i = ($page-1)*20; $i < (($numresults < ($page*20)) ? $numresults : ($page*20)); $i++) { >+ my $rec = $oResult[$k]->record($i); >+ if ($rec) { >+ my $marcrecord; >+ $marcdata = $rec->raw(); >+ >+ my ($charset_result, $charset_errors); >+ ($marcrecord, $charset_result, $charset_errors) = >+ MarcToUTF8Record($marcdata, C4::Context->preference('marcflavour'), $encoding[$k]); >+####WARNING records coming from Z3950 clients are in various character sets MARC8,UTF8,UNIMARC etc >+## In HEAD i change everything to UTF-8 >+# In rel2_2 i am not sure what encoding is so no character conversion is done here >+##Add necessary encoding changes to here -TG >+ >+ SetUTF8Flag($marcrecord); >+ >+ my $oldbiblio = TransformMarcToKoha( $dbh, $marcrecord, "" ); >+ $oldbiblio->{isbn} =~ s/ |-|\.//g if $oldbiblio->{isbn}; >+ # pad | and ( with spaces to allow line breaks in the html >+ $oldbiblio->{isbn} =~ s/\|/ \| /g if $oldbiblio->{isbn}; >+ $oldbiblio->{isbn} =~ s/\(/ \(/g if $oldbiblio->{isbn}; >+ >+ $oldbiblio->{issn} =~ s/ |-|\.//g if $oldbiblio->{issn}; >+ # pad | and ( with spaces to allow line breaks in the html >+ $oldbiblio->{issn} =~ s/\|/ \| /g if $oldbiblio->{issn}; >+ $oldbiblio->{issn} =~ s/\(/ \(/g if $oldbiblio->{issn}; >+ my %row_data; >+ $row_data{server} = $servername[$k]; >+ $row_data{host} = $serverhost[$k]; >+ $row_data{isbn} = $oldbiblio->{isbn}; >+ $row_data{lccn} = $oldbiblio->{lccn}; >+ $row_data{title} = $oldbiblio->{title}; >+ $row_data{author} = $oldbiblio->{author}; >+ $row_data{date} = $oldbiblio->{copyrightdate}; >+ $row_data{edition} = $oldbiblio->{editionstatement}; >+ $row_data{biblionumber} = $oldbiblio->{biblionumber}; >+ push( @breeding_loop, \%row_data ); >+ >+ } else { >+ push(@breeding_loop,{'server'=>$servername[$k],'title'=>join(': ',$oConnection[$k]->error_x()),'biblionumber'=>-1}); >+ } # $rec >+ } >+ } #$numresults >+ } >+ } # if $k !=0 >+ $numberpending = $nremaining - 1; >+ >+ my @servers = (); >+ foreach my $id (@id) { >+ push(@servers,{id => $id}); >+ } >+ >+ $template->param( >+ breeding_loop => \@breeding_loop, >+ server => $servername[$k], >+ numberpending => $numberpending, >+ errconn => \@errconn, >+ current_page => $page, >+ servers => \@servers, >+ total_pages => $total_pages, >+ ); >+ $template->param(show_nextbutton=>1) if $show_next; >+ $template->param(show_prevbutton=>1) if $page != 1; >+ >+ output_html_with_http_headers $input, $cookie, $template->output if $numberpending == 0; >+ >+ # print $template->output if $firstresult !=1; >+ $firstresult++; >+ >+ MAYBE_AGAIN: >+ if ( --$nremaining > 0 ) { >+ goto AGAIN; >+ } >+} ## if op=search >-- >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 11361
:
23365
|
60950
|
60951
|
60952
|
72812
|
72813
|
95808
|
100077
|
100463
|
100470
|
113334
|
119535
|
119536
|
119928