sub CountUsage {
my ($authid) = @_;
- if (C4::Context->preference('NoZebra')) {
- # Read the index Koha-Auth-Number for this authid and count the lines
- my $result = C4::Search::NZanalyse("an=$authid");
- my @tab = split /;/,$result;
- return scalar @tab;
- } else {
### ZOOM search here
my $query;
$query= "an:".$authid;
}
return $result;
- }
}
=head2 CountUsageChildren
=cut
sub GuessAuthTypeCode {
- my ($record) = @_;
+ my ($record, $heading_fields) = @_;
return unless defined $record;
-my $heading_fields = {
+ $heading_fields //= {
"MARC21"=>{
'100'=>{authtypecode=>'PERSO_NAME'},
'110'=>{authtypecode=>'CORPO_NAME'},
$res->{$tag}->{repeatable} = $repeatable;
}
$sth= $dbh->prepare(
-"SELECT tagfield,tagsubfield,liblibrarian,libopac,tab, mandatory, repeatable,authorised_value,frameworkcode as authtypecode,value_builder,kohafield,seealso,hidden,isurl
+"SELECT tagfield,tagsubfield,liblibrarian,libopac,tab, mandatory, repeatable,authorised_value,frameworkcode as authtypecode,value_builder,kohafield,seealso,hidden,isurl,defaultvalue
FROM auth_subfield_structure
WHERE authtypecode=?
ORDER BY tagfield,tagsubfield"
my $hidden;
my $isurl;
my $link;
+ my $defaultvalue;
while (
( $tag, $subfield, $liblibrarian, , $libopac, $tab,
$mandatory, $repeatable, $authorised_value, $authtypecode,
$value_builder, $kohafield, $seealso, $hidden,
- $isurl, $link )
+ $isurl, $defaultvalue, $link )
= $sth->fetchrow
)
{
$res->{$tag}->{$subfield}->{hidden} = $hidden;
$res->{$tag}->{$subfield}->{isurl} = $isurl;
$res->{$tag}->{$subfield}->{link} = $link;
+ $res->{$tag}->{$subfield}->{defaultvalue} = $defaultvalue;
}
return $res;
}
# construct UNIMARC summary, that is quite different from MARC21 one
# accepted form
foreach my $field ($record->field('2..')) {
- push @authorized, { heading => $field->as_string('abcdefghijlmnopqrstuvwxyz'), field => $field->tag() };
+ push @authorized, {
+ heading => $field->as_string('abcdefghijlmnopqrstuvwxyz'),
+ hemain => $field->subfield('a'),
+ field => $field->tag(),
+ };
}
# rejected form(s)
foreach my $field ($record->field('3..')) {
}
foreach my $field ($record->field('4..')) {
my $thesaurus = $field->subfield('2') ? "thes. : ".$thesaurus{"$field->subfield('2')"}." : " : '';
- push @seefrom, { heading => $thesaurus . $field->as_string('abcdefghijlmnopqrstuvwxyz'), type => 'seefrom', field => $field->tag() };
+ push @seefrom, {
+ heading => $thesaurus . $field->as_string('abcdefghijlmnopqrstuvwxyz'),
+ hemain => $field->subfield('a'),
+ type => 'seefrom',
+ field => $field->tag(),
+ };
}
# see :
field => $_->tag,
type => $type,
heading => $heading,
+ hemain => $_->subfield('a'),
search => $heading,
authid => $_->subfield('9'),
}
# Other forms
@otherscript = map { {
- lang => $_->subfield('8') || '',
- term => $_->subfield('a'),
+ lang => length ($_->subfield('8')) == 6 ? substr ($_->subfield('8'), 3, 3) : $_->subfield('8') || '',
+ term => $_->subfield('a') . ($_->subfield('b') ? ', ' . $_->subfield('b') : ''),
direction => 'ltr',
field => $_->tag,
} } $record->field('7..');
$subfields_to_report = 'vxyz';
}
if ($subfields_to_report) {
- push @authorized, { heading => $field->as_string($subfields_to_report), field => $tag };
+ push @authorized, {
+ heading => $field->as_string($subfields_to_report),
+ hemain => $field->subfield( substr($subfields_to_report, 0, 1) ),
+ field => $tag,
+ };
} else {
- push @authorized, { heading => $field->as_string(), field => $tag };
+ push @authorized, {
+ heading => $field->as_string(),
+ hemain => $field->subfield('a'),
+ field => $tag,
+ };
}
}
foreach my $field ($record->field('4..')) { #See From
$type = 'earlier' if $type && $type ne 'n';
}
if ($type eq 'subfi') {
- push @seefrom, { heading => $field->as_string($marc21subfields), type => ($field->subfield('i') || ''), field => $field->tag() };
+ push @seefrom, {
+ heading => $field->as_string($marc21subfields),
+ hemain => $field->subfield( substr($marc21subfields, 0, 1) ),
+ type => ($field->subfield('i') || ''),
+ field => $field->tag(),
+ };
} else {
- push @seefrom, { heading => $field->as_string($marc21subfields), type => $type, field => $field->tag() };
+ push @seefrom, {
+ heading => $field->as_string($marc21subfields),
+ hemain => $field->subfield( substr($marc21subfields, 0, 1) ),
+ type => $type,
+ field => $field->tag(),
+ };
}
}
foreach my $field ($record->field('5..')) { #See Also
if ($type eq 'subfi') {
push @seealso, {
heading => $field->as_string($marc21subfields),
- type => $field->subfield('i'),
- field => $field->tag(),
- search => $field->as_string($marc21subfields) || '',
- authid => $field->subfield('9') || ''
+ hemain => $field->subfield( substr($marc21subfields, 0, 1) ),
+ type => $field->subfield('i'),
+ field => $field->tag(),
+ search => $field->as_string($marc21subfields) || '',
+ authid => $field->subfield('9') || ''
};
} else {
push @seealso, {
heading => $field->as_string($marc21subfields),
- type => $type,
- field => $field->tag(),
- search => $field->as_string($marc21subfields) || '',
- authid => $field->subfield('9') || ''
+ hemain => $field->subfield( substr($marc21subfields, 0, 1) ),
+ type => $type,
+ field => $field->tag(),
+ search => $field->as_string($marc21subfields) || '',
+ authid => $field->subfield('9') || ''
};
}
}
}
}
$summary{mainentry} = $authorized[0]->{heading};
+ $summary{mainmainentry} = $authorized[0]->{hemain};
$summary{authorized} = \@authorized;
$summary{notes} = \@notes;
$summary{seefrom} = \@seefrom;
my @reccache;
# search all biblio tags using this authority.
#Getting marcbiblios impacted by the change.
- if (C4::Context->preference('NoZebra')) {
- #nozebra way
- my $dbh=C4::Context->dbh;
- my $rq=$dbh->prepare(qq(SELECT biblionumbers from nozebra where indexname="an" and server="biblioserver" and value="$mergefrom" ));
- $rq->execute;
- while (my $biblionumbers=$rq->fetchrow){
- my @biblionumbers=split /;/,$biblionumbers;
- foreach (@biblionumbers) {
- if ($_=~/(\d+),.*/) {
- my $marc=GetMarcBiblio($1);
- push @reccache,$marc;
- }
- }
- }
- } else {
- #zebra connection
- my $oConnection=C4::Context->Zconn("biblioserver",0);
- # We used to use XML syntax here, but that no longer works.
- # Thankfully, we don't need it.
- my $query;
- $query= "an=".$mergefrom;
- my $oResult = $oConnection->search(new ZOOM::Query::CCL2RPN( $query, $oConnection ));
- my $count = 0;
- if ($oResult) {
- $count=$oResult->size();
- }
- my $z=0;
- while ( $z<$count ) {
- my $rec;
- $rec=$oResult->record($z);
- my $marcdata = $rec->raw();
- my $marcrecordzebra= MARC::Record->new_from_usmarc($marcdata);
- my ( $biblionumbertagfield, $biblionumbertagsubfield ) = &GetMarcFromKohaField( "biblio.biblionumber", '' );
- my $i = ($biblionumbertagfield < 10) ? $marcrecordzebra->field($biblionumbertagfield)->data : $marcrecordzebra->subfield($biblionumbertagfield, $biblionumbertagsubfield);
- my $marcrecorddb=GetMarcBiblio($i);
- push @reccache, $marcrecorddb;
- $z++;
- }
- $oResult->destroy();
+ #zebra connection
+ my $oConnection=C4::Context->Zconn("biblioserver",0);
+ # We used to use XML syntax here, but that no longer works.
+ # Thankfully, we don't need it.
+ my $query;
+ $query= "an=".$mergefrom;
+ my $oResult = $oConnection->search(new ZOOM::Query::CCL2RPN( $query, $oConnection ));
+ my $count = 0;
+ if ($oResult) {
+ $count=$oResult->size();
+ }
+ my $z=0;
+ while ( $z<$count ) {
+ my $rec;
+ $rec=$oResult->record($z);
+ my $marcdata = $rec->raw();
+ my $marcrecordzebra= MARC::Record->new_from_usmarc($marcdata);
+ my ( $biblionumbertagfield, $biblionumbertagsubfield ) = &GetMarcFromKohaField( "biblio.biblionumber", '' );
+ my $i = ($biblionumbertagfield < 10) ? $marcrecordzebra->field($biblionumbertagfield)->data : $marcrecordzebra->subfield($biblionumbertagfield, $biblionumbertagsubfield);
+ my $marcrecorddb=GetMarcBiblio($i);
+ push @reccache, $marcrecorddb;
+ $z++;
}
+ $oResult->destroy();
#warn scalar(@reccache)." biblios to update";
# Get All candidate Tags for the change
# (This will reduce the search scope in marc records).