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 (+102 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;
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use strict;
21
use warnings;
22
no warnings 'redefine'; # otherwise loading up multiple plugins fills the log with subroutine redefine warnings
23
24
use C4::Context;
25
use Regexp::Common qw( URI );
26
27
=head1 DESCRIPTION
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 DESCRIPTION
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
    my $regex = $RE{URI};
58
    $regex =~ s/\//\\\//g;
59
60
    my $res  = <<END_OF_JS;
61
<script typei="text/javascript">
62
//<![CDATA[
63
64
function isUrl(s) {
65
    var regexp = /$regex/;
66
    return regexp.test(s);
67
}
68
69
function Blur$function_name(index) {
70
    var fieldValue = document.getElementById("$field_number").value;
71
    if(fieldValue != '') {
72
        if(!isUrl(fieldValue)) {
73
            invalid_url_alert('$field_name');
74
        }
75
    }
76
    return 0;
77
}
78
79
function Focus$function_name(subfield_managed) {
80
    // Do Nothing
81
}
82
83
function Clic$function_name(subfield_managed) {
84
    // Do Nothing
85
}
86
//]]>
87
</script>
88
END_OF_JS
89
return ($function_name,$res);
90
}
91
92
=head1 DESCRIPTION
93
94
plugin : the true value_builded. The screen that is open in the popup window.
95
96
=cut
97
98
sub plugin {
99
    return "";
100
}
101
102
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