Bug 25548: Remove Apache rewrite directives that trigger redirects
[koha.git] / cataloguing / value_builder / marc21_field_008_classifications.pl
blobd864f87459d08ff2b4cb8c8c16a59f01dec14ad7
1 #!/usr/bin/perl
3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
18 use Modern::Perl;
19 use C4::Auth;
20 use CGI qw ( -utf8 );
21 use C4::Context;
23 use C4::Search;
24 use C4::Output;
25 use Koha::Util::FrameworkPlugin qw|date_entered|;
27 use constant FIXLEN_DATA_ELTS => 'baaaaaaa';
29 my $builder = sub {
30 my ( $params ) = @_;
31 my $function_name = $params->{id};
32 my $dateentered = date_entered();
33 my $defaultval = FIXLEN_DATA_ELTS;
34 my $res="
35 <script>
37 function Focus$function_name(event) {
38 if (!document.getElementById(event.data.id).value) {
39 var authtype=document.forms['f'].elements['authtypecode'].value;
40 var fieldval='$dateentered$defaultval';
41 document.getElementById(event.data.id).value=fieldval;
43 return 1;
46 function Click$function_name(event) {
47 var authtype=document.forms['f'].elements['authtypecode'].value;
48 defaultvalue=document.getElementById(event.data.id).value;
49 newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=marc21_field_008_classifications.pl&index=\"+ event.data.id +\"&result=\"+defaultvalue+\"&authtypecode=\"+authtype,\"tag_editor\",'width=1000,height=600,toolbar=false,scrollbars=yes');
52 </script>
55 return $res;
58 my $launcher = sub {
59 my ( $params ) = @_;
60 my $input = $params->{cgi};
61 my $index = $input->param('index');
62 my $result = $input->param('result');
63 my $authtype = $input->param('authtypecode') || '';
65 my $defaultval = FIXLEN_DATA_ELTS;
67 my ($template, $loggedinuser, $cookie) = get_template_and_user({
68 template_name => "cataloguing/value_builder/marc21_field_008_classifications.tt",
69 query => $input,
70 type => "intranet",
71 flagsrequired => { editcatalogue => '*' },
72 debug => 1,
73 });
74 my $dateentered = date_entered();
75 $result = "$dateentered$defaultval" unless $result;
76 my @f;
77 for (0,6..13) {
78 $f[$_]=substr($result,$_,$_==0?6:1);
80 $template->param(index => $index);
82 $f[0] = $dateentered if !$f[0] || $f[0]=~/\s/;
83 $template->param(f1 => $f[0]);
85 for (6..13) {
86 $template->param(
87 "f$_" => $f[$_],
88 "f$_".($f[$_] eq '|'? 'pipe': $f[$_]) => $f[$_],
91 output_html_with_http_headers $input, $cookie, $template->output;
94 return { builder => $builder, launcher => $launcher };