require C4::Heading;
require C4::Serials;
-use vars qw($VERSION @ISA @EXPORT);
+use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
BEGIN {
$VERSION = 1.00;
# to add biblios
# EXPORTED FUNCTIONS.
+ push @EXPORT_OK, qw(
+ &GetRecordValue
+ );
+
push @EXPORT, qw(
&AddBiblio
);
# to get something
push @EXPORT, qw(
- &Get
&GetBiblio
&GetBiblioData
&GetBiblioItemData
&GetBiblioItemByBiblioNumber
&GetBiblioFromItemNumber
- GetFieldMapping
- SetFieldMapping
- DeleteFieldMapping
+ &GetRecordValue
+ &GetFieldMapping
+ &SetFieldMapping
+ &DeleteFieldMapping
&GetISBDView
return $num_headings_changed;
}
-=head2 Get
+=head2 GetRecordValue
=over 4
-my $values = Get($field, $record, $frameworkcode);
+my $values = GetRecordValue($field, $record, $frameworkcode);
=back
=cut
-sub Get {
+sub GetRecordValue {
my ($field, $record, $frameworkcode) = @_;
my $dbh = C4::Context->dbh;
}
}
- return @result;
+ return \@result;
}
=head2 SetFieldMapping
if ( ( @$tags[$i] && @$tags[$i] > 10 )
&& ( @$values[$i] ne "" ) )
{
- my $ind1 = substr( @$indicator[$j], 0, 1 );
+ my $ind1 = _default_ind_to_space(substr( @$indicator[$j], 0, 1 ));
my $ind2;
if ( @$indicator[$j] ) {
- $ind2 = substr( @$indicator[$j], 1, 1 );
+ $ind2 = _default_ind_to_space(substr( @$indicator[$j], 1, 1 ));
}
else {
warn "Indicator in @$tags[$i] is empty";
$first = 1;
}
else {
- my $ind1 = substr( @$indicator[$j], 0, 1 );
- my $ind2 = substr( @$indicator[$j], 1, 1 );
- $ind1 = " " if !defined($ind2) or $ind2 eq "";
- $ind2 = " " if !defined($ind2) or $ind2 eq "";
+ my $ind1 = _default_ind_to_space( substr( @$indicator[$j], 0, 1 ) );
+ my $ind2 = _default_ind_to_space( substr( @$indicator[$j], 1, 1 ) );
$xml .= "<datafield tag=\"@$tags[$i]\" ind1=\"$ind1\" ind2=\"$ind2\">\n";
$xml .= "<subfield code=\"@$subfields[$i]\">@$values[$i]</subfield>\n";
$first = 0;
}
else {
if ($first) {
- my $ind1 = substr( @$indicator[$j], 0, 1 );
- my $ind2 = substr( @$indicator[$j], 1, 1 );
- $ind1 = " " if !defined($ind2) or $ind2 eq "";
- $ind2 = " " if !defined($ind2) or $ind2 eq "";
+ my $ind1 = _default_ind_to_space( substr( @$indicator[$j], 0, 1 ) );
+ my $ind2 = _default_ind_to_space( substr( @$indicator[$j], 1, 1 ) );
$xml .= "<datafield tag=\"@$tags[$i]\" ind1=\"$ind1\" ind2=\"$ind2\">\n";
$first = 0;
}
return $xml;
}
+=head2 _default_ind_to_space
+
+Passed what should be an indicator returns a space
+if its undefined or zero length
+
+=cut
+
+sub _default_ind_to_space {
+ my $s = shift;
+ if (!defined $s || $s eq q{}) {
+ return ' ';
+ }
+ return $s;
+}
+
=head2 TransformHtmlToMarc
L<$record> = TransformHtmlToMarc(L<$params>,L<$cgi>)
elsif ($param =~ /^tag_(\d*)_indicator1_/){ # new field start when having 'input name="..._indicator1_..."
my $tag = $1;
- my $ind1 = substr($cgi->param($param),0,1);
- my $ind2 = substr($cgi->param($params->[$i+1]),0,1);
+ my $ind1 = _default_ind_to_space(substr($cgi->param($param), 0, 1));
+ my $ind2 = _default_ind_to_space(substr($cgi->param($params->[$i+1]), 0, 1));
$newfield=0;
my $j=$i+2;
if ( $cgi->param($params->[$j+1]) ne '' ) { # creating only if there is a value (code => value)
$newfield = MARC::Field->new(
$tag,
- ''.$ind1,
- ''.$ind2,
+ $ind1,
+ $ind2,
$cgi->param($inner_param) => $cgi->param($params->[$j+1]),
);
}