From 451c89cc7dbb34dd42c2713ebbb9a96f02dacecb Mon Sep 17 00:00:00 2001 From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Date: Tue, 12 May 2015 17:49:04 +0200 Subject: [PATCH] Bug 13437: Preliminary changes for marc21 plugins field 008 Content-Type: text/plain; charset=utf-8 Preliminary work on marc21_field_008.pl and 008_authorities.pl. Moving $dateentered en $defaultval to lower scope level. Test plan: Use both plugins in the marc21 editor (biblios/authorities). --- cataloguing/value_builder/marc21_field_008.pl | 15 +++++++++------ .../value_builder/marc21_field_008_authorities.pl | 19 ++++++++++++------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/cataloguing/value_builder/marc21_field_008.pl b/cataloguing/value_builder/marc21_field_008.pl index cc2d28d..e3de19c 100755 --- a/cataloguing/value_builder/marc21_field_008.pl +++ b/cataloguing/value_builder/marc21_field_008.pl @@ -34,12 +34,13 @@ plugin_parameters : other parameters added when the plugin is called by the dopo =cut -# find today's date -my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time); - -$year += 1900; -$mon += 1; -my $dateentered = substr($year, 2, 2) . sprintf("%0.2d", $mon) . sprintf("%0.2d", $mday); +sub date_entered { + # find today's date + my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time); + $year += 1900; + $mon += 1; + return substr($year, 2, 2) . sprintf("%0.2d", $mon) . sprintf("%0.2d", $mday); +} sub plugin_javascript { my $lang = C4::Context->preference('DefaultLanguageField008' ); @@ -48,6 +49,7 @@ sub plugin_javascript { my ($dbh, $record, $tagslib, $field_number, $tabloop) = @_; my $function_name = $field_number; + my $dateentered = date_entered(); my $res = " <script type=\"text/javascript\"> //<![CDATA[ @@ -149,6 +151,7 @@ sub plugin { } ); + my $dateentered = date_entered(); $result = "$dateentered" . "b xxu||||| |||| 00| 0 $lang d" unless $result; my $errorXml = ''; # Check if the xml, xsd exists and is validated diff --git a/cataloguing/value_builder/marc21_field_008_authorities.pl b/cataloguing/value_builder/marc21_field_008_authorities.pl index be15ced..319972d 100755 --- a/cataloguing/value_builder/marc21_field_008_authorities.pl +++ b/cataloguing/value_builder/marc21_field_008_authorities.pl @@ -1,6 +1,5 @@ #!/usr/bin/perl - # Copyright 2000-2002 Katipo Communications # # This file is part of Koha. @@ -36,16 +35,19 @@ plugin_parameters : other parameters added when the plugin is called by the dopo =cut -# find today's date -my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); - -$year +=1900; $mon +=1; -my $dateentered = substr($year,2,2).sprintf ("%0.2d", $mon).sprintf ("%0.2d",$mday); -my $defaultval = Field008(); +sub date_entered { + # find today's date + my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); + $year +=1900; + $mon +=1; + return substr($year,2,2).sprintf ("%0.2d", $mon).sprintf ("%0.2d",$mday); +} sub plugin_javascript { my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_; my $function_name= $field_number; + my $dateentered = date_entered(); + my $defaultval = Field008(); my $res=" <script type=\"text/javascript\"> //<![CDATA[ @@ -79,6 +81,8 @@ sub plugin { my $index= $input->param('index'); my $result= $input->param('result'); my $authtype= $input->param('authtypecode')||''; + + my $defaultval = Field008(); substr($defaultval,14-6,1)='b' if $authtype=~ /TOPIC_TERM|GENRE.FORM|CHRON_TERM/; my $dbh = C4::Context->dbh; @@ -91,6 +95,7 @@ sub plugin { flagsrequired => {editcatalogue => '*'}, debug => 1, }); + my $dateentered = date_entered(); $result = "$dateentered$defaultval" unless $result; my @f; for(0,6..17,28,29,31..33,38,39) { -- 1.7.10.4