4 # Copyright 2000-2002 Katipo Communications
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
13 # Koha is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with Koha; if not, see <http://www.gnu.org/licenses>.
24 use C4
::AuthoritiesMarc
;
33 ###TODO To rewrite in order to use SearchAuthorities
37 =head2 plugin_parameters
39 Other parameters added when the plugin is called by the dopop function
43 sub plugin_parameters
{
44 my ($dbh,$record,$tagslib,$i,$tabloop) = @_;
48 =head2 plugin_javascript
50 The javascript function called when the user enters the subfield.
51 contain 3 javascript functions :
52 * one called when the field is entered (OnFocus). Named FocusXXX
53 * one called when the field is leaved (onBlur). Named BlurXXX
54 * one called when the ... link is clicked (<a href="javascript:function">) named ClicXXX
58 * a variable containing the 3 scripts.
59 the 3 scripts are inserted after the <input> in the html code
63 sub plugin_javascript
{
64 my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_;
65 my $function_name= $field_number;
66 #---- build editors list.
67 #---- the editor list is built from the "EDITORS" thesaurus
68 #---- this thesaurus category must be filled as follow :
70 #---- 200$b for editor
71 #---- 200$c (repeated) for collections
75 <script type=\"text/javascript\">
76 function Focus$function_name(index) {
80 function Blur$function_name(subfield_managed) {
84 function Clic$function_name(subfield_managed) {
85 defaultvalue=escape(document.getElementById(\"$field_number\").value);
86 newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=unimarc_field_210c.pl&index=\"+subfield_managed,\"unimarc_225a\",'width=500,height=600,toolbar=false,scrollbars=yes');
90 return ($function_name,$res);
95 The true value_builded. The screen that is open in the popup window.
102 my $op = $query->param('op');
103 my $authtypecode = $query->param('authtypecode');
104 my $index = $query->param('index');
105 my $category = $query->param('category');
106 my $resultstring = $query->param('result');
107 my $dbh = C4
::Context
->dbh;
109 my $startfrom=$query->param('startfrom');
110 $startfrom=0 if(!defined $startfrom);
111 my ($template, $loggedinuser, $cookie);
114 my $authtypes = getauthtypes
;
116 foreach my $thisauthtype (keys %$authtypes) {
118 if ($thisauthtype eq $authtypecode) {
121 my %row =(value
=> $thisauthtype,
122 selected
=> $selected,
123 authtypetext
=> $authtypes->{$thisauthtype}{'authtypetext'},
126 push @authtypesloop, \
%row;
129 if ($op eq "do_search") {
130 my @marclist = $query->param('marclist');
131 my @and_or = $query->param('and_or');
132 my @excluding = $query->param('excluding');
133 my @operator = $query->param('operator');
134 my @value = $query->param('value');
135 my $orderby = $query->param('orderby');
137 $resultsperpage= $query->param('resultsperpage');
138 $resultsperpage = 19 if(!defined $resultsperpage);
140 # builds tag and subfield arrays
143 my ($results,$total) = SearchAuthorities
( \
@tags,\
@and_or,
144 \
@excluding, \
@operator, \
@value,
145 $startfrom*$resultsperpage, $resultsperpage,$authtypecode, $orderby);
147 # Getting the $b if it exists
149 my $authority = GetAuthority
($_->{authid
});
150 if ($authority->field('200') and $authority->subfield('200','b')) {
151 $_->{to_report
} = $authority->subfield('200','b');
155 ($template, $loggedinuser, $cookie)
156 = get_template_and_user
({template_name
=> "cataloguing/value_builder/unimarc_field_210c.tt",
159 authnotrequired
=> 0,
160 flagsrequired
=> {editcatalogue
=> '*'},
164 # multi page display gestion
166 my $displayprev=$startfrom;
167 if(($total - (($startfrom+1)*($resultsperpage))) > 0 ) {
173 if ($total>$resultsperpage) {
174 for (my $i=1; $i<$total/$resultsperpage+1; $i++) {
177 ($startfrom==($i-1)) && ($highlight=1);
178 push @numbers, { number
=> $i,
179 highlight
=> $highlight ,
180 startfrom
=> ($i-1)};
185 my $from = $startfrom*$resultsperpage+1;
188 if($total < (($startfrom+1)*$resultsperpage)) {
191 $to = (($startfrom+1)*$resultsperpage);
193 my $link="../cataloguing/plugin_launcher.pl?plugin_name=unimarc_field_210c.pl&authtypecode=EDITORS&".join("&",map {"value=".$_} @value)."&op=do_search&type=intranet&index=$index";
195 $template->param(result
=> $results) if $results;
196 $template->param('index' => $query->param('index'));
197 $template->param(startfrom
=> $startfrom,
198 displaynext
=> $displaynext,
199 displayprev
=> $displayprev,
200 resultsperpage
=> $resultsperpage,
201 startfromnext
=> $startfrom+1,
202 startfromprev
=> $startfrom-1,
207 authtypecode
=>$authtypecode,
208 resultstring
=>$value[0],
209 pagination_bar
=> pagination_bar
(
211 getnbpages
($total, $resultsperpage),
217 ($template, $loggedinuser, $cookie)
218 = get_template_and_user
({template_name
=> "cataloguing/value_builder/unimarc_field_210c.tt",
221 authnotrequired
=> 0,
222 flagsrequired
=> {editcatalogue
=> '*'},
226 $template->param(index => $index,
227 resultstring
=> $resultstring
231 $template->param(authtypesloop
=> \
@authtypesloop);
232 $template->param(category
=> $category);
235 output_html_with_http_headers
$query, $cookie, $template->output;