Bugzilla – Attachment 41231 Details for
Bug 8609
Add an URL validation plugin for authority and biblio frameworks
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8609 - Add an URL validation plugin for authority and biblio frameworks
Bug-8609---Add-an-URL-validation-plugin-for-author.patch (text/plain), 8.53 KB, created by
Rémi Mayrand-Provencher
on 2015-07-30 12:42:12 UTC
(
hide
)
Description:
Bug 8609 - Add an URL validation plugin for authority and biblio frameworks
Filename:
MIME Type:
Creator:
Rémi Mayrand-Provencher
Created:
2015-07-30 12:42:12 UTC
Size:
8.53 KB
patch
obsolete
>From c8a8884ffddf40aae1863e29ac447dd5f105594e Mon Sep 17 00:00:00 2001 >From: simith <simith@inlibro.com> >Date: Fri, 29 Aug 2014 09:47:02 -0400 >Subject: [PATCH] Bug 8609 - Add an URL validation plugin for authority and > biblio frameworks > >This patch adds a new validation plugin to validate that a field/subfield contains a valid url. This plugin that can be used in biblio and authority frameworks. > >Changes: > >C4/Installer/PerlDependencies.pm - Regexp::Common::URI dependence added >cataloguing/value_builder/url.pl - new file >koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt - new function called in url.pl >koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt - new function called in url.pl >koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt - new function called in url.pl >koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt - new function called in url.pl > >Testing: > >I) Before applying: > >0) Go to the Cataloging module: menu->More->Cataloging; >1) Click <<New record -> default framework>> bouton; >2) Click tab << 8 >>; >3) Insert a text (for example "test") in the 856->u input field; >4) Click out of the input field; >5) Validate no message; > >II) After Applying: > >i) field/subfield plugin attach > >0) In Koha adminstration, click << MARC bibliographic framework >>; >1) In Default framework, click << MARC structure >>; >2) Search field 856 and click << Subfields >>; >3) Click << u >>; >4) In Other options -> Plugin, choose url.pl > >ii) Insert a text in the 856->u input field > >0) Go to the Cataloging module: menu->More->Cataloging; >1) Click <<New record -> default framework>> bouton; >2) Click tab << 8 >>; >3) Insert a text (for example "test") in the 856->u input field; >4) Click out of the input field; >5) Validate message: ><< The field 856$u must contain a valid URL! >ex : http://www.google.com >> >--- > C4/Installer/PerlDependencies.pm | 5 + > cataloguing/value_builder/url.pl | 102 ++++++++++++++++++++ > .../prog/en/modules/authorities/authorities.tt | 4 + > .../prog/en/modules/cataloguing/addbiblio.tt | 4 + > .../prog/en/modules/cataloguing/additem.tt | 12 +++ > .../prog/en/modules/tools/batchMod-edit.tt | 5 + > 6 files changed, 132 insertions(+) > create mode 100644 cataloguing/value_builder/url.pl > >diff --git a/C4/Installer/PerlDependencies.pm b/C4/Installer/PerlDependencies.pm >index 27554e4..09ca563 100644 >--- a/C4/Installer/PerlDependencies.pm >+++ b/C4/Installer/PerlDependencies.pm >@@ -742,6 +742,11 @@ our $PERL_DEPS = { > 'required' => '1', > 'min_ver' => '1.29', > }, >+ 'Regexp::Common::URI' => { >+ 'usage' => 'URL validation value_builder', >+ 'required' => '0', >+ 'min_ver' => '2010010201', >+ }, > }; > > 1; >diff --git a/cataloguing/value_builder/url.pl b/cataloguing/value_builder/url.pl >new file mode 100644 >index 0000000..5731698 >--- /dev/null >+++ b/cataloguing/value_builder/url.pl >@@ -0,0 +1,102 @@ >+#!/usr/bin/perl >+ >+ >+# Copyright 2010 Frédérick Capovilla - Libéo >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use strict; >+use warnings; >+no warnings 'redefine'; # otherwise loading up multiple plugins fills the log with subroutine redefine warnings >+ >+use C4::Context; >+use Regexp::Common qw( URI ); >+ >+=head1 DESCRIPTION >+ >+plugin_parameters : other parameters added when the plugin is called by the dopop function >+ >+=cut >+ >+sub plugin_parameters { >+ return ""; >+} >+ >+=head1 DESCRIPTION >+ >+plugin_javascript : the javascript function called when the user enters the subfield. >+contain 3 javascript functions : >+* one called when the field is entered (OnFocus). Named FocusXXX >+* one called when the field is leaved (onBlur). Named BlurXXX >+* one called when the ... link is clicked (<a href="javascript:function">) named ClicXXX >+ >+returns : >+* XXX >+* a variable containing the 3 scripts. >+the 3 scripts are inserted after the <input> in the html code >+ >+=cut >+ >+sub plugin_javascript { >+ my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_; >+ my $function_name = $field_number; >+ my @split_field_name = split(/_/, $field_number); >+ my $field_name = $split_field_name[1] . '$' . $split_field_name[3]; >+ my $regex = $RE{URI}; >+ $regex =~ s/\//\\\//g; >+ >+ my $res = <<END_OF_JS; >+<script typei="text/javascript"> >+//<![CDATA[ >+ >+function isUrl(s) { >+ var regexp = /$regex/; >+ return regexp.test(s); >+} >+ >+function Blur$function_name(index) { >+ var fieldValue = document.getElementById("$field_number").value; >+ if(fieldValue != '') { >+ if(!isUrl(fieldValue)) { >+ invalid_url_alert('$field_name'); >+ } >+ } >+ return 0; >+} >+ >+function Focus$function_name(subfield_managed) { >+ // Do Nothing >+} >+ >+function Clic$function_name(subfield_managed) { >+ // Do Nothing >+} >+//]]> >+</script> >+END_OF_JS >+return ($function_name,$res); >+} >+ >+=head1 DESCRIPTION >+ >+plugin : the true value_builded. The screen that is open in the popup window. >+ >+=cut >+ >+sub plugin { >+ return ""; >+} >+ >+1; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt >index d6b3a2e..4a02b57 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt >@@ -150,6 +150,10 @@ function confirmnotdup(redirect){ > $("#confirm_not_duplicate").attr("value","1"); > Check(); > } >+// For the url.pl value_builder validation >+function invalid_url_alert(field_name) { >+ alert(_("The field ") + field_name + _(" must contain a valid URL!\nex : http://www.google.com")); >+} > //]]> > </script> > <link type="text/css" rel="stylesheet" href="[% themelang %]/css/addbiblio.css" /> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt >index 3bc00d5..d5cae47 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt >@@ -367,6 +367,10 @@ function Changefwk(FwkList) { > f.submit(); > } > >+// For the url.pl value_builder validation >+function invalid_url_alert(field_name) { >+ alert(_("The field ") + field_name + _(" must contain a valid URL!\nex : http://www.google.com")); >+} > //]]> > </script> > <link type="text/css" rel="stylesheet" href="[% themelang %]/css/addbiblio.css" /> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >index ab9621b..94ea62b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >@@ -89,6 +89,18 @@ function confirm_deletion(biblionumber,itemnumber) { > $("#row"+itemnumber).attr("class",""); > } > } >+ >+$(document).ready(function() { >+ $("#cataloguing_additem_itemlist tr").hover( >+ function () {$(this).addClass("highlight");}, >+ function () {$(this).removeClass("highlight");} >+ ); >+}); >+ >+// For the url.pl value_builder validation >+function invalid_url_alert(field_name) { >+ alert(_("The field ") + field_name + _(" must contain a valid URL!\nex : http://www.google.com")); >+} > //]]> > </script> > <link type="text/css" rel="stylesheet" href="[% themelang %]/css/addbiblio.css" /> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt >index 38a76ce..a656e46 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt >@@ -33,6 +33,11 @@ $(document).ready(function(){ > }); > > }); >+ >+// For the url.pl value_builder validation >+function invalid_url_alert(field_name) { >+ alert(_("The field ") + field_name + _(" must contain a valid URL!\nex : http://www.google.com")); >+} > //]]> > </script> > <!--[if IE]> >-- >1.7.9.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 8609
:
11511
|
26464
|
31279
|
31282
|
38961
|
41231
|
41232
|
48080
|
48125
|
58205