# Suite 330, Boston, MA 02111-1307 USA
use strict;
+use warnings;
# use utf8;
use MARC::Record;
use MARC::File::USMARC;
use MARC::File::XML;
use ZOOM;
-use C4::Context;
use C4::Koha;
-use C4::Branch;
use C4::Dates qw/format_date/;
use C4::Log; # logaction
use C4::ClassSource;
);
}
-# because of interdependencies between
-# C4::Search, C4::Heading, and C4::Biblio,
-# 'use C4::Heading' must occur after
-# the exports have been defined.
-use C4::Heading;
-
=head1 NAME
C4::Biblio - cataloging management functions
}
my %tables = ();
- if ($limit_table eq 'items') {
+ if ( defined $limit_table && $limit_table eq 'items') {
$tables{'items'} = 1;
} else {
$tables{'items'} = 1;
=cut
sub GetNoZebraIndexes {
- my $index = C4::Context->preference('NoZebraIndexes');
+ my $no_zebra_indexes = C4::Context->preference('NoZebraIndexes');
my %indexes;
- foreach my $line (split /('|"),[\n\r]*/,$index) {
+ INDEX: foreach my $line (split /['"],[\n\r]*/,$no_zebra_indexes) {
$line =~ /(.*)=>(.*)/;
my $index = $1; # initial ' or " is removed afterwards
my $fields = $2;
foreach (split / /,$line) {
next unless $_; # skip empty values (multiple spaces)
# if the entry is already here, do nothing, the biblionumber has already be removed
- unless ($result{$key}->{$_} =~ /$biblionumber,$title\-(\d);/) {
+ unless ( defined( $result{$key}->{$_} ) && ( $result{$key}->{$_} =~ /$biblionumber,$title\-(\d);/) ) {
# get the index value if it exist in the nozebra table and remove the entry, otherwise, do nothing
$sth2->execute($server,$key,$_);
my $existing_biblionumbers = $sth2->fetchrow;
next unless $_; # skip empty values (multiple spaces)
# if the entry is already here, improve weight
# warn "managing $_";
- if ($result{$key}->{"$_"} =~ /$biblionumber,\Q$title\E\-(\d+);/) {
- my $weight=$1 + 1;
+ if ( exists $result{$key}->{$_} && $result{$key}->{"$_"} =~ /$biblionumber,\Q$title\E\-(\d+);/) {
+ my $weight = $1 + 1;
$result{$key}->{"$_"} =~ s/$biblionumber,\Q$title\E\-(\d+);//g;
$result{$key}->{"$_"} .= "$biblionumber,$title-$weight;";
} else {
# it exists
if ($existing_biblionumbers) {
$result{$key}->{"$_"} =$existing_biblionumbers;
- my $weight=$1 + 1;
+ my $weight = defined $1 ? $1 + 1 : 1;
$result{$key}->{"$_"} =~ s/$biblionumber,\Q$title\E\-(\d+);//g;
$result{$key}->{"$_"} .= "$biblionumber,$title-$weight;";
# create a new ligne for this entry
foreach my $subfield ( keys( %{$tagslib->{ $tag }} ) ) {
# warn "checking $subfield. type is: " . ref $tagslib->{ $tag }{ $subfield };
if ( 'HASH' eq ref $tagslib->{ $tag }{ $subfield } ) {
- if ( exists $tagslib->{ $tag }{ $subfield }{'authorised_value'} && exists $bibliolevel_authorised_values->{ $tagslib->{ $tag }{ $subfield }{'authorised_value'} } ) {
+ if ( defined $tagslib->{ $tag }{ $subfield }{'authorised_value'} && exists $bibliolevel_authorised_values->{ $tagslib->{ $tag }{ $subfield }{'authorised_value'} } ) {
if ( defined $record->field( $tag ) ) {
my $this_subfield_value = $record->field( $tag )->subfield( $subfield );
if ( defined $this_subfield_value ) {
--- /dev/null
+package KohaTest::Biblio::GetNoZebraIndexes;
+use base qw( KohaTest::Biblio );
+
+use strict;
+use warnings;
+
+use Test::More;
+
+use C4::Biblio;
+
+=head2 STARTUP METHODS
+
+These get run once, before the main test methods in this module
+
+=cut
+
+
+=head2 TEST METHODS
+
+standard test methods
+
+=head3
+
+=cut
+
+sub returns_expected_hashref : Test(2) {
+ my $self = shift;
+
+ my %nzi = C4::Biblio::GetNoZebraIndexes();
+ ok( scalar keys %nzi, 'got some keys from GetNoZebraIndexes' );
+
+ my %expected = (
+ 'title' => '130a,210a,222a,240a,243a,245a,245b,246a,246b,247a,247b,250a,250b,440a,830a',
+ 'author' => '100a,100b,100c,100d,110a,111a,111b,111c,111d,245c,700a,710a,711a,800a,810a,811a',
+ 'isbn' => '020a',
+ 'issn' => '022a',
+ 'lccn' => '010a',
+ 'biblionumber' => '999c',
+ 'itemtype' => '942c',
+ 'publisher' => '260b',
+ 'date' => '260c',
+ 'note' => '500a,501a,504a,505a,508a,511a,518a,520a,521a,522a,524a,526a,530a,533a,538a,541a,546a,555a,556a,562a,563a,583a,585a,582a',
+ 'subject' => '600*,610*,611*,630*,650*,651*,653*,654*,655*,662*,690*',
+ 'dewey' => '082',
+ 'bc' => '952p',
+ 'callnum' => '952o',
+ 'an' => '6009,6109,6119',
+ 'homebranch' => '952a,952c'
+ );
+ is_deeply( \%nzi, \%expected, 'GetNoZebraIndexes returns the expected hashref' );
+}
+
+=head2 HELPER METHODS
+
+These methods are used by other test methods, but
+are not meant to be called directly.
+
+=cut
+
+=cut
+
+
+=head2 SHUTDOWN METHODS
+
+These get run once, after the main test methods in this module
+
+=head3
+
+=cut
+
+
+1;