Bugzilla – Attachment 11511 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]
Add an URL validation plugin for authority and biblio frameworks.
0001-Add-an-URL-validation-plugin-for-authority-and-bibli.patch (text/plain), 6.56 KB, created by
Frédérick Capovilla
on 2012-08-09 17:14:38 UTC
(
hide
)
Description:
Add an URL validation plugin for authority and biblio frameworks.
Filename:
MIME Type:
Creator:
Frédérick Capovilla
Created:
2012-08-09 17:14:38 UTC
Size:
6.56 KB
patch
obsolete
>From 27314e90f75448ce542af427a9afd4a94a20e154 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Fr=C3=A9d=C3=A9rick?= <frederick.capovilla@libeo.com> >Date: Thu, 9 Aug 2012 13:05:01 -0400 >Subject: [PATCH] Add an URL validation plugin for authority and biblio frameworks. > >--- > cataloguing/value_builder/url.pl | 100 ++++++++++++++++++++ > .../prog/en/modules/authorities/authorities.tt | 5 + > .../prog/en/modules/cataloguing/addbiblio.tt | 6 + > .../prog/en/modules/cataloguing/additem.tt | 5 + > .../prog/en/modules/tools/batchMod-edit.tt | 5 + > 5 files changed, 121 insertions(+), 0 deletions(-) > create mode 100644 cataloguing/value_builder/url.pl > >diff --git a/cataloguing/value_builder/url.pl b/cataloguing/value_builder/url.pl >new file mode 100644 >index 0000000..70d455a >--- /dev/null >+++ b/cataloguing/value_builder/url.pl >@@ -0,0 +1,100 @@ >+#!/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; either version 2 of the License, or (at your option) any later >+# version. >+# >+# 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; >+ >+=head1 >+ >+plugin_parameters : other parameters added when the plugin is called by the dopop function >+ >+=cut >+ >+sub plugin_parameters { >+ return ""; >+} >+ >+=head1 >+ >+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 $res = <<END_OF_JS; >+<script typei="text/javascript"> >+//<![CDATA[ >+ >+function isUrl(s) { >+ var regexp = /(ftp|http|https):\\/\\/(\\w+:{0,1}\\w*@)?(\\S+)(:[0-9]+)?(\\/|\\/([\\w#!:.?+=&%@!\\-\\/]))?/; >+ 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 >+ >+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 352d518..a1ef402 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt >@@ -501,6 +501,11 @@ function searchauthority() { > Y = document.forms[0].value.value; > window.location="/cgi-bin/koha/authorities/authorities-home.pl?op=do_search&type=intranet&authtypecode="+X+"&value="+Y+"&marclist=&and_or=and&excluding=&operator=contains"; > } >+ >+// 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 f934fbe..a1ee258 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt >@@ -635,6 +635,12 @@ function unHideSubfield(index,labelindex) { // FIXME :: is it used ? > label = document.getElementById(labelindex); > label.style.display='none'; > } >+ >+// 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 6692274..5fc9e1d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >@@ -162,6 +162,11 @@ $(document).ready(function() { > function () {$(this).attr("class","" );} > ); > }); >+ >+// 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 4c7198e..27a6417 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 >@@ -35,6 +35,11 @@ $("input[name='disable_input']").click(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> > <script type="text/javascript" src="[% themelang %]/js/pages/batchMod.js"></script> >-- >1.7.2.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