# Copyright 2000-2002 Katipo Communications
# Parts Copyright 2010 Nelsonville Public Library
+# Parts copyright 2010 BibLibre
#
# This file is part of Koha.
#
&GetKohaAuthorisedValues
&GetKohaAuthorisedValuesFromField
&GetKohaAuthorisedValueLib
- &GetAuthorisedValueByCode
- &GetKohaImageurlFromAuthorisedValues
+ &GetAuthorisedValueByCode
+ &GetKohaImageurlFromAuthorisedValues
&GetAuthValCode
&GetNormalizedUPC
&GetNormalizedISBN
my @imagesets = (); # list of hasrefs of image set data to pass to template
my @subdirectories = _getSubdirectoryNames( $paths->{'staff'}{'filesystem'} );
-warn $paths->{'staff'}{'filesystem'};
foreach my $imagesubdir ( @subdirectories ) {
- warn $imagesubdir;
+ warn $imagesubdir if $DEBUG;
my @imagelist = (); # hashrefs of image info
my @imagenames = _getImagesFromDirectory( File::Spec->catfile( $paths->{'staff'}{'filesystem'}, $imagesubdir ) );
my $imagesetactive = 0;
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare("SELECT imageurl FROM authorised_values WHERE category=? AND lib =?");
$sth->execute( $category, $lib );
- while ( my $data = $sth->fetchrow_hashref ) {
- return $data->{'imageurl'};
- }
+ while ( my $data = $sth->fetchrow_hashref ) {
+ return $data->{'imageurl'};
+ }
}
=head2 GetAuthValCode
my $sth = $dbh->prepare("SELECT DISTINCT category FROM authorised_values ORDER BY category");
$sth->execute;
my @results;
- while (my $category = $sth->fetchrow_array) {
+ while (defined (my $category = $sth->fetchrow_array) ) {
push @results, $category;
}
return \@results;
$authhorised_value = GetAuthorisedValueByCode( $category, $authvalcode );
-Return an hashref of the authorised value represented by $authvalcode.
+Return the lib attribute from authorised_values from the row identified
+by the passed category and code
=cut
sub GetAuthorisedValueByCode {
- my ( $category, $authvalcode ) = @_;
-
+ my ( $category, $authvalcode ) = @_;
+
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare("SELECT lib FROM authorised_values WHERE category=? AND authorised_value =?");
$sth->execute( $category, $authvalcode );
- while ( my $data = $sth->fetchrow_hashref ) {
- return $data->{'lib'};
- }
+ while ( my $data = $sth->fetchrow_hashref ) {
+ return $data->{'lib'};
+ }
}
=head2 GetKohaAuthorisedValues
my ($record,$marcflavour) = @_;
my (@fields,$upc);
- if ($marcflavour eq 'MARC21') {
- @fields = $record->field('024');
+ if ($marcflavour eq 'UNIMARC') {
+ @fields = $record->field('072');
foreach my $field (@fields) {
- my $indicator = $field->indicator(1);
my $upc = _normalize_match_point($field->subfield('a'));
- if ($indicator == 1 and $upc ne '') {
+ if ($upc ne '') {
return $upc;
}
}
+
}
- else { # assume unimarc if not marc21
- @fields = $record->field('072');
+ else { # assume marc21 if not unimarc
+ @fields = $record->field('024');
foreach my $field (@fields) {
+ my $indicator = $field->indicator(1);
my $upc = _normalize_match_point($field->subfield('a'));
- if ($upc ne '') {
+ if ($indicator == 1 and $upc ne '') {
return $upc;
}
}
}
return undef unless $record;
- if ($marcflavour eq 'MARC21') {
- @fields = $record->field('020');
+ if ($marcflavour eq 'UNIMARC') {
+ @fields = $record->field('010');
foreach my $field (@fields) {
- $isbn = $field->subfield('a');
+ my $isbn = $field->subfield('a');
if ($isbn) {
return _isbn_cleanup($isbn);
} else {
}
}
}
- else { # assume unimarc if not marc21
- @fields = $record->field('010');
+ else { # assume marc21 if not unimarc
+ @fields = $record->field('020');
foreach my $field (@fields) {
- my $isbn = $field->subfield('a');
+ $isbn = $field->subfield('a');
if ($isbn) {
return _isbn_cleanup($isbn);
} else {
}
}
}
-
}
sub GetNormalizedEAN {
my ($record,$marcflavour) = @_;
my (@fields,$ean);
- if ($marcflavour eq 'MARC21') {
- @fields = $record->field('024');
+ if ($marcflavour eq 'UNIMARC') {
+ @fields = $record->field('073');
foreach my $field (@fields) {
- my $indicator = $field->indicator(1);
$ean = _normalize_match_point($field->subfield('a'));
- if ($indicator == 3 and $ean ne '') {
+ if ($ean ne '') {
return $ean;
}
}
}
- else { # assume unimarc if not marc21
- @fields = $record->field('073');
+ else { # assume marc21 if not unimarc
+ @fields = $record->field('024');
foreach my $field (@fields) {
+ my $indicator = $field->indicator(1);
$ean = _normalize_match_point($field->subfield('a'));
- if ($ean ne '') {
+ if ($indicator == 3 and $ean ne '') {
return $ean;
}
}
my ($record,$marcflavour) = @_;
my (@fields,$oclc);
- if ($marcflavour eq 'MARC21') {
+ if ($marcflavour eq 'UNIMARC') {
+ # TODO: add UNIMARC fields
+ }
+ else { # assume marc21 if not unimarc
@fields = $record->field('035');
foreach my $field (@fields) {
$oclc = $field->subfield('a');
}
}
}
- else { # TODO: add UNIMARC fields
- }
}
sub _normalize_match_point {