(bug #3505) fix 210c and 225a unimarc's plugins
This fix the 2 plugins, make 225a to work with koha 3.0, and fix 210c to be xhtml valid Signed-off-by: Galen Charlton <gmcharlt@gmail.com> Signed-off-by: Henri-Damien LAURENT <henridamien.laurent@biblibre.com>
This commit is contained in:
parent
191dbb5b90
commit
6b24bfa5a4
|
|
@ -63,51 +63,12 @@ my $function_name= $field_number;
|
|||
#---- 200$a for isbn
|
||||
#---- 200$b for editor
|
||||
#---- 200$c (repeated) for collections
|
||||
my $sth
|
||||
= $dbh->prepare("select auth_subfield_table.authid,subfieldvalue from auth_subfield_table
|
||||
left join auth_header on auth_subfield_table.authid=auth_header.authid
|
||||
where authtypecode='EDITORS' and tag='200' and subfieldcode='a'");
|
||||
my $sth2
|
||||
= $dbh->prepare("select subfieldvalue from auth_subfield_table where tag='200' and subfieldcode='b' and authid=?");
|
||||
$sth->execute;
|
||||
my @editors;
|
||||
my $authoritysep = C4::Context->preference("authoritysep");
|
||||
while (my ($authid,$isbn) = $sth->fetchrow) {
|
||||
$sth2->execute($authid);
|
||||
my ($editor) = $sth2->fetchrow;
|
||||
push(@editors,"$isbn $authoritysep $editor");
|
||||
}
|
||||
|
||||
|
||||
my $res = "
|
||||
<script type=\"text/javascript\">
|
||||
function Focus$function_name(index) {
|
||||
var isbn_array = [ ";
|
||||
foreach my $editor (@editors) {
|
||||
my @arr = split (/ $authoritysep /,$editor);
|
||||
$res .='["'.$arr[0].'","'.$arr[1].'","'.$arr[2].'"],';
|
||||
}
|
||||
chop $res;
|
||||
$res .= "
|
||||
];
|
||||
// search isbn subfield. it''s 010a
|
||||
var isbn_found;
|
||||
var nb_fields = document.f.field_value.length;
|
||||
for (i=0 ; i< nb_fields; i++) {
|
||||
if (document.f.tag[i].value == '010' && document.f.subfield[i].value == 'a') {
|
||||
isbn_found=document.f.field_value[i].value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
try{
|
||||
isbn_found.getAttribute('value'); // throw an exception if doesn't (if no 010a)
|
||||
}
|
||||
catch(e){
|
||||
return;
|
||||
}
|
||||
for (i=0;i<=isbn_array.length;i++) {
|
||||
if (isbn_found.substr(0,isbn_array[i][0].length) == isbn_array[i][0]) {
|
||||
document.f.field_value[index].value =isbn_array[i][1];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function Blur$function_name(subfield_managed) {
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ use C4::Auth;
|
|||
use CGI;
|
||||
use C4::Context;
|
||||
|
||||
use C4::Search;
|
||||
use C4::AuthoritiesMarc;
|
||||
use C4::Output;
|
||||
|
||||
=head1
|
||||
|
|
@ -81,9 +81,6 @@ sub plugin_javascript {
|
|||
var inputs = document.getElementsByTagName('input');
|
||||
|
||||
for(var i=0 , len=inputs.length ; i \< len ; i++ ){
|
||||
if(inputs[i].id.match(/^tag_010_subfield_a_.*/)){
|
||||
isbn_found = inputs[i].value;
|
||||
}
|
||||
if(inputs[i].id.match(/^tag_210_subfield_c_.*/)){
|
||||
editor_found = inputs[i].value;
|
||||
}
|
||||
|
|
@ -93,7 +90,7 @@ sub plugin_javascript {
|
|||
}
|
||||
|
||||
defaultvalue = document.getElementById(\"$field_number\").value;
|
||||
window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=unimarc_field_225a.pl&index=\"+index+\"&result=\"+defaultvalue+\"&isbn_found=\"+isbn_found+\"&editor_found=\"+editor_found,\"unimarc 225a\",'width=500,height=200,toolbar=false,scrollbars=no');
|
||||
window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=unimarc_field_225a.pl&index=\"+index+\"&result=\"+defaultvalue+\"&editor_found=\"+editor_found,\"unimarc225a\",'width=500,height=200,toolbar=false,scrollbars=no');
|
||||
|
||||
}
|
||||
</script>
|
||||
|
|
@ -107,9 +104,8 @@ sub plugin {
|
|||
my $index = $input->param('index');
|
||||
my $result = $input->param('result');
|
||||
my $editor_found = $input->param('editor_found');
|
||||
my $isbn_found = $input->param('isbn_found');
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $authoritysep = C4::Context->preference("authoritysep");
|
||||
|
||||
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
|
||||
{
|
||||
template_name =>
|
||||
|
|
@ -125,62 +121,23 @@ sub plugin {
|
|||
# builds collection list : search isbn and editor, in parent, then load collections from bibliothesaurus table
|
||||
# if there is an isbn, complete search
|
||||
my @collections;
|
||||
if ($isbn_found) {
|
||||
my $sth = $dbh->prepare(
|
||||
"SELECT auth_subfield_table.authid,subfieldvalue
|
||||
FROM auth_subfield_table
|
||||
LEFT JOIN auth_header ON auth_subfield_table.authid = auth_header.authid
|
||||
WHERE authtypecode='EDITORS'
|
||||
AND tag='200'
|
||||
AND subfieldcode='a'
|
||||
AND subfieldvalue=?"
|
||||
);
|
||||
my $sth2 =
|
||||
$dbh->prepare(
|
||||
"SELECT subfieldvalue
|
||||
FROM auth_subfield_table
|
||||
WHERE tag='200'
|
||||
AND subfieldcode='c'
|
||||
AND authid=?
|
||||
ORDER BY subfieldvalue"
|
||||
);
|
||||
my @splited = split //, $isbn_found;
|
||||
my $isbn_rebuild = '';
|
||||
foreach my $x (@splited) {
|
||||
$isbn_rebuild .= $x;
|
||||
$sth->execute($isbn_rebuild);
|
||||
my ($authid) = $sth->fetchrow;
|
||||
$sth2->execute($authid);
|
||||
while ( my ($line) = $sth2->fetchrow ) {
|
||||
push @collections, $line;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
my $sth = $dbh->prepare(
|
||||
"SELECT auth_subfield_table.authid,subfieldvalue
|
||||
FROM auth_subfield_table
|
||||
LEFT JOIN auth_header ON auth_subfield_table.authid = auth_header.authid
|
||||
WHERE authtypecode='EDITORS'
|
||||
AND tag='200'
|
||||
AND subfieldcode='b'
|
||||
AND subfieldvalue=?"
|
||||
);
|
||||
my $sth2 =
|
||||
$dbh->prepare(
|
||||
"SELECT subfieldvalue
|
||||
FROM auth_subfield_table
|
||||
WHERE tag='200'
|
||||
AND subfieldcode='c'
|
||||
AND authid=?
|
||||
ORDER BY subfieldvalue"
|
||||
);
|
||||
$sth->execute($editor_found);
|
||||
my ($authid) = $sth->fetchrow;
|
||||
$sth2->execute($authid);
|
||||
while ( my ($line) = $sth2->fetchrow ) {
|
||||
push @collections, $line;
|
||||
|
||||
my @value = ($editor_found,"","");
|
||||
my @tags = ("mainentry","","");
|
||||
my @and_or = ('and','','');
|
||||
my @operator = ('is','','');
|
||||
my @excluding = ('','','');
|
||||
|
||||
|
||||
my ($results,$total) = SearchAuthorities( \@tags,\@and_or,
|
||||
\@excluding, \@operator, \@value,
|
||||
0, 20,"EDITORS", "HeadingAsc");
|
||||
foreach my $editor (@$results){
|
||||
my $authority = GetAuthority($editor->{authid});
|
||||
foreach my $col ($authority->subfield('200','c')){
|
||||
push @collections, $col;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# my @collections = ["test"];
|
||||
|
|
|
|||
|
|
@ -1,26 +1,31 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<div id="mainbloc">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>UNIMARC_Field 125b builder</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="mainbloc">
|
||||
<h1 class="authority">Authority search results</h1>
|
||||
<div id="bloc25">
|
||||
<div>
|
||||
<form name="f" method="post" action="plugin_launcher.pl">
|
||||
<input type="hidden" name="plugin_name" value="unimarc_field_210c.pl">
|
||||
<input type="hidden" name="op" value="do_search">
|
||||
<input type="hidden" name="type" value="intranet">
|
||||
<input type="hidden" name="nbstatements" value="<!-- TMPL_VAR NAME="nbstatements" -->">
|
||||
<div id="bloc25">
|
||||
<input type="hidden" name="plugin_name" value="unimarc_field_210c.pl" />
|
||||
<input type="hidden" name="op" value="do_search" />
|
||||
<input type="hidden" name="type" value="intranet" />
|
||||
<input type="hidden" name="nbstatements" value="<!-- TMPL_VAR NAME="nbstatements" -->" />
|
||||
<div>
|
||||
<h2 class="authority">Search on</h2>
|
||||
<p>
|
||||
<label class="label100">Authority type</label>
|
||||
EDITORS
|
||||
</p>
|
||||
<p>
|
||||
<label class="label100">Search value</label><input type="text" name="value" value="<!-- TMPL_VAR name="resultstring" -->">
|
||||
<input type="hidden" name="index" value="<!--TMPL_VAR Name="index"-->">
|
||||
<input type="hidden" name="authtypecode" value="EDITORS">
|
||||
<input type="hidden" name="q" value="<!-- TMPL_VAR NAME="index" -->">
|
||||
<label class="label100">Search value</label><input type="text" name="value" value="<!-- TMPL_VAR name="resultstring" -->" />
|
||||
<input type="hidden" name="index" value="<!--TMPL_VAR Name="index"-->" />
|
||||
<input type="hidden" name="authtypecode" value="EDITORS" />
|
||||
<input type="hidden" name="q" value="<!-- TMPL_VAR NAME="index" -->" />
|
||||
<input type="hidden" name="marclist" value="all" />
|
||||
<input type="hidden" name="and_or" value="and" />
|
||||
<input type="hidden" name="excluding" value="" />
|
||||
|
|
@ -37,21 +42,21 @@
|
|||
|
||||
</p>
|
||||
<p>
|
||||
<input type="submit" value="Start search" class="button authority">
|
||||
<input type="submit" value="Start search" class="button authority" />
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div id="bloc25">
|
||||
<div id="resultnumber">
|
||||
<div>
|
||||
<div>
|
||||
<div class="paginationBar">
|
||||
<!--TMPL_VAR Name="pagination_bar"-->
|
||||
</div>
|
||||
<p>
|
||||
<!-- TMPL_IF name="total" -->
|
||||
<b>Results <!-- TMPL_VAR NAME="from" --> to <!-- TMPL_VAR NAME="to" --> of <!-- TMPL_VAR NAME="total" --></b><br><br>
|
||||
<b>Results <!-- TMPL_VAR NAME="from" --> to <!-- TMPL_VAR NAME="to" --> of <!-- TMPL_VAR NAME="total" --></b><br /><br />
|
||||
<!-- TMPL_ELSE -->
|
||||
No results found<br>
|
||||
No results found<br />
|
||||
<!-- /TMPL_IF -->
|
||||
</p>
|
||||
</div>
|
||||
|
|
@ -74,7 +79,7 @@
|
|||
</table>
|
||||
|
||||
</div>
|
||||
<div id="resultnumber">
|
||||
<div>
|
||||
<div class="paginationBar">
|
||||
<!--TMPL_VAR Name="pagination_bar"-->
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,15 +1,16 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>UNIMARC_Field 225a builder</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="mainbloc">
|
||||
<form name="f_pop" onSubmit="javascript:report()">
|
||||
<form name="f_pop" onsubmit="javascript:report()" action="">
|
||||
<h2 class="authority">Collection</h2>
|
||||
<p><label>Select a collection</label><!-- TMPL_VAR name="collection" --></p>
|
||||
<input type="submit" value="OK" class="button authority"></p>
|
||||
<input type="submit" value="OK" class="button authority" />
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue