&GetAuthorisedValueDesc
&GetMarcStructure
&GetMarcFromKohaField
+ &GetMarcSubfieldStructureFromKohaField
&GetFrameworkCode
&TransformKohaToMarc
&PrepHostMarcField
# warn "ERROR IN ISBD DEFINITION at : $isbdfield" unless $fieldvalue;
# warn "FV : $fieldvalue";
if ( $subfvalue ne "" ) {
+ # OPAC hidden subfield
+ next
+ if ( ( $template eq 'opac' )
+ && ( $tagslib->{$fieldvalue}->{$subfvalue}->{'hidden'} || 0 ) > 0 );
foreach my $field (@fieldslist) {
foreach my $subfield ( $field->subfield($subfvalue) ) {
my $calculated = $analysestring;
for my $i ( 0 .. $#subf ) {
my $valuecode = $subf[$i][1];
my $subfieldcode = $subf[$i][0];
+ # OPAC hidden subfield
+ next
+ if ( ( $template eq 'opac' )
+ && ( $tagslib->{$fieldvalue}->{$subfieldcode}->{'hidden'} || 0 ) > 0 );
my $subfieldvalue = GetAuthorisedValueDesc( $tag, $subf[$i][0], $subf[$i][1], '', $tagslib );
my $tagsubf = $tag . $subfieldcode;
($MARCfield,$MARCsubfield)=GetMarcFromKohaField($kohafield,$frameworkcode);
Returns the MARC fields & subfields mapped to the koha field
-for the given frameworkcode
+for the given frameworkcode or default framework if $frameworkcode is missing
=cut
sub GetMarcFromKohaField {
- my ( $kohafield, $frameworkcode ) = @_;
- return (0, undef) unless $kohafield and defined $frameworkcode;
+ my $kohafield = shift;
+ my $frameworkcode = shift || '';
+ return (0, undef) unless $kohafield;
my $relations = C4::Context->marcfromkohafield;
if ( my $mf = $relations->{$frameworkcode}->{$kohafield} ) {
return @$mf;
return (0, undef);
}
+=head2 GetMarcSubfieldStructureFromKohaField
+
+ my $subfield_structure = &GetMarcSubfieldStructureFromKohaField($kohafield, $frameworkcode);
+
+Returns a hashref where keys are marc_subfield_structure column names for the
+row where kohafield=$kohafield for the given framework code.
+
+$frameworkcode is optional. If not given, then the default framework is used.
+
+=cut
+
+sub GetMarcSubfieldStructureFromKohaField {
+ my ($kohafield, $frameworkcode) = @_;
+
+ return undef unless $kohafield;
+ $frameworkcode //= '';
+
+ my $dbh = C4::Context->dbh;
+ my $query = qq{
+ SELECT *
+ FROM marc_subfield_structure
+ WHERE kohafield = ?
+ AND frameworkcode = ?
+ };
+ my $sth = $dbh->prepare($query);
+ $sth->execute($kohafield, $frameworkcode);
+ my $result = $sth->fetchrow_hashref;
+ $sth->finish;
+
+ return $result;
+}
+
=head2 GetMarcBiblio
my $record = GetMarcBiblio($biblionumber, [$embeditems]);
my $marcxml = GetXmlBiblio($biblionumber);
Returns biblioitems.marcxml of the biblionumber passed in parameter.
-The XML contains both biblio & item datas
+The XML should only contain biblio information (item information is no longer stored in marcxml field)
=cut
my $note = "";
my $tag = "";
my $marcnote;
+ my %blacklist = map { $_ => 1 } split(/,/,C4::Context->preference('NotesBlacklist'));
foreach my $field ( $record->field($scope) ) {
- my $value = $field->as_string();
- if ( $note ne "" ) {
- $marcnote = { marcnote => $note, };
- push @marcnotes, $marcnote;
- $note = $value;
- }
- if ( $note ne $value ) {
- $note = $note . " " . $value;
+ my $tag = $field->tag();
+ if (!$blacklist{$tag}) {
+ my $value = $field->as_string();
+ if ( $note ne "" ) {
+ $marcnote = { marcnote => $note, };
+ push @marcnotes, $marcnote;
+ $note = $value;
+ }
+ if ( $note ne $value ) {
+ $note = $note . " " . $value;
+ }
}
}
my ($marc, $biblionumber, $itemnumbers) = @_;
croak "No MARC record" unless $marc;
+ $itemnumbers = [] unless defined $itemnumbers;
+
my $frameworkcode = GetFrameworkCode($biblionumber);
_strip_item_fields($marc, $frameworkcode);
my @item_fields;
my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField( "items.itemnumber", $frameworkcode );
while (my ($itemnumber) = $sth->fetchrow_array) {
- next if $itemnumbers and not grep { $_ == $itemnumber } @$itemnumbers;
+ next if @$itemnumbers and not grep { $_ == $itemnumber } @$itemnumbers;
require C4::Items;
my $item_marc = C4::Items::GetMarcItem($biblionumber, $itemnumber);
push @item_fields, $item_marc->field($itemtag);
# deal with UNIMARC field 100 (encoding) : create it if needed & set encoding to unicode
if ( $encoding eq "UNIMARC" ) {
+ my $defaultlanguage = C4::Context->preference("UNIMARCField100Language");
+ $defaultlanguage = "fre" if (!$defaultlanguage || length($defaultlanguage) != 3);
my $string = $record->subfield( 100, "a" );
if ( ($string) && ( length( $record->subfield( 100, "a" ) ) == 36 ) ) {
my $f100 = $record->field(100);
$string = POSIX::strftime( "%Y%m%d", localtime );
$string =~ s/\-//g;
$string = sprintf( "%-*s", 35, $string );
+ substr ( $string, 22, 3, $defaultlanguage);
}
- substr( $string, 22, 6, "frey50" );
+ substr( $string, 25, 3, "y50" );
unless ( $record->subfield( 100, "a" ) ) {
$record->insert_fields_ordered( MARC::Field->new( 100, "", "", "a" => $string ) );
}