Bug 19987: If no z39.50/SRU servers the button should not show
[koha.git] / cataloguing / value_builder / upload.pl
1 #!/usr/bin/perl
2
3 # Converted to new plugin style (Bug 6874/See also 13437)
4
5 # This file is part of Koha.
6 #
7 # Copyright (C) 2015 Rijksmuseum
8 # Copyright (C) 2011-2012 BibLibre
9 #
10 # Koha is free software; you can redistribute it and/or modify it
11 # under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 3 of the License, or
13 # (at your option) any later version.
14 #
15 # Koha is distributed in the hope that it will be useful, but
16 # WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22
23 use Modern::Perl;
24
25 # This plugin does not use the plugin launcher. It refers to tools/upload.pl.
26 # That script and template support using it as a plugin.
27
28 # If the plugin is called with the pattern [id=some_hashvalue] in the
29 # corresponding field, it starts the upload script as a search, providing
30 # the possibility to delete the uploaded file. If the field is empty, you
31 # can upload a new file.
32
33 my $builder = sub {
34     my ( $params ) = @_;
35     return <<"SCRIPT";
36 <script type=\"text/javascript\">
37         function Click$params->{id}(event) {
38             var index = event.data.id;
39             var str = document.getElementById(index).value;
40             var myurl, term;
41             if( str && str.match(/id=([0-9a-f]+)/) ) {
42                 term = RegExp.\$1;
43                 myurl = '../tools/upload.pl?op=search&index='+index+'&term='+term+'&plugin=1';
44             } else {
45                 myurl = '../tools/upload.pl?op=new&index='+index+'&plugin=1';
46             }
47             window.open( myurl, 'tag_editor', 'width=800,height=400,toolbar=false,scrollbars=yes' );
48         }
49 </script>
50 SCRIPT
51 };
52
53 return { builder => $builder };