Line 0
Link Here
|
|
|
1 |
#!/usr/bin/perl |
2 |
|
3 |
|
4 |
# Copyright 2010 Frédérick Capovilla - Libéo |
5 |
# |
6 |
# This file is part of Koha. |
7 |
# |
8 |
# Koha is free software; you can redistribute it and/or modify it under the |
9 |
# terms of the GNU General Public License as published by the Free Software |
10 |
# Foundation; either version 2 of the License, or (at your option) any later |
11 |
# version. |
12 |
# |
13 |
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY |
14 |
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
15 |
# A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
16 |
# |
17 |
# You should have received a copy of the GNU General Public License along |
18 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
19 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
20 |
|
21 |
use strict; |
22 |
use warnings; |
23 |
no warnings 'redefine'; # otherwise loading up multiple plugins fills the log with subroutine redefine warnings |
24 |
|
25 |
use C4::Context; |
26 |
|
27 |
=head1 |
28 |
|
29 |
plugin_parameters : other parameters added when the plugin is called by the dopop function |
30 |
|
31 |
=cut |
32 |
|
33 |
sub plugin_parameters { |
34 |
return ""; |
35 |
} |
36 |
|
37 |
=head1 |
38 |
|
39 |
plugin_javascript : the javascript function called when the user enters the subfield. |
40 |
contain 3 javascript functions : |
41 |
* one called when the field is entered (OnFocus). Named FocusXXX |
42 |
* one called when the field is leaved (onBlur). Named BlurXXX |
43 |
* one called when the ... link is clicked (<a href="javascript:function">) named ClicXXX |
44 |
|
45 |
returns : |
46 |
* XXX |
47 |
* a variable containing the 3 scripts. |
48 |
the 3 scripts are inserted after the <input> in the html code |
49 |
|
50 |
=cut |
51 |
|
52 |
sub plugin_javascript { |
53 |
my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_; |
54 |
my $function_name = $field_number; |
55 |
my @split_field_name = split(/_/, $field_number); |
56 |
my $field_name = $split_field_name[1] . '$' . $split_field_name[3]; |
57 |
|
58 |
my $res = <<END_OF_JS; |
59 |
<script typei="text/javascript"> |
60 |
//<![CDATA[ |
61 |
|
62 |
function isUrl(s) { |
63 |
var regexp = /(ftp|http|https):\\/\\/(\\w+:{0,1}\\w*@)?(\\S+)(:[0-9]+)?(\\/|\\/([\\w#!:.?+=&%@!\\-\\/]))?/; |
64 |
return regexp.test(s); |
65 |
} |
66 |
|
67 |
function Blur$function_name(index) { |
68 |
var fieldValue = document.getElementById("$field_number").value; |
69 |
if(fieldValue != '') { |
70 |
if(!isUrl(fieldValue)) { |
71 |
invalid_url_alert('$field_name'); |
72 |
} |
73 |
} |
74 |
return 0; |
75 |
} |
76 |
|
77 |
function Focus$function_name(subfield_managed) { |
78 |
// Do Nothing |
79 |
} |
80 |
|
81 |
function Clic$function_name(subfield_managed) { |
82 |
// Do Nothing |
83 |
} |
84 |
//]]> |
85 |
</script> |
86 |
END_OF_JS |
87 |
return ($function_name,$res); |
88 |
} |
89 |
|
90 |
=head1 |
91 |
|
92 |
plugin : the true value_builded. The screen that is open in the popup window. |
93 |
|
94 |
=cut |
95 |
|
96 |
sub plugin { |
97 |
return ""; |
98 |
} |
99 |
|
100 |
1; |