new and modified plugins for unimarc biblio management.
note that the plugin api has been deeply modified, and should now be definitive. It will be documented soon on the wiki.
This commit is contained in:
parent
1215d1dc77
commit
421de1df64
|
|
@ -0,0 +1,23 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>UNIMARC Field 100 builder</title>
|
||||
</head>
|
||||
<body>
|
||||
<form name="f_pop" onSubmit="javascript:report()">
|
||||
<table>
|
||||
<tr>
|
||||
<td>Select a collection</td>
|
||||
<td><TMPL_VAR name="collection"></td>
|
||||
</tr>
|
||||
<tr><td colspan=2><input type="submit" value="OK"></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
<script>
|
||||
function report() {
|
||||
opener.document.f.field_value[<TMPL_VAR name="index">].value= document.f_pop.f1.value;
|
||||
self.close();
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Personal Authorities builder</title>
|
||||
</head>
|
||||
<body>
|
||||
<form name="f_pop" action="plugin_launcher.pl" method="post">
|
||||
<input type="hidden" name="plugin_name" value="unimarc_field_700_701_702.pl">
|
||||
<textarea name="result" rows=10 cols=60><TMPL_VAR name="result"></textarea></br>
|
||||
<p><input type="text" name="search_string" value="<TMPL_VAR name="search_string">">
|
||||
<input type="hidden" name="index" value="<TMPL_VAR name="index">">
|
||||
<input type="hidden" name="op" value="search">
|
||||
<input type="hidden" name="a" value="<TMPL_VAR name="a">">
|
||||
<input type="hidden" name="b" value="<TMPL_VAR name="b">">
|
||||
<input type="hidden" name="c" value="<TMPL_VAR name="c">">
|
||||
<input type="hidden" name="f" value="<TMPL_VAR name="f">">
|
||||
<input type="submit" value="Search"><input type="button" value="END" onClick="javascript:report()">
|
||||
</form>
|
||||
<TMPL_IF name="search_string">
|
||||
<form name="f2_pop" action="plugin_launcher.pl" method="post">
|
||||
<input type="hidden" name="plugin_name" value="unimarc_field_700_701_702.pl">
|
||||
<TMPL_VAR name="select_list">
|
||||
<input type="hidden" name="index" value="<TMPL_VAR name="index">">
|
||||
<input type="hidden" name="op" value="select">
|
||||
<input type="hidden" name="result" value="<TMPL_VAR name="result">">
|
||||
<input type="submit" name="OK" value="OK">
|
||||
</form>
|
||||
</TMPL_IF>
|
||||
<form name="f3_pop" action="plugin_launcher.pl" method="post">
|
||||
<input type="hidden" name="plugin_name" value="unimarc_field_700_701_702.pl">
|
||||
<input type="hidden" name="index" value="<TMPL_VAR name="index">">
|
||||
<input type="hidden" name="op" value="add">
|
||||
insert a new authority : <input type="text" name="insert" value="<TMPL_VAR name="search_string">">
|
||||
<input type="submit" name="NEW" value="NEW">
|
||||
</form>
|
||||
<script>
|
||||
function report() {
|
||||
var index_start=<TMPL_VAR name="index">;
|
||||
opener.document.f.field_value[index_start].value= document.f_pop.result.value;
|
||||
var whichfield = opener.document.f.tag[index_start].value;
|
||||
for (i=index_start ; i<opener.document.f.field_value.length ; i++) {
|
||||
if (opener.document.f.tag[i].value == whichfield && opener.document.f.subfield[i].value == 'a') {
|
||||
opener.document.f.field_value[i].value = document.f_pop.a.value;
|
||||
}
|
||||
}
|
||||
for (i=index_start ; i<opener.document.f.field_value.length ; i++) {
|
||||
if (opener.document.f.tag[i].value == whichfield && opener.document.f.subfield[i].value == 'b') {
|
||||
opener.document.f.field_value[i].value = document.f_pop.b.value;
|
||||
}
|
||||
}
|
||||
for (i=index_start ; i<opener.document.f.field_value.length ; i++) {
|
||||
if (opener.document.f.tag[i].value == whichfield && opener.document.f.subfield[i].value == 'c') {
|
||||
opener.document.f.field_value[i].value = document.f_pop.c.value;
|
||||
}
|
||||
}
|
||||
for (i=index_start ; i<opener.document.f.field_value.length ; i++) {
|
||||
if (opener.document.f.tag[i].value == whichfield && opener.document.f.subfield[i].value == 'f') {
|
||||
opener.document.f.field_value[i].value = document.f_pop.f.value;
|
||||
}
|
||||
}
|
||||
self.close();
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# written 10/5/2002 by Paul
|
||||
# $Id$
|
||||
|
||||
# Copyright 2000-2002 Katipo Communications
|
||||
#
|
||||
|
|
@ -27,10 +27,32 @@ use C4::Search;
|
|||
use C4::Output;
|
||||
|
||||
sub plugin_parameters {
|
||||
my ($dbh,$record,$tagslib) = @_;
|
||||
my ($dbh,$record,$tagslib,$i,$tabloop) = @_;
|
||||
return "";
|
||||
}
|
||||
sub plugin_javascript {
|
||||
my ($dbh,$record,$tagslib,$i,$tabloop) = @_;
|
||||
my $function_name= "100".(int(rand(100000))+1);
|
||||
my $res="
|
||||
<script>
|
||||
function Focus$function_name(subfield_managed) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
function Blur$function_name(subfield_managed) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
function Clic$function_name(i) {
|
||||
defaultvalue=document.forms[0].field_value[i].value;
|
||||
newin=window.open(\"../plugin_launcher.pl?plugin_name=unimarc_field_100.pl&index=\"+i+\"&result=\"+defaultvalue,\"unimarc field 100\",'width=500,height=400,toolbar=false,scrollbars=yes');
|
||||
|
||||
}
|
||||
</script>
|
||||
";
|
||||
|
||||
return ($function_name,$res);
|
||||
}
|
||||
sub plugin {
|
||||
my ($input) = @_;
|
||||
my %env;
|
||||
|
|
@ -47,7 +69,6 @@ my ($input) = @_;
|
|||
my $f2 = substr($result,8,1);
|
||||
my $f3 = substr($result,9,4);
|
||||
my $f4 = substr($result,13,4);
|
||||
warn "f2 : $f2";
|
||||
$template->param(index => $index,
|
||||
f1 => $f1,
|
||||
f3 => $f3,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,106 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# $Id$
|
||||
|
||||
# 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., 59 Temple Place,
|
||||
# Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
use strict;
|
||||
use CGI;
|
||||
use C4::Context;
|
||||
use HTML::Template;
|
||||
use C4::Search;
|
||||
use C4::Output;
|
||||
|
||||
sub plugin_parameters {
|
||||
my ($dbh,$record,$tagslib,$i,$tabloop) = @_;
|
||||
return "";
|
||||
}
|
||||
sub plugin_javascript {
|
||||
my ($dbh,$record,$tagslib,$i,$tabloop) = @_;
|
||||
my $function_name= "100".(int(rand(100000))+1);
|
||||
my $res="
|
||||
<script>
|
||||
function Focus$function_name(subfield_managed) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
function Blur$function_name(subfield_managed) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
function Clic$function_name(index) {
|
||||
// find the 010a value and the 210c. it will be used in the popup to find possibles collections
|
||||
var isbn_found;
|
||||
for (i=0 ; i<document.f.field_value.length ; i++) {
|
||||
if (document.f.tag[i].value == '010' && document.f.subfield[i].value == 'a') {
|
||||
isbn_found=document.f.field_value[i].value;
|
||||
}
|
||||
}
|
||||
var editor_found;
|
||||
for (i=0 ; i<document.f.field_value.length ; i++) {
|
||||
if (document.f.tag[i].value == '210' && document.f.subfield[i].value == 'c') {
|
||||
editor_found=document.f.field_value[i].value;
|
||||
}
|
||||
}
|
||||
|
||||
defaultvalue=document.f.field_value[index].value;
|
||||
newin=window.open(\"../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');
|
||||
|
||||
}
|
||||
</script>
|
||||
";
|
||||
|
||||
return ($function_name,$res);
|
||||
}
|
||||
sub plugin {
|
||||
my ($input) = @_;
|
||||
my %env;
|
||||
|
||||
# my $input = new CGI;
|
||||
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 = gettemplate("value_builder/unimarc_field_225a.tmpl",0);
|
||||
# builds collection list : search isbn and editor, in parent, then load collections from bibliothesaurus table
|
||||
my $sth = $dbh->prepare("select stdlib from bibliothesaurus where father=? and category='EDITORS'");
|
||||
my @splited = split //, $isbn_found;
|
||||
my $isbn_rebuild='';
|
||||
my @collections;
|
||||
foreach my $x (@splited) {
|
||||
$isbn_rebuild.=$x;
|
||||
$sth->execute("$isbn_rebuild $authoritysep $editor_found $authoritysep");
|
||||
while (my ($line)= $sth->fetchrow) {
|
||||
push @collections,$line;
|
||||
}
|
||||
}
|
||||
# my @collections = ["test"];
|
||||
my $collection =CGI::scrolling_list(-name=>'f1',
|
||||
-values=> \@collections,
|
||||
-default=>"$result",
|
||||
-size=>1,
|
||||
-multiple=>0,
|
||||
);
|
||||
$template->param(index => $index,
|
||||
collection => $collection);
|
||||
print "Content-Type: text/html\n\n", $template->output;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
@ -26,6 +26,22 @@ use HTML::Template;
|
|||
use C4::Search;
|
||||
use C4::Output;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
plugin unimarc_field_700-4
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
This plug-in deals with unimarc field 700-4 (
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
=head1 FUNCTIONS
|
||||
|
||||
=over 2
|
||||
|
||||
=cut
|
||||
|
||||
sub plugin_parameters {
|
||||
my ($dbh,$record,$tagslib,$morethan,$begin_tabloop) = @_;
|
||||
my $index2; # the resulting index
|
||||
|
|
@ -50,6 +66,11 @@ for (my $tabloop = $begin_tabloop; $tabloop<=9;$tabloop++) {
|
|||
return "&index2=$index2";
|
||||
}
|
||||
|
||||
sub plugin_javascript {
|
||||
my ($dbh,$record,$tagslib,$i,$tabloop) = @_;
|
||||
return ("","");
|
||||
}
|
||||
|
||||
sub plugin {
|
||||
my ($input) = @_;
|
||||
my %env;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,154 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# $Id$
|
||||
|
||||
# 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., 59 Temple Place,
|
||||
# Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
use strict;
|
||||
use CGI;
|
||||
use C4::Context;
|
||||
use HTML::Template;
|
||||
use C4::Search;
|
||||
use C4::Output;
|
||||
use C4::Authorities;
|
||||
|
||||
sub plugin_parameters {
|
||||
my ($dbh,$record,$tagslib,$i,$tabloop) = @_;
|
||||
return "";
|
||||
}
|
||||
sub plugin_javascript {
|
||||
my ($dbh,$record,$tagslib,$i,$tabloop) = @_;
|
||||
my $function_name= "100".(int(rand(100000))+1);
|
||||
my $res="
|
||||
<script>
|
||||
function Focus$function_name(subfield_managed) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
function Blur$function_name(subfield_managed) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
function Clic$function_name(index) {
|
||||
defaultvalue=document.f.field_value[index].value;
|
||||
newin=window.open(\"../plugin_launcher.pl?plugin_name=unimarc_field_700_701_702.pl&index=\"+index+\"&result=\"+defaultvalue,\"unimarc 700\",'width=700,height=300,toolbar=false,scrollbars=yes');
|
||||
|
||||
}
|
||||
</script>
|
||||
";
|
||||
|
||||
return ($function_name,$res);
|
||||
}
|
||||
sub plugin {
|
||||
my ($input) = @_;
|
||||
my %env;
|
||||
my $dbh = C4::Context->dbh;
|
||||
# my $input = new CGI;
|
||||
my $index= $input->param('index');
|
||||
my $result= $input->param('result');
|
||||
my $search_string= $input->param('search_string');
|
||||
my $op = $input->param('op');
|
||||
my $id = $input->param('id');
|
||||
my $insert = $input->param('insert');
|
||||
my @freelib;
|
||||
my %stdlib;
|
||||
my $select_list;
|
||||
my ($a,$b,$c,$f) ; # the 4 managed subfields.
|
||||
if ($op eq "add") {
|
||||
newauthority($dbh,'NP',$insert,$insert,'',1,'');
|
||||
$search_string=$insert;
|
||||
}
|
||||
if ($op eq "select") {
|
||||
my $sti = $dbh->prepare("select stdlib from bibliothesaurus where id=?");
|
||||
$sti->execute($id);
|
||||
my ($freelib_text) = $sti->fetchrow_array;
|
||||
$result = $freelib_text;
|
||||
# fill the 4 managed subfields
|
||||
my @arr = split //,$result;
|
||||
my $where = 1;
|
||||
foreach my $x (@arr) {
|
||||
next if ($x eq ')');
|
||||
if ($x eq ',') {
|
||||
$where=2;
|
||||
next;
|
||||
}
|
||||
if ($x eq '(') {
|
||||
if ($result =~ /.*;.*/) {
|
||||
$where=3;
|
||||
} else {
|
||||
$where=4;
|
||||
}
|
||||
next;
|
||||
}
|
||||
if ($x eq ';') {
|
||||
$where=4;
|
||||
next;
|
||||
}
|
||||
if ($where eq 1) {
|
||||
$a.=$x;
|
||||
}
|
||||
if ($where eq 2) {
|
||||
$b.=$x;
|
||||
}
|
||||
if ($where eq 3) {
|
||||
$c.=$x;
|
||||
}
|
||||
if ($where eq 4) {
|
||||
$f.=$x;
|
||||
}
|
||||
}
|
||||
# remove trailing blanks
|
||||
$a=~ s/^\s+//g;
|
||||
$b=~ s/^\s+//g;
|
||||
$c=~ s/^\s+//g;
|
||||
$f=~ s/^\s+//g;
|
||||
$a=~ s/\s+$//g;
|
||||
$b=~ s/\s+$//g;
|
||||
$c=~ s/\s+$//g;
|
||||
$f=~ s/^s+$//g;
|
||||
}
|
||||
if ($search_string) {
|
||||
# my $sti=$dbh->prepare("select id,freelib from bibliothesaurus where freelib like '".$search_string."%' and category ='$category'");
|
||||
my $sti=$dbh->prepare("select id,freelib from bibliothesaurus where match (category,freelib) AGAINST ('$search_string') and category ='NP'");
|
||||
$sti->execute;
|
||||
while (my $line=$sti->fetchrow_hashref) {
|
||||
$stdlib{$line->{'id'}} = "$line->{'freelib'}";
|
||||
push(@freelib,$line->{'id'});
|
||||
}
|
||||
$select_list= CGI::scrolling_list( -name=>'id',
|
||||
-values=> \@freelib,
|
||||
-default=> "",
|
||||
-size=>1,
|
||||
-multiple=>0,
|
||||
-labels=> \%stdlib
|
||||
);
|
||||
}
|
||||
my $template = gettemplate("value_builder/unimarc_field_700_701_702.tmpl",0);
|
||||
# builds collection list : search isbn and editor, in parent, then load collections from bibliothesaurus table
|
||||
$template->param(index => $index,
|
||||
result =>$result,
|
||||
select_list => $select_list,
|
||||
search_string => $search_string,
|
||||
a => $a,
|
||||
b => $b,
|
||||
c => $c,
|
||||
f => $f,);
|
||||
print "Content-Type: text/html\n\n", $template->output;
|
||||
}
|
||||
|
||||
1;
|
||||
Loading…
Reference in New Issue