use Business::ISBN;
use autouse 'Data::cselectall_arrayref' => qw(Dumper);
use DBI qw(:sql_types);
-use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $DEBUG);
+use vars qw(@ISA @EXPORT @EXPORT_OK $DEBUG);
BEGIN {
- $VERSION = 3.07.00.049;
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(
- &slashifyDate
- &subfield_is_koha_internal_p
&GetPrinters &GetPrinter
&GetItemTypes &getitemtypeinfo
&GetItemTypesCategorized &GetItemTypesByCategory
&GetSupportName &GetSupportList
- &get_itemtypeinfos_of
&getframeworks &getframeworkinfo
&GetFrameworksLoop
&getallthemes
&getFacets
- &displayServers
&getnbpages
&get_infos_of
&get_notforloan_label_of
&getitemtypeimagelocation
&GetAuthorisedValues
&GetAuthorisedValueCategories
- &IsAuthorisedValueCategory
&GetKohaAuthorisedValues
&GetKohaAuthorisedValuesFromField
&GetKohaAuthorisedValuesMapping
&GetKohaAuthorisedValueLib
&GetAuthorisedValueByCode
- &GetKohaImageurlFromAuthorisedValues
&GetAuthValCode
- &AddAuthorisedValue
&GetNormalizedUPC
&GetNormalizedISBN
&GetNormalizedEAN
=cut
-=head2 slashifyDate
-
- $slash_date = &slashifyDate($dash_date);
-
-Takes a string of the form "DD-MM-YYYY" (or anything separated by
-dashes), converts it to the form "YYYY/MM/DD", and returns the result.
-
-=cut
-
-sub slashifyDate {
-
- # accepts a date of the form xx-xx-xx[xx] and returns it in the
- # form xx/xx/xx[xx]
- my @dateOut = split( '-', shift );
- return ("$dateOut[2]/$dateOut[1]/$dateOut[0]");
-}
-
-# FIXME.. this should be moved to a MARC-specific module
-sub subfield_is_koha_internal_p {
- my ($subfield) = @_;
-
- # We could match on 'lib' and 'tab' (and 'mandatory', & more to come!)
- # But real MARC subfields are always single-character
- # so it really is safer just to check the length
-
- return length $subfield != 1;
-}
-
=head2 GetSupportName
$itemtypename = &GetSupportName($codestring);
return @$tmp;
}
-sub get_itemtypeinfos_of {
- my @itemtypes = @_;
-
- my $placeholders = join( ', ', map { '?' } @itemtypes );
- my $query = <<"END_SQL";
-SELECT itemtype,
- description,
- imageurl,
- notforloan
- FROM itemtypes
- WHERE itemtype IN ( $placeholders )
-END_SQL
-
- return get_infos_of( $query, 'itemtype', undef, \@itemtypes );
-}
-
=head2 getframework
$frameworks = &getframework();
}
];
- unless ( C4::Context->preference("singleBranchMode")
- || Koha::Libraries->search->count == 1 )
+ unless ( Koha::Libraries->search->count == 1 )
{
my $DisplayLibraryFacets = C4::Context->preference('DisplayLibraryFacets');
if ( $DisplayLibraryFacets eq 'both'
},
];
- unless ( C4::Context->preference("singleBranchMode")
- || Koha::Libraries->search->count == 1 )
+ unless ( Koha::Libraries->search->count == 1 )
{
my $DisplayLibraryFacets = C4::Context->preference('DisplayLibraryFacets');
if ( $DisplayLibraryFacets eq 'both'
return \%notforloan_label_of;
}
-=head2 displayServers
-
- my $servers = displayServers();
- my $servers = displayServers( $position );
- my $servers = displayServers( $position, $type );
-
-displayServers returns a listref of hashrefs, each containing
-information about available z3950 servers. Each hashref has a format
-like:
-
- {
- 'checked' => 'checked',
- 'encoding' => 'utf8',
- 'icon' => undef,
- 'id' => 'LIBRARY OF CONGRESS',
- 'label' => '',
- 'name' => 'server',
- 'opensearch' => '',
- 'value' => 'lx2.loc.gov:210/',
- 'zed' => 1,
- },
-
-=cut
-
-sub displayServers {
- my ( $position, $type ) = @_;
- my $dbh = C4::Context->dbh;
-
- my $strsth = 'SELECT * FROM z3950servers';
- my @where_clauses;
- my @bind_params;
-
- if ($position) {
- push @bind_params, $position;
- push @where_clauses, ' position = ? ';
- }
-
- if ($type) {
- push @bind_params, $type;
- push @where_clauses, ' type = ? ';
- }
-
- # reassemble where clause from where clause pieces
- if (@where_clauses) {
- $strsth .= ' WHERE ' . join( ' AND ', @where_clauses );
- }
-
- my $rq = $dbh->prepare($strsth);
- $rq->execute(@bind_params);
- my @primaryserverloop;
-
- while ( my $data = $rq->fetchrow_hashref ) {
- push @primaryserverloop,
- { label => $data->{description},
- id => $data->{name},
- name => "server",
- value => $data->{host} . ":" . $data->{port} . "/" . $data->{database},
- encoding => ( $data->{encoding} ? $data->{encoding} : "iso-5426" ),
- checked => "checked",
- icon => $data->{icon},
- zed => $data->{type} eq 'zed',
- opensearch => $data->{type} eq 'opensearch'
- };
- }
- return \@primaryserverloop;
-}
-
-
-=head2 GetKohaImageurlFromAuthorisedValues
-
-$authhorised_value = GetKohaImageurlFromAuthorisedValues( $category, $authvalcode );
-
-Return the first url of the authorised value image represented by $lib.
-
-=cut
-
-sub GetKohaImageurlFromAuthorisedValues {
- my ( $category, $lib ) = @_;
- 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'};
- }
-}
-
=head2 GetAuthValCode
$authvalcode = GetAuthValCode($kohafield,$frameworkcode);
return \@results;
}
-=head2 IsAuthorisedValueCategory
-
- $is_auth_val_category = IsAuthorisedValueCategory($category);
-
-Returns whether a given category name is a valid one
-
-=cut
-
-sub IsAuthorisedValueCategory {
- my $category = shift;
- my $query = '
- SELECT category
- FROM authorised_values
- WHERE category=?
- LIMIT 1
- ';
- my $sth = C4::Context->dbh->prepare($query);
- $sth->execute($category);
- $sth->fetchrow ? return 1
- : return 0;
-}
-
=head2 GetAuthorisedValueByCode
$authorised_value = GetAuthorisedValueByCode( $category, $authvalcode, $opac );
return $value;
}
-=head2 AddAuthorisedValue
-
- AddAuthorisedValue($category, $authorised_value, $lib, $lib_opac, $imageurl);
-
-Create a new authorised value.
-
-=cut
-
-sub AddAuthorisedValue {
- my ($category, $authorised_value, $lib, $lib_opac, $imageurl) = @_;
-
- my $dbh = C4::Context->dbh;
- my $query = qq{
- INSERT INTO authorised_values (category, authorised_value, lib, lib_opac, imageurl)
- VALUES (?,?,?,?,?)
- };
- my $sth = $dbh->prepare($query);
- $sth->execute($category, $authorised_value, $lib, $lib_opac, $imageurl);
-}
-
=head2 display_marc_indicators
my $display_form = C4::Koha::display_marc_indicators($field);
sub GetNormalizedUPC {
my ($marcrecord,$marcflavour) = @_;
- if ($marcrecord) {
- if ($marcflavour eq 'UNIMARC') {
- my @fields = $marcrecord->field('072');
- foreach my $field (@fields) {
- my $upc = _normalize_match_point($field->subfield('a'));
- if ($upc) {
- return $upc;
- }
+ return unless $marcrecord;
+ if ($marcflavour eq 'UNIMARC') {
+ my @fields = $marcrecord->field('072');
+ foreach my $field (@fields) {
+ my $upc = _normalize_match_point($field->subfield('a'));
+ if ($upc) {
+ return $upc;
}
-
}
- else { # assume marc21 if not unimarc
- my @fields = $marcrecord->field('024');
- foreach my $field (@fields) {
- my $indicator = $field->indicator(1);
- my $upc = _normalize_match_point($field->subfield('a'));
- if ($upc && $indicator == 1 ) {
- return $upc;
- }
+
+ }
+ else { # assume marc21 if not unimarc
+ my @fields = $marcrecord->field('024');
+ foreach my $field (@fields) {
+ my $indicator = $field->indicator(1);
+ my $upc = _normalize_match_point($field->subfield('a'));
+ if ($upc && $indicator == 1 ) {
+ return $upc;
}
}
}
- return;
}
# Normalizes and returns the first valid ISBN found in the record
($isbn) = split(/\|/, $isbn );
return _isbn_cleanup($isbn);
}
- if ($marcrecord) {
-
- if ($marcflavour eq 'UNIMARC') {
- my @fields = $marcrecord->field('010');
- foreach my $field (@fields) {
- my $isbn = $field->subfield('a');
- if ($isbn) {
- return _isbn_cleanup($isbn);
- }
+
+ return unless $marcrecord;
+
+ if ($marcflavour eq 'UNIMARC') {
+ my @fields = $marcrecord->field('010');
+ foreach my $field (@fields) {
+ my $isbn = $field->subfield('a');
+ if ($isbn) {
+ return _isbn_cleanup($isbn);
}
}
- else { # assume marc21 if not unimarc
- my @fields = $marcrecord->field('020');
- foreach my $field (@fields) {
- $isbn = $field->subfield('a');
- if ($isbn) {
- return _isbn_cleanup($isbn);
- }
+ }
+ else { # assume marc21 if not unimarc
+ my @fields = $marcrecord->field('020');
+ foreach my $field (@fields) {
+ $isbn = $field->subfield('a');
+ if ($isbn) {
+ return _isbn_cleanup($isbn);
}
}
}
- return;
}
sub GetNormalizedEAN {
my ($marcrecord,$marcflavour) = @_;
- if ($marcrecord) {
- if ($marcflavour eq 'UNIMARC') {
- my @fields = $marcrecord->field('073');
- foreach my $field (@fields) {
- my $ean = _normalize_match_point($field->subfield('a'));
- if ( $ean ) {
- return $ean;
- }
+ return unless $marcrecord;
+
+ if ($marcflavour eq 'UNIMARC') {
+ my @fields = $marcrecord->field('073');
+ foreach my $field (@fields) {
+ my $ean = _normalize_match_point($field->subfield('a'));
+ if ( $ean ) {
+ return $ean;
}
}
- else { # assume marc21 if not unimarc
- my @fields = $marcrecord->field('024');
- foreach my $field (@fields) {
- my $indicator = $field->indicator(1);
- my $ean = _normalize_match_point($field->subfield('a'));
- if ( $ean && $indicator == 3 ) {
- return $ean;
- }
+ }
+ else { # assume marc21 if not unimarc
+ my @fields = $marcrecord->field('024');
+ foreach my $field (@fields) {
+ my $indicator = $field->indicator(1);
+ my $ean = _normalize_match_point($field->subfield('a'));
+ if ( $ean && $indicator == 3 ) {
+ return $ean;
}
}
}
- return;
}
sub GetNormalizedOCLCNumber {
my ($marcrecord,$marcflavour) = @_;
- if ($marcrecord && $marcflavour ne 'UNIMARC' ) {
+ return unless $marcrecord;
+
+ if ($marcflavour ne 'UNIMARC' ) {
my @fields = $marcrecord->field('035');
foreach my $field (@fields) {
my $oclc = $field->subfield('a');
return $oclc;
}
}
+ } else {
+ # TODO for UNIMARC
}
- return;
+ return
}
sub GetAuthvalueDropbox {