Lines 1-74
Link Here
|
1 |
#!/usr/bin/perl |
|
|
2 |
|
3 |
# Copyright 2014 Rijksmuseum |
4 |
# |
5 |
# This file is part of Koha. |
6 |
# |
7 |
# Koha is free software; you can redistribute it and/or modify it |
8 |
# under the terms of the GNU General Public License as published by |
9 |
# the Free Software Foundation; either version 3 of the License, or |
10 |
# (at your option) any later version. |
11 |
# |
12 |
# Koha is distributed in the hope that it will be useful, but |
13 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
# GNU General Public License for more details. |
16 |
# |
17 |
# You should have received a copy of the GNU General Public License |
18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
19 |
|
20 |
use Modern::Perl; |
21 |
|
22 |
use Date::Calc; |
23 |
|
24 |
use Koha::Util::FrameworkPlugin qw(wrapper); |
25 |
use C4::Auth qw( get_template_and_user ); |
26 |
use CGI qw ( -utf8 ); |
27 |
use C4::Context; |
28 |
use C4::Output qw( output_html_with_http_headers ); |
29 |
|
30 |
my $builder= sub { |
31 |
my $params = shift; |
32 |
my $id = $params->{id}; |
33 |
|
34 |
return qq| |
35 |
<script> |
36 |
|
37 |
function Click$id(event) { |
38 |
var fieldvalue=\$('#'+event.data.id).val(); |
39 |
window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=unimarc_field_182a.pl&index=\"+event.data.id+\"&result=\"+fieldvalue,\"tag_editor\",'width=700,height=700,toolbar=false,scrollbars=yes'); |
40 |
return false; /* prevents scrolling */ |
41 |
} |
42 |
</script>|; |
43 |
}; |
44 |
|
45 |
my $launcher= sub { |
46 |
my $params = shift; |
47 |
my $cgi = $params->{cgi}; |
48 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user({ |
49 |
template_name => "cataloguing/value_builder/unimarc_field_182a.tt", |
50 |
query => $cgi, |
51 |
type => "intranet", |
52 |
flagsrequired => {editcatalogue => '*'}, |
53 |
}); |
54 |
my $results = scalar $cgi->param('result'); |
55 |
|
56 |
$template->param( |
57 |
index => scalar $cgi->param('index'), |
58 |
result => $results, |
59 |
); |
60 |
|
61 |
# Return the result of the position in the string, ex: abcde = 1=a, 2=b, 3=c... |
62 |
my @x = split(//, $results); |
63 |
my $i = 1; |
64 |
for my $fresult (@x) { |
65 |
$template->param("f$i" => $fresult); |
66 |
++$i; |
67 |
} |
68 |
output_html_with_http_headers $cgi, $cookie, $template->output; |
69 |
}; |
70 |
|
71 |
# Return the hashref with the builder and launcher to FrameworkPlugin object. |
72 |
# NOTE: If you do not need a popup but only use e.g. Focus, Blur etc. for a |
73 |
# particular plugin, you only need to define and return the builder. |
74 |
return { builder => $builder, launcher => $launcher }; |