From a7356b1cbc8b3b427a49548f45e25f4a95d569c2 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Tue, 5 Apr 2016 14:51:43 +0200 Subject: [PATCH] Bug 16203: item plugins (W-I-P) Content-Type: text/plain; charset=utf-8 -rwxr-xr-x 1 master-koha master-koha 3082 Nov 19 10:04 barcode_manual.pl -rwxr-xr-x 1 master-koha master-koha 3896 Nov 19 10:04 barcode.pl -rwxr-xr-x 1 master-koha master-koha 4292 Nov 19 10:04 callnumber-KU.pl -rwxr-xr-x 1 master-koha master-koha 3406 Nov 19 10:04 callnumber.pl -rwxr-xr-x 1 master-koha master-koha 4424 Nov 19 10:04 cn_browser.pl -rwxr-xr-x 1 master-koha master-koha 2058 Nov 19 10:04 dateaccessioned.pl -rwxr-xr-x 1 master-koha master-koha 6777 Jan 4 10:34 macles.pl -rwxr-xr-x 1 master-koha master-koha 3409 Nov 19 10:04 stocknumberam123.pl -rwxr-xr-x 1 master-koha master-koha 3525 Nov 19 10:04 stocknumberAV.pl -rwxr-xr-x 1 master-koha master-koha 1646 Nov 19 10:04 stocknumber.pl Added license statement to cn_browser.pl. --- cataloguing/value_builder/barcode.pl | 36 +++++++++---------- cataloguing/value_builder/barcode_manual.pl | 34 +++++++++--------- 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 +++++++++---------- 6 files changed, 120 insertions(+), 100 deletions(-) diff --git a/cataloguing/value_builder/barcode.pl b/cataloguing/value_builder/barcode.pl index b1b4f61..36b17e3 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 . -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, - ""); + return q||; } 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,7 +84,7 @@ sub plugin_javascript { $scr or $scr = < 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..aa1b627 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 . -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, - ""); + return q||; } 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 - 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 . -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=" "; + 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 . -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=" "; + 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 = " "; + 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 . 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 END_OF_JS - return ($function_name, $res); -} + return $res; +}; + +return { builder => $builder }; -- 1.7.10.4