Bugzilla – Attachment 58185 Details for
Bug 16203
Convert item plugins to new style (see bug 10480)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16203: Convert item plugins to new style (see bug 10480)
Bug-16203-Convert-item-plugins-to-new-style-see-bu.patch (text/plain), 24.57 KB, created by
Jonathan Druart
on 2016-12-14 17:43:01 UTC
(
hide
)
Description:
Bug 16203: Convert item plugins to new style (see bug 10480)
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-12-14 17:43:01 UTC
Size:
24.57 KB
patch
obsolete
>From ac411492c616553161a905bafb3ab7057aace948 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Tue, 5 Apr 2016 14:51:43 +0200 >Subject: [PATCH] Bug 16203: Convert item plugins to new style (see bug 10480) > >Converts item plugins to new style (with builder and launcher). >See also bugs 10480 and 13437. > >The following plugins have been adjusted: >barcode_manual.pl >barcode.pl >callnumber-KU.pl >callnumber.pl >cn_browser.pl (Added license statement too) >dateaccessioned.pl >macles.pl >stocknumberam123.pl >stocknumberAV.pl >stocknumber.pl > >Test plan: >Connect the plugin to an item field. >Verify that the plugin still works. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Tested if all plugins compile okay. >Ran most of them thru FrameworkPlugin.t. >Tested them in the item editor. > >Note: the form for macles.pl comes up, further hard to test. > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > cataloguing/value_builder/barcode.pl | 40 ++++++++++----------- > cataloguing/value_builder/barcode_manual.pl | 36 +++++++++---------- > cataloguing/value_builder/callnumber-KU.pl | 32 +++++++++-------- > cataloguing/value_builder/callnumber.pl | 32 +++++++++-------- > cataloguing/value_builder/cn_browser.pl | 50 ++++++++++++++++++--------- > cataloguing/value_builder/dateaccessioned.pl | 36 +++++++++---------- > cataloguing/value_builder/macles.pl | 45 ++++++++++-------------- > cataloguing/value_builder/stocknumber.pl | 36 +++++++++---------- > cataloguing/value_builder/stocknumberAV.pl | 28 +++++++++------ > cataloguing/value_builder/stocknumberam123.pl | 30 +++++++++------- > 10 files changed, 193 insertions(+), 172 deletions(-) > >diff --git a/cataloguing/value_builder/barcode.pl b/cataloguing/value_builder/barcode.pl >index b1b4f61..3bd49f2 100755 >--- a/cataloguing/value_builder/barcode.pl >+++ b/cataloguing/value_builder/barcode.pl >@@ -1,4 +1,7 @@ > #!/usr/bin/perl >+ >+# Converted to new plugin style (Bug 13437) >+ > # Copyright 2000-2002 Katipo Communications > # Parts copyright 2008-2010 Foundations Bible College > # >@@ -17,21 +20,19 @@ > # You should have received a copy of the GNU General Public License > # along with Koha; if not, see <http://www.gnu.org/licenses>. > >-use strict; >-use warnings; >-no warnings 'redefine'; # otherwise loading up multiple plugins fills the log with subroutine redefine warnings >+use Modern::Perl; > > use C4::Context; >-require C4::Barcodes::ValueBuilder; >+use C4::Barcodes::ValueBuilder; > use Koha::DateUtils; > > use Algorithm::CheckDigits; > > my $DEBUG = 0; > >-sub plugin_javascript { >- my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_; >- my $function_name= "barcode".(int(rand(100000))+1); >+my $builder = sub { >+ my ( $params ) = @_; >+ my $function_name = $params->{id}; > my %args; > > # find today's date >@@ -45,13 +46,7 @@ sub plugin_javascript { > warn "Barcode type = $autoBarcodeType" if $DEBUG; > if ((not $autoBarcodeType) or $autoBarcodeType eq 'OFF') { > # don't return a value unless we have the appropriate syspref set >- return ($function_name, >- "<script type=\"text/javascript\"> >- // autoBarcodeType OFF (or not defined) >- function Focus$function_name() { return 0;} >- function Clic$function_name() { return 0;} >- function Blur$function_name() { return 0;} >- </script>"); >+ return q|<script type=\"text/javascript\"></script>|; > } > if ($autoBarcodeType eq 'annual') { > ($nextnum, $scr) = C4::Barcodes::ValueBuilder::annual::get_barcode(\%args); >@@ -65,6 +60,7 @@ sub plugin_javascript { > elsif ($autoBarcodeType eq 'EAN13') { > # not the best, two catalogers could add the same barcode easily this way :/ > my $query = "select max(abs(barcode)) from items"; >+ my $dbh = $params->{dbh}; > my $sth = $dbh->prepare($query); > $sth->execute(); > while (my ($last)= $sth->fetchrow_array) { >@@ -88,23 +84,25 @@ sub plugin_javascript { > $scr or $scr = <<END_OF_JS; > if (\$('#' + id).val() == '' || force) { > \$('#' + id).val('$nextnum'); >-} >+}; > END_OF_JS > > my $js = <<END_OF_JS; > <script type="text/javascript"> > //<![CDATA[ > >-function Focus$function_name(subfield_managed, id, force) { >+function Focus$function_name(id, force) { > $scr >- return 0; > } > >-function Clic$function_name(id) { >- return Focus$function_name('not_relavent', id, 1); >+function Click$function_name(id) { >+ Focus$function_name(id, 1); >+ return false; > } > //]]> > </script> > END_OF_JS >- return ($function_name, $js); >-} >+ return $js; >+}; >+ >+return { builder => $builder }; >diff --git a/cataloguing/value_builder/barcode_manual.pl b/cataloguing/value_builder/barcode_manual.pl >index 6bf5ac4..a035769 100755 >--- a/cataloguing/value_builder/barcode_manual.pl >+++ b/cataloguing/value_builder/barcode_manual.pl >@@ -1,4 +1,7 @@ > #!/usr/bin/perl >+ >+# Converted to new plugin style (Bug 13437) >+ > # Copyright 2000-2002 Katipo Communications > # Parts copyright 2008-2010 Foundations Bible College > # >@@ -17,21 +20,20 @@ > # You should have received a copy of the GNU General Public License > # along with Koha; if not, see <http://www.gnu.org/licenses>. > >-use strict; >-use warnings; >-no warnings 'redefine'; # otherwise loading up multiple plugins fills the log with subroutine redefine warnings >+use Modern::Perl; > > use C4::Context; >-require C4::Barcodes::ValueBuilder; >+use C4::Barcodes::ValueBuilder; > use Koha::DateUtils; > > my $DEBUG = 0; > >-sub plugin_javascript { >- my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_; >- my $function_name= "barcode".(int(rand(100000))+1); >+my $builder = sub { >+ my ( $params ) = @_; >+ my $function_name = $params->{id}; > my %args; > >+ my $dbh = $params->{dbh}; > $args{dbh} = $dbh; > > # find today's date >@@ -45,13 +47,7 @@ sub plugin_javascript { > warn "Barcode type = $autoBarcodeType" if $DEBUG; > if ((not $autoBarcodeType) or $autoBarcodeType eq 'OFF') { > # don't return a value unless we have the appropriate syspref set >- return ($function_name, >- "<script type=\"text/javascript\"> >- // autoBarcodeType OFF (or not defined) >- function Focus$function_name() { return 0;} >- function Clic$function_name() { return 0;} >- function Blur$function_name() { return 0;} >- </script>"); >+ return q|<script type=\"text/javascript\"></script>|; > } > if ($autoBarcodeType eq 'annual') { > ($nextnum, $scr) = C4::Barcodes::ValueBuilder::annual::get_barcode(\%args); >@@ -70,16 +66,18 @@ sub plugin_javascript { > } > END_OF_JS > >- my $js = <<END_OF_JS; >+ my $js = <<END_OF_JS; > <script type="text/javascript"> > //<![CDATA[ > >- function Clic$function_name(id) { >+ function Click$function_name(id) { > $scr >- return 0; >+ return false; > } > //]]> > </script> > END_OF_JS >- return ($function_name, $js); >-} >+ return $js; >+}; >+ >+return { builder => $builder }; >diff --git a/cataloguing/value_builder/callnumber-KU.pl b/cataloguing/value_builder/callnumber-KU.pl >index 8394da0..5cbdd25 100755 >--- a/cataloguing/value_builder/callnumber-KU.pl >+++ b/cataloguing/value_builder/callnumber-KU.pl >@@ -1,5 +1,7 @@ > #!/usr/bin/perl > >+# Converted to new plugin style (Bug 13437) >+ > # Copyright 2012 CatalystIT Ltd > # > # This file is part of Koha. >@@ -17,10 +19,10 @@ > # You should have received a copy of the GNU General Public License > # along with Koha; if not, see <http://www.gnu.org/licenses>. > >-use strict; >-use warnings; >-use C4::Auth; >+use Modern::Perl; > use CGI qw ( -utf8 ); >+ >+use C4::Auth; > use C4::Context; > use C4::Output; > >@@ -40,12 +42,12 @@ CCC QW - returns first unused number CCC QWxx starting with CCC QW01 > > =cut > >-sub plugin_javascript { >- my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_; >+my $builder = sub { >+ my ( $params ) = @_; > my $res=" > <script type='text/javascript'> >- function Clic$field_number() { >- var code = document.getElementById('$field_number'); >+ function Click$params->{id}() { >+ var code = document.getElementById('$params->{id}'); > var url = '../cataloguing/plugin_launcher.pl?plugin_name=callnumber-KU.pl&code=' + code.value; > var req = \$.get(url); > req.done(function(resp){ >@@ -56,13 +58,12 @@ sub plugin_javascript { > } > </script> > "; >+ return $res; >+}; > >- return ($field_number,$res); >-} >- >-my $BASE_CALLNUMBER_RE = qr/^(\w+) (\w+)$/; >-sub plugin { >- my ($input) = @_; >+my $launcher = sub { >+ my ( $params ) = @_; >+ my $input = $params->{cgi}; > my $code = $input->param('code'); > > my ($template, $loggedinuser, $cookie) = get_template_and_user({ >@@ -74,6 +75,7 @@ sub plugin { > debug => 1, > }); > >+ my $BASE_CALLNUMBER_RE = qr/^(\w+) (\w+)$/; > my $ret; > my ($alpha, $num) = ($code =~ $BASE_CALLNUMBER_RE); > if (defined $num) { # otherwise no point >@@ -117,4 +119,6 @@ sub plugin { > return => $ret || $code > ); > output_html_with_http_headers $input, $cookie, $template->output; >-} >+}; >+ >+return { builder => $builder, launcher => $launcher }; >diff --git a/cataloguing/value_builder/callnumber.pl b/cataloguing/value_builder/callnumber.pl >index 9d69f27..aeca228 100755 >--- a/cataloguing/value_builder/callnumber.pl >+++ b/cataloguing/value_builder/callnumber.pl >@@ -1,5 +1,7 @@ > #!/usr/bin/perl > >+# Converted to new plugin style (Bug 13437) >+ > # Copyright 2010 BibLibre SARL > # > # This file is part of Koha. >@@ -17,10 +19,10 @@ > # You should have received a copy of the GNU General Public License > # along with Koha; if not, see <http://www.gnu.org/licenses>. > >-use strict; >-use warnings; >-use C4::Auth; >+use Modern::Perl; > use CGI qw ( -utf8 ); >+ >+use C4::Auth; > use C4::Context; > use C4::Output; > >@@ -37,12 +39,12 @@ In this case, a callnumber has this form : "PREFIX 0009678570". > > =cut > >-sub plugin_javascript { >- my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_; >+my $builder = sub { >+ my ( $params ) = @_; > my $res=" > <script type='text/javascript'> >- function Blur$field_number() { >- var code = document.getElementById('$field_number'); >+ function Blur$params->{id}() { >+ var code = document.getElementById('$params->{id}'); > var url = '../cataloguing/plugin_launcher.pl?plugin_name=callnumber.pl&code=' + code.value; > var req = \$.get(url); > req.done(function(resp){ >@@ -54,12 +56,12 @@ sub plugin_javascript { > > </script> > "; >+ return $res; >+}; > >- return ($field_number,$res); >-} >- >-sub plugin { >- my ($input) = @_; >+my $launcher = sub { >+ my ( $params ) = @_; >+ my $input = $params->{cgi}; > my $code = $input->param('code'); > > my ($template, $loggedinuser, $cookie) = get_template_and_user({ >@@ -82,7 +84,7 @@ sub plugin { > return => $max+1, > ); > } >- # If a prefix is submited, we look for the highest itemcallnumber with this prefix, and return it incremented >+ # If a prefix is submitted, we look for the highest itemcallnumber with this prefix, and return it incremented > } elsif ( $code =~ m/^[A-Z.\-']+$/ ) { > my $sth = $dbh->prepare("SELECT MAX(CAST(SUBSTRING_INDEX(itemcallnumber,' ',-1) AS SIGNED)) FROM items WHERE itemcallnumber LIKE ?"); > $sth->execute($code.' %'); >@@ -104,4 +106,6 @@ sub plugin { > ); > } > output_html_with_http_headers $input, $cookie, $template->output; >-} >+}; >+ >+return { builder => $builder, launcher => $launcher }; >diff --git a/cataloguing/value_builder/cn_browser.pl b/cataloguing/value_builder/cn_browser.pl >index 9599666..51767a9 100755 >--- a/cataloguing/value_builder/cn_browser.pl >+++ b/cataloguing/value_builder/cn_browser.pl >@@ -1,34 +1,52 @@ >-use Modern::Perl; >-no warnings 'redefine'; >+#!/usr/bin/perl >+ >+# Converted to new plugin style (Bug 13437) >+ >+# Copyright 2015 Koha Development Team >+# >+# 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 3 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 Modern::Perl; > use CGI; >+ > use C4::Auth; > use C4::ClassSource; > use C4::Output; > >-sub plugin_javascript { >- my ( $dbh, $record, $tagslib, $field_number, $tabloop ) = @_; >- my $function_name = "328" . ( int( rand(100000) ) + 1 ); >+my $builder = sub { >+ my ( $params ) = @_; >+ my $function_name = $params->{id}; > my $res = " > <script type=\"text/javascript\"> > //<![CDATA[ > >-function Clic$function_name(i) { >- q = document.getElementById('$field_number'); >+function Click$function_name(i) { >+ q = document.getElementById('$params->{id}'); > window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=cn_browser.pl&popup&q=\"+q.value,\"cnbrowser\",\"width=500,height=400,toolbar=false,scrollbars=yes\"); > } > > //]]> > </script> > "; >+ return $res; >+}; > >- return ( $function_name, $res ); >-} >- >-sub plugin { >- my ($input) = @_; >- my $cgi = new CGI; >- my $params = $cgi->Vars; >+my $launcher = sub { >+ my ( $params ) = @_; >+ my $cgi = $params->{cgi}; > my $results_per_page = 30; > my $current_page = $cgi->param('page') || 1; > >@@ -143,6 +161,6 @@ sub plugin { > $template->param( 'popup' => defined( $cgi->param('popup') ) ); > > output_html_with_http_headers $cgi, $cookie, $template->output; >-} >+}; > >-1; >+return { builder => $builder, launcher => $launcher }; >diff --git a/cataloguing/value_builder/dateaccessioned.pl b/cataloguing/value_builder/dateaccessioned.pl >index 5244a1e..5fc1c45 100755 >--- a/cataloguing/value_builder/dateaccessioned.pl >+++ b/cataloguing/value_builder/dateaccessioned.pl >@@ -1,5 +1,7 @@ > #!/usr/bin/perl > >+# Converted to new plugin style (Bug 13437) >+ > # Copyright 2000-2002 Katipo Communications > # > # This file is part of Koha. >@@ -18,12 +20,12 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >+use C4::Biblio qw/GetMarcFromKohaField/; > use Koha::DateUtils; >-no warnings 'redefine'; > >-sub plugin_javascript { >- # my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_; >- my $function_name = "dateaccessioned".(int(rand(100000))+1); >+my $builder = sub { >+ my ( $params ) = @_; >+ my $function_name = $params->{id}; > > my $date = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); > >@@ -35,29 +37,25 @@ sub plugin_javascript { > // > // from: cataloguing/value_builder/dateaccessioned.pl > >-function Focus$function_name(subfield_managed, id, force) { >- //var summary = ""; >- //for (i=0 ; i<document.f.field_value.length ; i++) { >- // summary += i + ": " + document.f.tag[i].value + " " + document.f.subfield[i].value + ": " + document.f.field_value[i].value + "\\n"; >- //} >- //alert("Got focus, subfieldmanaged: " + subfield_managed + "\\n" + summary); >- set_to_today(id); >- return 0; >+function Focus$function_name(event) { >+ set_to_today(event.data.id); > } > >-function Clic$function_name(id) { >- set_to_today(id, 1); >- return 0; >+function Click$function_name(event) { >+ set_to_today(event.data.id); >+ return false; // prevent page scroll > } > >-function set_to_today(id, force) { >+function set_to_today( id ) { > if (! id) { alert(_("Bad id ") + id + _(" sent to set_to_today()")); return 0; } >- if (\$("#" + id).val() == '' || \$("#" + id).val() == '0000-00-00' || force) { >+ if (\$("#" + id).val() == '' || \$("#" + id).val() == '0000-00-00' ) { > \$("#" + id).val("$date"); > } > } > //]]> > </script> > END_OF_JS >- return ($function_name, $res); >-} >+ return $res; >+}; >+ >+return { builder => $builder }; >diff --git a/cataloguing/value_builder/macles.pl b/cataloguing/value_builder/macles.pl >index c37b6a0..bed0c88 100755 >--- a/cataloguing/value_builder/macles.pl >+++ b/cataloguing/value_builder/macles.pl >@@ -1,5 +1,6 @@ > #!/usr/bin/perl > >+# Converted to new plugin style (Bug 13437) > > # Copyright 2000-2002 Katipo Communications > # >@@ -18,44 +19,33 @@ > # You should have received a copy of the GNU General Public License > # along with Koha; if not, see <http://www.gnu.org/licenses>. > >-use strict; >-#use warnings; FIXME - Bug 2505 >+use Modern::Perl; > use CGI qw ( -utf8 ); >+ > use C4::Context; > use C4::Output; > use C4::Auth; > >-# use Data::Dumper; >-use vars qw( $tagslib); >-use vars qw( $authorised_values_sth); >-use vars qw( $is_a_modif ); >-use utf8; >- >-sub plugin_javascript { >-my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_; >-my $function_name= "macles".(int(rand(100000))+1); >-my $res=" >+my $builder = sub { >+ my ( $params ) = @_; >+ my $function_name = $params->{id}; >+ my $res=" > <script type=\"text/javascript\"> > //<![CDATA[ >- >-function Clic$function_name(i) { >- newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=macles.pl&index=\"+i,\"MACLES\",',toolbar=false,scrollbars=yes'); >- >+function Click$function_name(i) { >+ newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=macles.pl&index=\"+i,\"MACLES\",',toolbar=false,scrollbars=yes'); > } > //]]> > </script> > "; >+ return $res; >+}; > >-return ($function_name,$res); >-} >- >-sub plugin { >-my ($input) = @_; >- >-# my $input = new CGI; >+my $launcher = sub { >+ my ( $params ) = @_; >+ my $input = $params->{cgi}; > my $index= $input->param('index'); > >- > my $dbh = C4::Context->dbh; > my $rq=$dbh->prepare("SELECT authorised_value, lib from authorised_values where category=\"MACLES\" order by authorised_value DESC"); > #tabs >@@ -90,7 +80,6 @@ my ($input) = @_; > } else { > unshift @{$numbers{$number}->{$tab->{'authorised_value'}}},$tab->{'lib'}; > } >-# use Data::Dumper;warn "BIGLOOP IN".Dumper(@BIGLOOP); > } > foreach my $num ( sort keys %numbers ) { > my @tmpcolhdr; >@@ -168,7 +157,7 @@ my ($input) = @_; > $BIGLOOPcell{'number'} = $num; > push @BIGLOOP, \%BIGLOOPcell; > } >-# warn "BIGLOOP OUT".Dumper(@BIGLOOP); >+ > my ($template, $loggedinuser, $cookie) > = get_template_and_user({template_name => "cataloguing/value_builder/macles.tt", > query => $input, >@@ -180,4 +169,6 @@ my ($input) = @_; > $template->param(BIGLOOP=>\@BIGLOOP); > $template->param("index"=>$index); > output_html_with_http_headers $input, $cookie, $template->output; >-} >+}; >+ >+return { builder => $builder, launcher => $launcher }; >diff --git a/cataloguing/value_builder/stocknumber.pl b/cataloguing/value_builder/stocknumber.pl >index ae150dd..11e237c 100755 >--- a/cataloguing/value_builder/stocknumber.pl >+++ b/cataloguing/value_builder/stocknumber.pl >@@ -1,5 +1,7 @@ > #!/usr/bin/perl > >+# Converted to new plugin style (Bug 13437) >+ > # Copyright 2000-2002 Katipo Communications > # > # This file is part of Koha. >@@ -17,13 +19,13 @@ > # You should have received a copy of the GNU General Public License > # along with Koha; if not, see <http://www.gnu.org/licenses>. > >-use strict; >-use warnings; >+use Modern::Perl; > use C4::Context; > >-sub plugin_javascript { >- my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_; >- my $function_name= "inventory".(int(rand(100000))+1); >+my $builder = sub { >+ my ( $params ) = @_; >+ my $function_name = $params->{id}; >+ my $dbh = $params->{dbh}; > > my $branchcode = C4::Context->userenv->{'branch'}; > >@@ -34,26 +36,24 @@ sub plugin_javascript { > my ($nextnum) = $sth->fetchrow; > $nextnum = $branchcode.'_'.$nextnum; > >- my $scr = <<END_OF_JS; >-if (\$('#' + id).val() == '' || force) { >- \$('#' + id).val('$nextnum'); >-} >-END_OF_JS >- > my $js = <<END_OF_JS; > <script type="text/javascript"> > //<![CDATA[ > >-function Focus$function_name(subfield_managed, id, force) { >-$scr >- return 0; >+function Focus$function_name(id, force) { >+ if (\$('#' + id).val() == '' || force) { >+ \$('#' + id).val('$nextnum'); >+ } > } > >-function Clic$function_name(id) { >- return Focus$function_name('not_relavent', id, 1); >+function Click$function_name(event) { >+ Focus$function_name(event.data.id, 1); >+ return false; > } > //]]> > </script> > END_OF_JS >- return ($function_name, $js); >-} >+ return $js; >+}; >+ >+return { builder => $builder }; >diff --git a/cataloguing/value_builder/stocknumberAV.pl b/cataloguing/value_builder/stocknumberAV.pl >index 8860060..789a055 100755 >--- a/cataloguing/value_builder/stocknumberAV.pl >+++ b/cataloguing/value_builder/stocknumberAV.pl >@@ -1,5 +1,7 @@ > #!/usr/bin/perl > >+# Converted to new plugin style (Bug 13437) >+ > # Copyright 2012 BibLibre SARL > # > # This file is part of Koha. >@@ -18,8 +20,9 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use C4::Auth; > use CGI qw ( -utf8 ); >+ >+use C4::Auth; > use C4::Context; > use C4::Output; > >@@ -37,12 +40,12 @@ In this case, a stocknumber has this form : "PREFIX 0009678570". > > =cut > >-sub plugin_javascript { >- my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_; >+my $builder = sub { >+ my ( $params ) = @_; > my $res = qq{ > <script type='text/javascript'> >- function Clic$field_number() { >- var code = document.getElementById('$field_number'); >+ function Click$params->{id}() { >+ var code = document.getElementById('$params->{id}'); > \$.ajax({ > url: '/cgi-bin/koha/cataloguing/plugin_launcher.pl', > type: 'POST', >@@ -51,7 +54,7 @@ sub plugin_javascript { > 'code' : code.value, > }, > success: function(data){ >- var field = document.getElementById('$field_number'); >+ var field = document.getElementById('$params->{id}'); > field.value = data; > return 1; > } >@@ -60,11 +63,12 @@ sub plugin_javascript { > </script> > }; > >- return ($field_number,$res); >-} >+ return $res; >+}; > >-sub plugin { >- my ($input) = @_; >+my $launcher = sub { >+ my ( $params ) = @_; >+ my $input = $params->{cgi}; > my $code = $input->param('code'); > > my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >@@ -98,4 +102,6 @@ sub plugin { > } > > output_html_with_http_headers $input, $cookie, $template->output; >-} >+}; >+ >+return { builder => $builder, launcher => $launcher }; >diff --git a/cataloguing/value_builder/stocknumberam123.pl b/cataloguing/value_builder/stocknumberam123.pl >index 6290be6..17d64ac 100755 >--- a/cataloguing/value_builder/stocknumberam123.pl >+++ b/cataloguing/value_builder/stocknumberam123.pl >@@ -1,5 +1,7 @@ > #!/usr/bin/perl > >+# Converted to new plugin style (Bug 13437) >+ > # Copyright 2010 BibLibre SARL > # > # This file is part of Koha. >@@ -17,10 +19,10 @@ > # You should have received a copy of the GNU General Public License > # along with Koha; if not, see <http://www.gnu.org/licenses>. > >-use strict; >-use warnings; >-use C4::Auth; >+use Modern::Perl; > use CGI qw ( -utf8 ); >+ >+use C4::Auth; > use C4::Context; > use C4::Output; > >@@ -38,12 +40,12 @@ In this case, a stocknumber has this form : "PREFIX 0009678570". > > =cut > >-sub plugin_javascript { >- my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_; >+my $builder = sub { >+ my ( $params ) = @_; > my $res=" > <script type='text/javascript'> >- function Blur$field_number() { >- var code = document.getElementById('$field_number'); >+ function Blur$params->{id}() { >+ var code = document.getElementById('$params->{id}'); > var url = '../cataloguing/plugin_launcher.pl?plugin_name=stocknumberam123.pl&code=' + code.value; > var req = \$.get(url); > req.done(function(resp){ >@@ -52,15 +54,15 @@ sub plugin_javascript { > }); > return 1; > } >- > </script> > "; > >- return ($field_number,$res); >-} >+ return $res; >+}; > >-sub plugin { >- my ($input) = @_; >+my $launcher = sub { >+ my ( $params ) = @_; >+ my $input = $params->{cgi}; > my $code = $input->param('code'); > > my ($template, $loggedinuser, $cookie) = get_template_and_user({ >@@ -100,4 +102,6 @@ sub plugin { > ); > } > output_html_with_http_headers $input, $cookie, $template->output; >-} >+}; >+ >+return { builder => $builder, launcher => $launcher }; >-- >2.1.4
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 16203
:
49913
|
50066
|
57956
| 58185