#
# 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 2 of the License, or (at your option) any later
-# version.
+# 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.
+# 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, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
use 5.010;
use strict;
use warnings;
-use MARC::Record;
use MARC::Field;
use C4::Context;
-our $VERSION = 3.00;
=head1 NAME
my %subdivisions = (
'j' => 'formsubdiv',
'x' => 'generalsubdiv',
- 'y' => 'chronologicalsubdiv',
- 'z' => 'geographicsubdiv',
+ 'y' => 'geographicsubdiv',
+ 'z' => 'chronologicalsubdiv',
);
my $bib_heading_fields;
return bless {}, $class;
}
-=head2 valid_bib_heading_tag
+=head2 valid_heading_tag
=cut
-sub valid_bib_heading_tag {
+sub valid_heading_tag {
my ( $self, $tag ) = @_;
return $bib_heading_fields->{$tag};
}
+=head2 valid_heading_subfield
+
+=cut
+
+sub valid_heading_subfield {
+ my $self = shift;
+ my $tag = shift;
+ my $subfield = shift;
+
+ if ( exists $bib_heading_fields->{$tag} ) {
+ return 1 if ($bib_heading_fields->{$tag}->{subfields} =~ /$subfield/);
+ }
+ return 0;
+}
+
=head2 parse_heading
=cut
my $code = $subfields[$i]->[0];
my $code_re = quotemeta $code;
my $value = $subfields[$i]->[1];
- $value =~ s/[-,.:=;!%\/]*$//;
+ $value =~ s/[\s]*[-,.:=;!%\/][\s]*$//;
next unless $subfields =~ qr/$code_re/;
if ($first) {
$first = 0;
$heading = $value;
}
else {
- $heading .= " $value";
+ if ( exists $subdivisions{$code} ) {
+ $heading .= " $subdivisions{$code} $value";
+ }
+ else {
+ $heading .= " $value";
+ }
}
}