From cc4ab0f91a5db931a9f6c83941a7d9265a2b575f Mon Sep 17 00:00:00 2001 From: Bernardo Gonzalez Kriegel Date: Wed, 18 Sep 2013 17:58:24 -0300 Subject: [PATCH] Bug 8334 - Authority UNIMARC 100 field plugin The work for this patch belongs to Vitor Fernandez Udated License information. This patch adds a plugin for field 100 of UNIMARC authorities. To test on a UNIMARC site: 1) Apply the patch 2) Edit some authority framework, field 100 3) Link subfield 'a' to unimarc_field_100_authorities.pl plugin, save 4) Edit or add auth record, clic on '...' to bring plugin 5) Modify field 100a 6) Save record Please someone with UNIMARC experience take a look at this. --- .../value_builder/unimarc_field_100_authorities.pl | 128 ++++++ .../value_builder/unimarc_field_100_authorities.tt | 412 ++++++++++++++++++++ 2 files changed, 540 insertions(+) create mode 100644 cataloguing/value_builder/unimarc_field_100_authorities.pl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/unimarc_field_100_authorities.tt diff --git a/cataloguing/value_builder/unimarc_field_100_authorities.pl b/cataloguing/value_builder/unimarc_field_100_authorities.pl new file mode 100644 index 0000000..30abc3a --- /dev/null +++ b/cataloguing/value_builder/unimarc_field_100_authorities.pl @@ -0,0 +1,128 @@ +#!/usr/bin/perl + +# This file is part of Koha. +# +# Copyright (C) 2013 Vitor Fernandes +# +# 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, see . + +use Modern::Perl; +use C4::Auth; +use CGI; +use C4::Context; +use C4::Output; + + +=head1 FUNCTIONS + +=head2 plugin_parameters + +Other parameters added when the plugin is called by the dopop function + +=cut + +sub plugin_parameters { + my ( $dbh, $record, $tagslib, $i, $tabloop ) = @_; + return ""; +} + +sub plugin_javascript { + my ( $dbh, $record, $tagslib, $field_number, $tabloop ) = @_; + my $res = " + +"; + + return ( $field_number, $res ); +} + +sub wrapper { + my ($char) = @_; + return "space" if $char eq " "; + return "dblspace" if $char eq " "; + return "pipe" if $char eq "|"; + return $char; +} + +sub plugin { + my ($input) = @_; + my $index = $input->param('index'); + my $result = $input->param('result'); + + my $dbh = C4::Context->dbh; + + my $defaultlanguage = C4::Context->preference("UNIMARCField100Language"); + $defaultlanguage = "fre" if (!$defaultlanguage || length($defaultlanguage) != 3); + + my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "cataloguing/value_builder/unimarc_field_100_authorities.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => { editcatalogue => '*' }, + debug => 1, + } + ); + $result = " a".$defaultlanguage."y50 ba0" unless $result; + my $f1 = substr( $result, 0, 8 ); + if ( $f1 eq ' ' ) { + my @today = Date::Calc::Today(); + $f1 = $today[0] . sprintf('%02s',$today[1]) . sprintf('%02s',$today[2]); + } + + my $f2 = substr( $result, 8, 1 ); $f2 = wrapper( $f2 ) if $f2; + my $f3 = substr( $result, 9, 3 ); + my $f4 = substr( $result, 12, 1 ); $f4 = wrapper( $f4 ) if $f4; + my $f5 = substr( $result, 13, 2 ); $f5 = wrapper( $f5 ) if $f5; + my $f6 = substr( $result, 15, 2 ); $f6 = wrapper( $f6 ) if $f6; + my $f7 = substr( $result, 17, 4 ); $f7 = wrapper( $f7 ) if $f7; + my $f8 = substr( $result, 21, 2 ); $f8 = wrapper( $f8 ) if $f8; + my $f9 = substr( $result, 23, 1 ); $f9 = wrapper( $f9 ) if $f9; + + $template->param( + index => $index, + f1 => $f1, + "f2$f2" => 1, + f3 => $f3, + "f4$f4" => 1, + "f5$f5" => 1, + "f6$f6" => 1, + f7 => $f7, + "f8$f8" => 1, + "f9$f9" => 1, + ); + output_html_with_http_headers $input, $cookie, $template->output; +} + +1; + diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/unimarc_field_100_authorities.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/unimarc_field_100_authorities.tt new file mode 100644 index 0000000..553ee49 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/unimarc_field_100_authorities.tt @@ -0,0 +1,412 @@ +[% INCLUDE 'doc-head-open.inc' %] +UNIMARC field 100 builder +[% INCLUDE 'doc-head-close.inc' %] + + +

UNIMARC field 100 builder

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+

Cancel

+
+ +[% INCLUDE 'popup-bottom.inc' %] -- 1.7.9.5