use vars qw($VERSION @ISA @EXPORT);
# set the version for version checking
-$VERSION = do { my @v = '$Revision$' =~ /\d+/g; shift(@v).".".join( "_", map { sprintf "%03d", $_ } @v ); };
+$VERSION = 3.00;
@ISA = qw(Exporter);
@EXPORT = qw(
$n++;
}
if ($n>1){
- $query= "\@or ".$query;
+ while ($n>1){$query= "\@or ".$query;$n--;}
}
my $dosearch;
}#if value
}
##Add how many queries generated
- $query= $and.$query.$q2;
+ if ($query=~/\S+/){
+ $query= $and.$query.$q2
+ } else {
+ $query=$q2;
+ }
## Adding order
$query=' @or @attr 7=1 @attr 1=Heading 0 @or @attr 7=1 @attr 1=Heading-Entity 1'.$query if ($sortby eq "HeadingAsc");
$query=' @or @attr 7=2 @attr 1=Heading 0 @or @attr 7=1 @attr 1=Heading-Entity 1'.$query if ($sortby eq "HeadingDsc");
# check that authority exists
- $sth=$dbh->prepare("select count(*) from auth_tag_structure where authtypecode=?");
+ $sth=$dbh->prepare("SELECT count(*) FROM auth_tag_structure WHERE authtypecode=?");
$sth->execute($authtypecode);
my ($total) = $sth->fetchrow;
$authtypecode="" unless ($total >0);
($authid)=$sth->fetchrow;
$authid=$authid+1;
##Insert the recordID in MARC record
- ##Both authid and authtypecode is expected to be in the same field. Modify if other requirements arise
- $record->add_fields('001',$authid) unless $record->field('001');
+ unless ($record->field('001') && $record->field('001')->data() eq $authid){
+ $record->delete_field($record->field('001'));
+ $record->insert_fields_ordered(MARC::Field->new('001',$authid));
+ }
$record->add_fields('152','','','b'=>$authtypecode) unless $record->field('152');
# warn $record->as_formatted;
$dbh->do("lock tables auth_header WRITE");
$sth->finish;
}else{
$record->add_fields('001',$authid) unless ($record->field('001'));
- $record->add_fields('100',$authid) unless ($record->field('100'));
+ if (($format eq "UNIMARCAUTH") && (!$record->subfield('100','a'))){
+ $record->leader(" nx j22 ");
+ my $date=POSIX::strftime("%Y%m%d",localtime);
+ if ($record->field('100')){
+ $record->field('100')->update('a'=>$date."afrey50 ba0");
+ } else {
+ $record->append_fields(
+ MARC::Field->new('100',' ',' '
+ ,'a'=>$date."afrey50 ba0")
+ );
+ }
+ }
$record->add_fields('152','','','b'=>$authtypecode) unless ($record->field('152'));
$dbh->do("lock tables auth_header WRITE");
my $sth=$dbh->prepare("update auth_header set marc=?,marcxml=? where authid=?");
### they should have a system preference "dontmerge=1" otherwise by default biblios will be updated
### the $merge flag is now depreceated and will be removed at code cleaning
if (C4::Context->preference('dontmerge') ){
- # save the file in localfile/modified_authorities
+ # save the file in tmp/modified_authorities
my $cgidir = C4::Context->intranetdir ."/cgi-bin";
unless (opendir(DIR,"$cgidir")) {
$cgidir = C4::Context->intranetdir."/";
}
- my $filename = $cgidir."/localfile/modified_authorities/$authid.authid";
+ my $filename = $cgidir."/tmp/modified_authorities/$authid.authid";
open AUTH, "> $filename";
print AUTH $authid;
close AUTH;
my ($authtypecode) = @_;
my $dbh=C4::Context->dbh;
my $sth;
- if ($authtypecode){
+ if (defined $authtypecode){ # NOTE - in MARC21 framework, '' is a valid authority
+ # type
$sth=$dbh->prepare("select * from auth_types where authtypecode=?");
$sth->execute($authtypecode);
} else {
my @fields = $record->fields();
my $reported_tag;
# if the library has a summary defined, use it. Otherwise, build a standard one
- if ($summary) {
+ # FIXME - it appears that the summary field in the authority frameworks
+ # can work as a display template. However, this doesn't
+ # suit the MARC21 version, so for now the "templating"
+ # feature will be enabled only for UNIMARC for backwards
+ # compatibility.
+ if ($summary and C4::Context->preference('marcflavour') eq 'UNIMARC') {
my @fields = $record->fields();
# $reported_tag = '$9'.$result[$counter];
foreach my $field (@fields) {
$summary.= '<p><div class="label">'.$seeheading.'</div></p>' if ($seeheading);
} else {
# construct MARC21 summary
+ # FIXME - looping over 1XX is questionable
+ # since MARC21 authority should have only one 1XX
foreach my $field ($record->field('1..')) {
+ next if "152" eq $field->tag(); # FIXME - 152 is not a good tag to use
+ # in MARC21 -- purely local tags really ought to be
+ # 9XX
if ($record->field('100')) {
$heading.= $field->as_string('abcdefghjklmnopqrstvxyz68');
} elsif ($record->field('110')) {
}
} #See From
foreach my $field ($record->field('4..')) {
- $seeheading.= " ".$field->as_string()."<br />";
- $seeheading.= " <i>see:</i> ".$seeheading."<br />";
+ $seeheading.= "<br /> <i>used for/see from:</i> ".$field->as_string();
} #See Also
foreach my $field ($record->field('5..')) {
- $altheading.= " <i>see also:</i> ".$field->as_string()."<br />";
- $altheading.= " ".$field->as_string()."<br />";
- $altheading.= " <i>see also:</i> ".$altheading."<br />";
+ $altheading.= "<br /> <i>see also:</i> ".$field->as_string();
}
+ $summary .= ": " if $summary;
$summary.=$heading.$seeheading.$altheading;
}
}
=cut
-# $Id$
-# $Log$
# Revision 1.50 2007/07/26 15:14:05 toins
# removing warn compilation.
#