use vars qw($VERSION @ISA @EXPORT);
# set the version for version checking
-$VERSION = 0.01;
+$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");
=back
=cut
+
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");
- return scalar split /;/,$result;
+ my @tab = split /;/,$result;
+ return scalar @tab;
} else {
### ZOOM search here
my $oConnection=C4::Context->Zconn("biblioserver",1);
# 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);
$sth= $dbh->prepare(
-"SELECT tagfield,liblibrarian,libopac,mandatory,repeatable
+"SELECT auth_tag_structure.tagfield,auth_tag_structure.liblibrarian,auth_tag_structure.libopac,auth_tag_structure.mandatory,auth_tag_structure.repeatable
FROM auth_tag_structure
WHERE authtypecode=?
ORDER BY tagfield"
$res->{$tag}->{repeatable} = $repeatable;
}
$sth= $dbh->prepare(
-"SELECT tagfield,tagsubfield,liblibrarian,libopac,tab, mandatory, repeatable,authorised_value,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
FROM auth_subfield_structure
WHERE authtypecode=?
ORDER BY tagfield,tagsubfield"
my $leader=' a ';##Fixme correct leader as this one just adds utf8 to MARC21
# if authid empty => true add, find a new authid number
+ my $format= 'UNIMARCAUTH' if (uc(C4::Context->preference('marcflavour')) eq 'UNIMARC');
+ $format= 'MARC21' if (uc(C4::Context->preference('marcflavour')) ne 'UNIMARC');
if (!$authid) {
my $sth=$dbh->prepare("select max(authid) from auth_header");
$sth->execute;
# warn $record->as_formatted;
$dbh->do("lock tables auth_header WRITE");
$sth=$dbh->prepare("insert into auth_header (authid,datecreated,authtypecode,marc,marcxml) values (?,now(),?,?,?)");
- $sth->execute($authid,$authtypecode,$record->as_usmarc,$record->as_xml_record);
+ $sth->execute($authid,$authtypecode,$record->as_usmarc,$record->as_xml_record($format));
$sth->finish;
}else{
$record->add_fields('001',$authid) unless ($record->field('001'));
$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=?");
- $sth->execute($record->as_usmarc,$record->as_xml_record,$authid);
+ $sth->execute($record->as_usmarc,$record->as_xml_record($format),$authid);
$sth->finish;
}
$dbh->do("unlock tables");
### 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 $dbh=C4::Context->dbh;
my $authref = GetAuthType($authtypecode);
my $summary = $authref->{summary};
+ my %language;
+ $language{'fre'}="Français";
+ $language{'eng'}="Anglais";
+ $language{'ger'}="Allemand";
+ $language{'ita'}="Italien";
+ $language{'spa'}="Espagnol";
+ my %thesaurus;
+ $thesaurus{'1'}="Peuples";
+ $thesaurus{'2'}="Anthroponymes";
+ $thesaurus{'3'}="Oeuvres";
+ $thesaurus{'4'}="Chronologie";
+ $thesaurus{'5'}="Lieux";
+ $thesaurus{'6'}="Sujets";
+ #thesaurus a remplir
my @fields = $record->fields();
my $reported_tag;
# if the library has a summary defined, use it. Otherwise, build a standard one
}
$summary =~ s/\[(.*?)]//g;
$summary =~ s/\n/<br>/g;
- } else {
- my $heading; # = $authref->{summary};
- my $altheading;
- my $seeheading;
- my $see;
- my @fields = $record->fields();
- if (C4::Context->preference('marcflavour') eq 'UNIMARC') {
- # construct UNIMARC summary, that is quite different from MARC21 one
- # accepted form
- foreach my $field ($record->field('2..')) {
- $heading.= $field->as_string();
- }
- # rejected form(s)
- foreach my $field ($record->field('4..')) {
- $summary.= " <i>".$field->as_string()."</i><br/>";
- $summary.= " <i>see:</i> ".$heading."<br/>";
- }
- # see :
- foreach my $field ($record->field('5..')) {
- $summary.= " <i>".$field->as_string()."</i><br/>";
- $summary.= " <i>see:</i> ".$heading."<br/>";
- }
- # // form
- foreach my $field ($record->field('7..')) {
- $seeheading.= " <i>see also:</i> ".$field->as_string()."<br />";
- $altheading.= " ".$field->as_string()."<br />";
- $altheading.= " <i>see also:</i> ".$heading."<br />";
- }
- $summary = "<b>".$heading."</b><br />".$seeheading.$altheading.$summary;
+ } else {
+ my $heading;
+ my $authid;
+ my $altheading;
+ my $seealso;
+ my $broaderterms;
+ my $narrowerterms;
+ my $see;
+ my $seeheading;
+ my $notes;
+ my @fields = $record->fields();
+ if (C4::Context->preference('marcflavour') eq 'UNIMARC') {
+ # construct UNIMARC summary, that is quite different from MARC21 one
+ # accepted form
+ foreach my $field ($record->field('2..')) {
+ $heading.= $field->subfield('a');
+ $authid=$field->subfield('3');
+ }
+ # rejected form(s)
+ foreach my $field ($record->field('3..')) {
+ $notes.= '<span class="note">'.$field->subfield('a')."</span>\n";
+ }
+ foreach my $field ($record->field('4..')) {
+ my $thesaurus = "thes. : ".$thesaurus{"$field->subfield('2')"}." : " if ($field->subfield('2'));
+ $see.= '<span class="UF">'.$thesaurus.$field->subfield('a')."</span> -- \n";
+ }
+ # see :
+ foreach my $field ($record->field('5..')) {
+
+ if (($field->subfield('5')) && ($field->subfield('a')) && ($field->subfield('5') eq 'g')) {
+ $broaderterms.= '<span class="BT"> <a href="detail.pl?authid='.$field->subfield('3').'">'.$field->subfield('a')."</a></span> -- \n";
+ } elsif (($field->subfield('5')) && ($field->subfield('a')) && ($field->subfield('5') eq 'h')){
+ $narrowerterms.= '<span class="NT"><a href="detail.pl?authid='.$field->subfield('3').'">'.$field->subfield('a')."</a></span> -- \n";
+ } elsif ($field->subfield('a')) {
+ $seealso.= '<span class="RT"><a href="detail.pl?authid='.$field->subfield('3').'">'.$field->subfield('a')."</a></span> -- \n";
+ }
+ }
+ # // form
+ foreach my $field ($record->field('7..')) {
+ my $lang = substr($field->subfield('8'),3,3);
+ $seeheading.= '<span class="langue"> En '.$language{$lang}.' : </span><span class="OT"> '.$field->subfield('a')."</span><br />\n";
+ }
+ $broaderterms =~s/-- \n$//;
+ $narrowerterms =~s/-- \n$//;
+ $seealso =~s/-- \n$//;
+ $see =~s/-- \n$//;
+ $summary = "<b><a href=\"detail.pl?authid=$authid\">".$heading."</a></b><br />".($notes?"$notes <br />":"");
+ $summary.= '<p><div class="label">TG : '.$broaderterms.'</div></p>' if ($broaderterms);
+ $summary.= '<p><div class="label">TS : '.$narrowerterms.'</div></p>' if ($narrowerterms);
+ $summary.= '<p><div class="label">TA : '.$seealso.'</div></p>' if ($seealso);
+ $summary.= '<p><div class="label">EP : '.$see.'</div></p>' if ($see);
+ $summary.= '<p><div class="label">'.$seeheading.'</div></p>' if ($seeheading);
} else {
# construct MARC21 summary
foreach my $field ($record->field('1..')) {
}
$summary.=$heading.$seeheading.$altheading;
}
- }
-return $summary;
+ }
+ return $summary;
}
=head2 BuildUnimarcHierarchies
=cut
-# $Id$
-# $Log$
+# Revision 1.50 2007/07/26 15:14:05 toins
+# removing warn compilation.
+#
+# Revision 1.49 2007/07/16 15:45:28 hdl
+# Adding Summary for UNIMARC authorities
+#
# Revision 1.48 2007/06/25 15:01:45 tipaul
# bugfixes on unimarc 100 handling (the field used for encoding)
#