use utf8;
use JSON;
use POSIX qw(strftime);
+use Storable;
use lib '/srv/koha_ffzg';
use C4::Context;
}
debug 'auth_department' => $auth_department;
+store $auth_department, '/dev/shm/auth_department.storable';
debug 'auth_group' => $auth_group;
debug 'department_in_sum' => $department_in_sum;
=cut
my $biblio_year;
+my $biblio_full_name;
my $type_stats;
my $parser = XML::LibXML->new();
my $extract = {
'008' => undef,
'100' => '(9|a)',
+ '245' => 'a',
'680' => 'i',
'700' => '(9|4|a)',
'942' => '(t|r|v)'
foreach my $authid ( @first_author ) {
push @{ $authors->{$authid}->{aut}->{ $category } }, $row->{biblionumber};
}
+ $biblio_full_name->{ $row->{biblionumber} } = $data->{100}->[0]->{a};
} else {
$have_100 = 0;
}
+ $biblio_full_name->{ $row->{biblionumber} } ||= $data->{245}->[0]->{a};
+
my $have_edt;
if ( exists $data->{700} ) {
$type_stats->{$type}++;
- if ( $type =~ m/(edt|trl|com|ctb)/ ) {
- push @{ $authors->{$authid}->{sec}->{ $category } }, $row->{biblionumber};
- push @{ $authors->{$authid}->{$1}->{ $category } }, $row->{biblionumber};
- } elsif ( $type =~ m/aut/ ) {
- if ( ! $have_100 ) {
- $have_edt = grep { exists $_->{4} && $_->{4} =~ m/edt/ } @{ $data->{700} } if ! defined $have_edt;
- if ( $have_edt ) {
- $skip->{ have_700_edt }->{ $row->{biblionumber} }++;
+ my @types = split(/\s+/, $type);
+
+ foreach my $type ( @types ) {
+ $type_stats->{_count_each_type}->{$type}++;
+
+ if ( $type =~ m/(edt|trl|com|ctb)/ ) {
+ push @{ $authors->{$authid}->{sec}->{ $category } }, $row->{biblionumber};
+ push @{ $authors->{$authid}->{$type}->{ $category } }, $row->{biblionumber};
+ $type =~ s/(com|ctb)/_ostalo/;
+ push @{ $authors->{$authid}->{$type}->{ $category } }, $row->{biblionumber};
+
+ } elsif ( $type =~ m/aut/ ) {
+ if ( ! $have_100 ) {
+ $have_edt = grep { exists $_->{4} && $_->{4} =~ m/edt/ } @{ $data->{700} } if ! defined $have_edt;
+ if ( $have_edt ) {
+ $skip->{ have_700_edt }->{ $row->{biblionumber} }++;
+ } else {
+ push @{ $authors->{$authid}->{aut}->{ $category } }, $row->{biblionumber};
+ }
} else {
push @{ $authors->{$authid}->{aut}->{ $category } }, $row->{biblionumber};
}
} else {
- push @{ $authors->{$authid}->{aut}->{ $category } }, $row->{biblionumber};
+# warn "# SKIP ", $row->{biblionumber}, ' no 700$4 in ', dump($data);
+ $skip->{ 'no_700$4' }->{ $row->{biblionumber} }++;
}
- } else {
-# warn "# SKIP ", $row->{biblionumber}, ' no 700$4 in ', dump($data);
- $skip->{ 'no_700$4' }->{ $row->{biblionumber} }++;
}
}
delete $data->{700};
}
debug 'authors' => $authors;
+store $authors, '/dev/shm/authors.storable';
debug 'type_stats' => $type_stats;
debug 'skip' => $skip;
debug 'biblio_year' => $biblio_year;
+debug 'biblio_full_name' => $biblio_full_name;
debug 'biblio_data' => $biblio_data;
debug 'biblio_author_external' => $biblio_author_external;
my @v = @_;
my $u;
$u->{$_}++ foreach @v;
- return sort { $biblio_year->{$b} <=> $biblio_year->{$a} || $a <=> $b } keys %$u;
+ return sort {
+ $biblio_year->{$b} <=> $biblio_year->{$a} ||
+ $biblio_full_name->{$a} cmp $biblio_full_name->{$b} ||
+ $a <=> $b
+ } keys %$u;
}
sub author_html {
foreach my $category ( sort keys %{ $authors->{$authid}->{$type} } ) {
my $label = $category_label->{$category} || 'Bez kategorije';
- print $fh qq|<a name="$type-$category"><h3>$label</h3></a>\n<ul>\n|;
+ print $fh qq|<a name="$type-$category"><h3>$label</h3></a>\n<ol>\n|;
foreach my $biblionumber ( unique_biblionumber @{ $authors->{$authid}->{$type}->{$category} } ) {
print $fh li_biblio( $biblionumber );
}
- print $fh qq|</ul>\n|;
+ print $fh qq|</ol>\n|;
}
}
html_year_selection $fh => $row->{authid};
author_html( $fh, $row->{authid}, 'aut' => 'Primarno autorstvo' );
- author_html( $fh, $row->{authid}, 'sec' => 'Uredništva, prijevodi, krička izdanja' );
+ #author_html( $fh, $row->{authid}, 'sec' => 'Uredništva, prijevodi, kritička izdanja' );
+ author_html( $fh, $row->{authid}, 'edt' => 'Uredništva' );
+ author_html( $fh, $row->{authid}, 'trl' => 'Prijevodi' );
+ author_html( $fh, $row->{authid}, '_ostalo' => 'Ostalo' );
print $fh html_end;
close($fh);
next unless @biblionumber;
my $label = $category_label->{$category} || 'Bez kategorije';
- print $fh qq|<a name="$type-$category"><h3>$label</h3></a>\n<ul>\n|;
+ print $fh qq|<a name="$type-$category"><h3>$label</h3></a>\n<ol>\n|;
print $fh li_biblio( $_ ) foreach @biblionumber;
- print $fh qq|</ul>|;
+ print $fh qq|</ol>|;
}
}
mkdir 'html/departments' unless -d 'html/departments';
open(my $dep_fh, '>:encoding(utf-8)', 'html/departments/index.new');
-print $dep_fh html_title('Odsijeci Filozofskog fakulteta u Zagrebu'), qq|<ul>\n|;
+print $dep_fh html_title('Odsjeci Filozofskog fakulteta u Zagrebu'), qq|<ul>\n|;
foreach my $department ( sort keys %$department_category_author ) {
my $dep = $department || 'Nema odsjeka';
my $dep_file = unac_string('utf-8',$dep);
department_html( $fh, $department, 'aut', 'Primarno autorstvo' );
- department_html( $fh, $department, 'sec', 'Sekundarno autorstvo' );
+# department_html( $fh, $department, 'sec', 'Sekundarno autorstvo' );
+ department_html( $fh, $department, 'edt', 'Uredništva' );
+ department_html( $fh, $department, 'trl', 'Prijevodi' );
+ department_html( $fh, $department, '_ostalo', 'Ostalo' );
print $fh html_end;
close($fh);