Bug 17233 - Add 008 value builder plugin for MARC21 classifications

This patch adds 008 cataloguing value builder for MARC21 classifications
records (LCC, DDC/Dewey, UDC and so on).

For most practical purposes, MARC21 classification records
(<https://www.loc.gov/marc/classification/>) are quite similar to regular
MARC21 authority records, so handling them in Koha is (almost) achievable
by means of the built-in 'regular' MARC21 authority records related
functionalities, but there are some notable differences - in particular,
008 field length and format is not the same.

To test:

1) apply patch
2) link the new plugin (marc21_field_008_classifications.pl) to the 008
field in the existing (or cloned, ..) authority framework of your choice
3) try to add, edit, re-edit 008 field using this "authority" framework,
ensure that the new plugin behaves as it should according to the
Library of Congress specifications for MARC21 classification records
008 field format (<https://www.loc.gov/marc/classification/cd008.html>).

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
Jacek Ablewicz 2016-09-01 21:10:57 +02:00 committed by Kyle M Hall
parent db467287d1
commit 5693f10220
2 changed files with 316 additions and 0 deletions

View file

@ -0,0 +1,97 @@
#!/usr/bin/perl
# 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, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use C4::Auth;
use CGI qw ( -utf8 );
use C4::Context;
use C4::Search;
use C4::Output;
use Koha::Util::FrameworkPlugin qw|date_entered|;
use constant FIXLEN_DATA_ELTS => 'baaaaaaa';
my $builder = sub {
my ( $params ) = @_;
my $function_name = $params->{id};
my $dateentered = date_entered();
my $defaultval = FIXLEN_DATA_ELTS;
my $res="
<script type=\"text/javascript\">
//<![CDATA[
function Focus$function_name(event) {
if (!document.getElementById(event.data.id).value) {
var authtype=document.forms['f'].elements['authtypecode'].value;
var fieldval='$dateentered$defaultval';
document.getElementById(event.data.id).value=fieldval;
}
return 1;
}
function Click$function_name(event) {
var authtype=document.forms['f'].elements['authtypecode'].value;
defaultvalue=document.getElementById(event.data.id).value;
newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=marc21_field_008_classifications.pl&index=\"+ event.data.id +\"&result=\"+defaultvalue+\"&authtypecode=\"+authtype,\"tag_editor\",'width=1000,height=600,toolbar=false,scrollbars=yes');
}
//]]>
</script>
";
return $res;
};
my $launcher = sub {
my ( $params ) = @_;
my $input = $params->{cgi};
my $index = $input->param('index');
my $result = $input->param('result');
my $authtype = $input->param('authtypecode') || '';
my $defaultval = FIXLEN_DATA_ELTS;
my ($template, $loggedinuser, $cookie) = get_template_and_user({
template_name => "cataloguing/value_builder/marc21_field_008_classifications.tt",
query => $input,
type => "intranet",
authnotrequired => 0,
flagsrequired => { editcatalogue => '*' },
debug => 1,
});
my $dateentered = date_entered();
$result = "$dateentered$defaultval" unless $result;
my @f;
for (0,6..13) {
$f[$_]=substr($result,$_,$_==0?6:1);
}
$template->param(index => $index);
$f[0] = $dateentered if !$f[0] || $f[0]=~/\s/;
$template->param(f1 => $f[0]);
for (6..13) {
$template->param(
"f$_" => $f[$_],
"f$_".($f[$_] eq '|'? 'pipe': $f[$_]) => $f[$_],
);
}
output_html_with_http_headers $input, $cookie, $template->output;
};
return { builder => $builder, launcher => $launcher };

View file

@ -0,0 +1,219 @@
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Classifications &rsaquo; 008 builder</title>
[% INCLUDE 'doc-head-close.inc' %]
</head>
<body id="cat_marc21_field_008_classifications" class="cat" style="padding:1em;">
<h3> 008 Fixed-length data elements</h3>
<form name="f_pop" onsubmit="report()" action="">
<input type="hidden" name="plugin_name" value="marc21_field_008_classifications.pl" />
<input name="f1" value="[% f1 %]" type="hidden" />
<table>
<tr>
<td>00-05- Date entered on file</td>
<td>[% f1 %]</td>
</tr>
<tr>
<td><label for="f6">06- Kind of record</label></td>
<td>
<select name="f6" id="f6" size="1">
[% IF ( f6a ) %]
<option value="a" selected="selected">a- Schedule record</option>
[% ELSE %]
<option value="a">a- Schedule record</option>
[% END %]
[% IF ( f6b ) %]
<option value="b" selected="selected">b- Table record</option>
[% ELSE %]
<option value="b">b- Table record</option>
[% END %]
[% IF ( f6c ) %]
<option value="c" selected="selected">c- Index term record</option>
[% ELSE %]
<option value="c">c- Index term record</option>
[% END %]
</select>
</td>
</tr>
<tr>
<td><label for="f7">07- Type of number</label></td>
<td>
<select name="f7" id="f7" size="1">
[% IF ( f7a ) %]
<option value="a" selected="selected">a- Single number</option>
[% ELSE %]
<option value="a">a- Single number</option>
[% END %]
[% IF ( f7b ) %]
<option value="b" selected="selected">b- Defined number span</option>
[% ELSE %]
<option value="b">b- Defined number span</option>
[% END %]
[% IF ( f7c ) %]
<option value="c" selected="selected">c- Summary number span</option>
[% ELSE %]
<option value="c">c- Summary number span</option>
[% END %]
[% IF ( f7n ) %]
<option value="n" selected="selected">n- Not applicable</option>
[% ELSE %]
<option value="n">n - Not applicable</option>
[% END %]
</select>
</td>
</tr>
<tr>
<td><label for="f8">08- Classification validity</label></td>
<td>
<select name="f8" id="f8" size="1">
[% IF ( f8a ) %]
<option value="a" selected="selected">a- Valid</option>
[% ELSE %]
<option value="a">a- Valid</option>
[% END %]
[% IF ( f8b ) %]
<option value="b" selected="selected">b- First number of span invalid</option>
[% ELSE %]
<option value="b">b- First number of span invalid</option>
[% END %]
[% IF ( f8c ) %]
<option value="c" selected="selected">c- Last number of span invalid</option>
[% ELSE %]
<option value="c">c- Last number of span invalid</option>
[% END %]
[% IF ( f8d ) %]
<option value="d" selected="selected">d- Completely invalid</option>
[% ELSE %]
<option value="d">d- Completely invalid</option>
[% END %]
[% IF ( f8e ) %]
<option value="e" selected="selected">e- Obsolete</option>
[% ELSE %]
<option value="e">e- Obsolete</option>
[% END %]
[% IF ( f8n ) %]
<option value="n" selected="selected">n- Not applicable</option>
[% ELSE %]
<option value="n">n - Not applicable</option>
[% END %]
</select>
</td>
</tr>
<tr>
<td><label for="f9">09- Standard or optional designation</label></td>
<td>
<select name="f9" id="f9" size="1">
[% IF ( f9a ) %]
<option value="a" selected="selected">a- Standard</option>
[% ELSE %]
<option value="a">a- Standard</option>
[% END %]
[% IF ( f9b ) %]
<option value="b" selected="selected">b- Optional</option>
[% ELSE %]
<option value="b">b- Optional</option>
[% END %]
[% IF ( f9n ) %]
<option value="n" selected="selected">n- Not applicable</option>
[% ELSE %]
<option value="n">n - Not applicable</option>
[% END %]
</select>
</td>
</tr>
<tr>
<td><label for="f10">10- Record update in process</label></td>
<td>
<select name="f10" id="f10" size="1">
[% IF ( f10a ) %]
<option value="a" selected="selected">a- Record can be used</option>
[% ELSE %]
<option value="a">a- Record can be used</option>
[% END %]
[% IF ( f10b ) %]
<option value="b" selected="selected">b- Record is being updated</option>
[% ELSE %]
<option value="b">b- Record is being updated</option>
[% END %]
</select>
</td>
</tr>
<tr>
<td><label for="f11">11- Level of establishment</label></td>
<td>
<select name="f11" id="f11" size="1">
[% IF ( f11a ) %]
<option value="a" selected="selected">a- Fully established</option>
[% ELSE %]
<option value="a">a- Fully established</option>
[% END %]
[% IF ( f11c ) %]
<option value="c" selected="selected">c- Provisional</option>
[% ELSE %]
<option value="c">c- Provisional</option>
[% END %]
</select>
</td>
</tr>
<tr>
<td><label for="f12">12- Synthesized number indication</label></td>
<td>
<select name="f12" id="f12" size="1">
[% IF ( f12a ) %]
<option value="a" selected="selected">a- Not synthesized</option>
[% ELSE %]
<option value="a">a- Not synthesized</option>
[% END %]
[% IF ( f12b ) %]
<option value="b" selected="selected">b- Synthesized</option>
[% ELSE %]
<option value="b">b- Synthesized</option>
[% END %]
[% IF ( f12n ) %]
<option value="n" selected="selected">n- Not applicable</option>
[% ELSE %]
<option value="n">n - Not applicable</option>
[% END %]
</select>
</td>
</tr>
<tr>
<td><label for="f13">13- Display controller</label></td>
<td>
<select name="f13" id="f13" size="1">
[% IF ( f13a ) %]
<option value="a" selected="selected">a- Displayed in standard schedules or tables</option>
[% ELSE %]
<option value="a">a- Displayed in standard schedules or tables</option>
[% END %]
[% IF ( f13b ) %]
<option value="b" selected="selected">b- Extended display</option>
[% ELSE %]
<option value="b">b- Extended display</option>
[% END %]
</select>
</td>
</tr>
</table>
<fieldset class="action"><input type="submit" value="OK" /> <a href="#" class="cancel close">Cancel</a></fieldset>
</form>
<script type="text/javascript">//<![CDATA[
function report() {
var doc = opener.document;
var field = doc.getElementById("[% index %]");
field.value =
document.f_pop.f1.value+
document.f_pop.f6.value+
document.f_pop.f7.value+
document.f_pop.f8.value+
document.f_pop.f9.value+
document.f_pop.f10.value+
document.f_pop.f11.value+
document.f_pop.f12.value+
document.f_pop.f13.value;
self.close();
return false;
}
//]]>
</script>
[% INCLUDE 'popup-bottom.inc' %]