[Koha-cvs] CVS: koha/value_builder unimarc_field_225a.pl,NONE,1.1 unimarc_field_700_701_702.pl,NONE,1.1 unimarc_field_100.pl,1.2,1.3 unimarc_field_700-4.pl,1.1,1.2

Paul POULAIN tipaul at users.sourceforge.net
Tue Dec 10 14:53:24 CET 2002


Update of /cvsroot/koha/koha/value_builder
In directory sc8-pr-cvs1:/tmp/cvs-serv27735/value_builder

Modified Files:
	unimarc_field_100.pl unimarc_field_700-4.pl 
Added Files:
	unimarc_field_225a.pl unimarc_field_700_701_702.pl 
Log Message:
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.

--- NEW FILE ---
#!/usr/bin/perl

# $Id: unimarc_field_225a.pl,v 1.1 2002/12/10 13:53:22 tipaul Exp $

# 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;

--- NEW FILE ---
#!/usr/bin/perl

# $Id: unimarc_field_700_701_702.pl,v 1.1 2002/12/10 13:53:22 tipaul Exp $

# 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;

Index: unimarc_field_100.pl
===================================================================
RCS file: /cvsroot/koha/koha/value_builder/unimarc_field_100.pl,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** unimarc_field_100.pl	19 Nov 2002 12:45:31 -0000	1.2
--- unimarc_field_100.pl	10 Dec 2002 13:53:22 -0000	1.3
***************
*** 1,5 ****
  #!/usr/bin/perl
  
! # written 10/5/2002 by Paul
  
  # Copyright 2000-2002 Katipo Communications
--- 1,5 ----
  #!/usr/bin/perl
  
! # $Id$
  
  # Copyright 2000-2002 Katipo Communications
***************
*** 28,35 ****
  
  sub plugin_parameters {
! my ($dbh,$record,$tagslib) = @_;
  return "";
  }
  
  sub plugin {
  my ($input) = @_;
--- 28,57 ----
  
  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(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) = @_;
***************
*** 48,52 ****
  	my $f3 = substr($result,9,4);
  	my $f4 = substr($result,13,4);
- 	warn "f2 : $f2";
  	$template->param(index => $index,
  							f1 => $f1,
--- 70,73 ----

Index: unimarc_field_700-4.pl
===================================================================
RCS file: /cvsroot/koha/koha/value_builder/unimarc_field_700-4.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** unimarc_field_700-4.pl	19 Nov 2002 12:45:31 -0000	1.1
--- unimarc_field_700-4.pl	10 Dec 2002 13:53:22 -0000	1.2
***************
*** 27,30 ****
--- 27,46 ----
  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) = @_;
***************
*** 49,52 ****
--- 65,73 ----
  #	my $index2=6;
  	return "&index2=$index2";
+ }
+ 
+ sub plugin_javascript {
+ my ($dbh,$record,$tagslib,$i,$tabloop) = @_;
+ return ("","");
  }
  





More information about the Koha-cvs mailing list