5 # Copyright 2000-2002 Katipo Communications
7 # This file is part of Koha.
9 # Koha is free software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License as published by the Free Software
11 # Foundation; either version 2 of the License, or (at your option) any later
14 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License along with
19 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
20 # Suite 330, Boston, MA 02111-1307 USA
32 plugin_parameters : other parameters added when the plugin is called by the dopop function
35 sub plugin_parameters {
36 my ($dbh,$record,$tagslib,$i,$tabloop) = @_;
42 plugin_javascript : the javascript function called when the user enters the subfield.
43 contain 3 javascript functions :
44 * one called when the field is entered (OnFocus). Named FocusXXX
45 * one called when the field is leaved (onBlur). Named BlurXXX
46 * one called when the ... link is clicked (<a href="javascript:function">) named ClicXXX
50 * a variable containing the 3 scripts.
51 the 3 scripts are inserted after the <input> in the html code
54 sub plugin_javascript {
55 my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_;
56 my $function_name= "210c".(int(rand(100000))+1);
57 #---- build editors list.
58 #---- the editor list is built from the "EDITORS" thesaurus
59 #---- this thesaurus category must be filled as follow :
61 #---- 200$b for editor
62 #---- 200$c (repeated) for collections
63 my $sth = $dbh->prepare("select auth_subfield_table.authid,subfieldvalue from auth_subfield_table
64 left join auth_header on auth_subfield_table.authid=auth_header.authid
65 where authtypecode='EDITORS' and tag='200' and subfieldcode='a'");
66 my $sth2 = $dbh->prepare("select subfieldvalue from auth_subfield_table where tag='200' and subfieldcode='b' and authid=?");
69 my $authoritysep = C4::Context->preference("authoritysep");
70 while (my ($authid,$isbn) = $sth->fetchrow) {
71 $sth2->execute($authid);
72 my ($editor) = $sth2->fetchrow;
73 push(@editors,"$isbn $authoritysep $editor");
77 function Focus$function_name(index) {
79 foreach my $editor (@editors) {
80 my @arr = split (/ $authoritysep /,$editor);
81 $res .='["'.$arr[0].'","'.$arr[1].'","'.$arr[2].'"],';
86 // search isbn subfield. it''s 010a
88 for (i=0 ; i<document.f.field_value.length ; i++) {
89 if (document.f.tag[i].value == '010' && document.f.subfield[i].value == 'a') {
90 isbn_found=document.f.field_value[i].value;
93 for (i=0;i<=isbn_array.length;i++) {
94 if (isbn_found.substr(0,isbn_array[i][0].length) == isbn_array[i][0]) {
95 document.f.field_value[index].value =isbn_array[i][1];
100 function Blur$function_name(subfield_managed) {
104 function Clic$function_name(subfield_managed) {
105 defaultvalue=escape(document.forms[0].field_value[subfield_managed].value);
106 newin=window.open(\"../authorities/authorities-home.pl\",\"value builder\",'width=500,height=400,toolbar=false,scrollbars=yes');
111 return ($function_name,$res);
116 plugin : the true value_builded. The screen that is open in the popup window.
122 my $index = $input->param("index");
123 my $result = $input->param("result");
124 $result=~s/ / /g;
125 $result=~s/"/"/g;
126 print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=thesaurus_popup.pl?category=EDITORS&nohierarchy=1&index=$index&result=$result\"></html>";