From 421de1df6471d4a624f8b5a5e0b03ebbf714fc77 Mon Sep 17 00:00:00 2001 From: tipaul Date: Tue, 10 Dec 2002 13:52:20 +0000 Subject: [PATCH] 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. --- .../en/value_builder/unimarc_field_225a.tmpl | 23 +++ .../unimarc_field_700_701_702.tmpl | 65 ++++++++ value_builder/unimarc_field_100.pl | 27 ++- value_builder/unimarc_field_225a.pl | 106 ++++++++++++ value_builder/unimarc_field_700-4.pl | 21 +++ value_builder/unimarc_field_700_701_702.pl | 154 ++++++++++++++++++ 6 files changed, 393 insertions(+), 3 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/default/en/value_builder/unimarc_field_225a.tmpl create mode 100644 koha-tmpl/intranet-tmpl/default/en/value_builder/unimarc_field_700_701_702.tmpl create mode 100644 value_builder/unimarc_field_225a.pl create mode 100644 value_builder/unimarc_field_700_701_702.pl diff --git a/koha-tmpl/intranet-tmpl/default/en/value_builder/unimarc_field_225a.tmpl b/koha-tmpl/intranet-tmpl/default/en/value_builder/unimarc_field_225a.tmpl new file mode 100644 index 0000000000..85e378cce6 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/default/en/value_builder/unimarc_field_225a.tmpl @@ -0,0 +1,23 @@ + + +UNIMARC Field 100 builder + + +
+ + + + + + +
Select a collection
+
+ + + diff --git a/koha-tmpl/intranet-tmpl/default/en/value_builder/unimarc_field_700_701_702.tmpl b/koha-tmpl/intranet-tmpl/default/en/value_builder/unimarc_field_700_701_702.tmpl new file mode 100644 index 0000000000..b79f6661d4 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/default/en/value_builder/unimarc_field_700_701_702.tmpl @@ -0,0 +1,65 @@ + + +Personal Authorities builder + + +
+ +
+

"> + "> + + "> + "> + "> + "> + +

+ +
+ + + "> + + "> + + +
+
+ + "> + + insert a new authority : "> + +
+ + + diff --git a/value_builder/unimarc_field_100.pl b/value_builder/unimarc_field_100.pl index 988b66bf0d..05a67fa35d 100755 --- a/value_builder/unimarc_field_100.pl +++ b/value_builder/unimarc_field_100.pl @@ -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=" + +"; + +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, diff --git a/value_builder/unimarc_field_225a.pl b/value_builder/unimarc_field_225a.pl new file mode 100644 index 0000000000..36617037b5 --- /dev/null +++ b/value_builder/unimarc_field_225a.pl @@ -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=" + +"; + +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; diff --git a/value_builder/unimarc_field_700-4.pl b/value_builder/unimarc_field_700-4.pl index 7022df20de..e010171266 100755 --- a/value_builder/unimarc_field_700-4.pl +++ b/value_builder/unimarc_field_700-4.pl @@ -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; diff --git a/value_builder/unimarc_field_700_701_702.pl b/value_builder/unimarc_field_700_701_702.pl new file mode 100644 index 0000000000..ee3027475f --- /dev/null +++ b/value_builder/unimarc_field_700_701_702.pl @@ -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=" + +"; + +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; -- 2.39.2