View | Details | Raw Unified | Return to bug 8609
Collapse All | Expand All

(-)a/C4/Installer/PerlDependencies.pm (+5 lines)
Lines 742-747 our $PERL_DEPS = { Link Here
742
        'required' => '0',
742
        'required' => '0',
743
        'min_ver'  => '5.836',
743
        'min_ver'  => '5.836',
744
    },
744
    },
745
    'Regexp::Common::URI' => {
746
        'usage'    => 'URL validation value_builder',
747
        'required' => '0',
748
        'min_ver'  => '2010010201',
749
    },
745
};
750
};
746
751
747
1;
752
1;
(-)a/cataloguing/value_builder/url.pl (+103 lines)
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
use Regexp::Common qw( URI );
27
28
=head1
29
30
plugin_parameters : other parameters added when the plugin is called by the dopop function
31
32
=cut
33
34
sub plugin_parameters {
35
    return "";
36
}
37
38
=head1
39
40
plugin_javascript : the javascript function called when the user enters the subfield.
41
contain 3 javascript functions :
42
* one called when the field is entered (OnFocus). Named FocusXXX
43
* one called when the field is leaved (onBlur). Named BlurXXX
44
* one called when the ... link is clicked (<a href="javascript:function">) named ClicXXX
45
46
returns :
47
* XXX
48
* a variable containing the 3 scripts.
49
the 3 scripts are inserted after the <input> in the html code
50
51
=cut
52
53
sub plugin_javascript {
54
    my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_;
55
    my $function_name = $field_number;
56
    my @split_field_name = split(/_/, $field_number);
57
    my $field_name = $split_field_name[1] . '$' . $split_field_name[3];
58
    my $regex = $RE{URI};
59
    $regex =~ s/\//\\\//g;
60
61
    my $res  = <<END_OF_JS;
62
<script typei="text/javascript">
63
//<![CDATA[
64
65
function isUrl(s) {
66
    var regexp = /$regex/;
67
    return regexp.test(s);
68
}
69
70
function Blur$function_name(index) {
71
    var fieldValue = document.getElementById("$field_number").value;
72
    if(fieldValue != '') {
73
        if(!isUrl(fieldValue)) {
74
            invalid_url_alert('$field_name');
75
        }
76
    }
77
    return 0;
78
}
79
80
function Focus$function_name(subfield_managed) {
81
    // Do Nothing
82
}
83
84
function Clic$function_name(subfield_managed) {
85
    // Do Nothing
86
}
87
//]]>
88
</script>
89
END_OF_JS
90
return ($function_name,$res);
91
}
92
93
=head1
94
95
plugin : the true value_builded. The screen that is open in the popup window.
96
97
=cut
98
99
sub plugin {
100
    return "";
101
}
102
103
1;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt (+4 lines)
Lines 122-127 function confirmnotdup(redirect){ Link Here
122
    $("#confirm_not_duplicate").attr("value","1");
122
    $("#confirm_not_duplicate").attr("value","1");
123
    Check();
123
    Check();
124
}
124
}
125
// For the url.pl value_builder validation
126
function invalid_url_alert(field_name) {
127
    alert(_("The field ") + field_name + _(" must contain a valid URL!\nex : http://www.google.com"));
128
}
125
//]]>
129
//]]>
126
</script>
130
</script>
127
<link type="text/css" rel="stylesheet" href="[% themelang %]/css/addbiblio.css" />
131
<link type="text/css" rel="stylesheet" href="[% themelang %]/css/addbiblio.css" />
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt (+4 lines)
Lines 362-367 function Changefwk(FwkList) { Link Here
362
    f.submit();
362
    f.submit();
363
}
363
}
364
364
365
// For the url.pl value_builder validation
366
function invalid_url_alert(field_name) {
367
    alert(_("The field ") + field_name + _(" must contain a valid URL!\nex : http://www.google.com"));
368
}
365
//]]>
369
//]]>
366
</script>
370
</script>
367
<link type="text/css" rel="stylesheet" href="[% themelang %]/css/addbiblio.css" />
371
<link type="text/css" rel="stylesheet" href="[% themelang %]/css/addbiblio.css" />
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt (+5 lines)
Lines 99-104 $(document).ready(function() { Link Here
99
        function () {$(this).removeClass("highlight");}
99
        function () {$(this).removeClass("highlight");}
100
    );
100
    );
101
});
101
});
102
103
// For the url.pl value_builder validation
104
function invalid_url_alert(field_name) {
105
    alert(_("The field ") + field_name + _(" must contain a valid URL!\nex : http://www.google.com"));
106
}
102
//]]>
107
//]]>
103
</script>
108
</script>
104
<link type="text/css" rel="stylesheet" href="[% themelang %]/css/addbiblio.css" />
109
<link type="text/css" rel="stylesheet" href="[% themelang %]/css/addbiblio.css" />
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt (-1 / +5 lines)
Lines 33-38 $(document).ready(function(){ Link Here
33
  });
33
  });
34
34
35
});
35
});
36
37
// For the url.pl value_builder validation
38
function invalid_url_alert(field_name) {
39
    alert(_("The field ") + field_name + _(" must contain a valid URL!\nex : http://www.google.com"));
40
}
36
//]]>
41
//]]>
37
</script>
42
</script>
38
<!--[if IE]>
43
<!--[if IE]>
39
- 

Return to bug 8609