From: Dan Wells Date: Tue, 17 Sep 2013 21:02:54 +0000 (-0400) Subject: Make titles understand compressed holdings X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=9c86d1b38e554c920e4420edb41e3fadf42da71d;p=working%2FEvergreen.git Make titles understand compressed holdings Signed-off-by: Dan Wells --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD/Holding.pm b/Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD/Holding.pm index c9dc00b1c9..915715dc79 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD/Holding.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD/Holding.pm @@ -56,13 +56,17 @@ sub new { } if ($key =~ /[a-h]/) { # Enumeration specific details of holdings - $self->{_mfhdh_FIELDS}->{$key}{UNIT_TITLE} = undef; + $self->{_mfhdh_FIELDS}->{$key}{UNIT_TITLES} = undef; $last_enum = $key; } } elsif ($key eq 'o') { warn '$o specified prior to first enumeration' unless defined($last_enum); - $self->{_mfhdh_FIELDS}->{$last_enum}->{UNIT_TITLE} = $val; + if ($self->{_mfhdh_COMPRESSED}) { + $self->{_mfhdh_FIELDS}->{$key}{UNIT_TITLES} = [split(/\-/, $val, -1)]; + } else { + $self->{_mfhdh_FIELDS}->{$key}{UNIT_TITLES} = [$val]; + } $last_enum = undef; } elsif ($key =~ /[npq]/) { $self->{_mfhdh_DESCR}->{$key} = $val; @@ -135,11 +139,12 @@ sub field_values { # Given a field key, returns a unit title (if there is one), or undef # if there isn't # -sub unit_title { +sub unit_titles { my ($self, $key) = @_; if (exists $self->fields->{$key}) { - return $self->fields->{$key}{UNIT_TITLE}; + my @titles = $self->fields->{$key}{UNIT_TITLES}; + return \@titles; } else { return; } @@ -376,7 +381,7 @@ sub format_single_enum { $skip_sep ||= ($key eq 'a'); return ($skip_sep ? '' : $sep) . $capstr . $holding_values->{$key} . - ($self->unit_title($key) ? ' ' . $self->unit_title($key) : ''); + (($holding_values->{$key . '_title'}) ? ' ' . $holding_values->{$key . '_title'} : ''); } # @@ -466,6 +471,8 @@ sub format { foreach my $key (keys %$subfields) { ($holding_start{$key}, $holding_end{$key}) = @{$self->field_values($key)}; + ($holding_start{$key . '_title'}, $holding_end{$key . '_title'}) = + @{$self->unit_titles($key)}; } if ($self->is_compressed) {