3 # LC_COLLATE=hr_HR.utf8 KOHA_CONF=/etc/koha/sites/ffzg/koha-conf.xml ./html.pl
9 use Data::Dump qw(dump);
13 use lib '/srv/koha_ffzg';
16 my $dbh = C4::Context->dbh;
20 my $sth_select_authors = $dbh->prepare(q{
23 ExtractValue(marcxml,'//datafield[@tag="100"]/subfield[@code="9"]') as first_author,
24 ExtractValue(marcxml,'//datafield[@tag="700"]/subfield[@code="9"]') as other_authors,
25 ExtractValue(marcxml,'//datafield[@tag="942"]/subfield[@code="t"]') as category
26 from biblioitems where agerestriction > 0
29 $sth_select_authors->execute();
30 while( my $row = $sth_select_authors->fetchrow_hashref ) {
32 my $all_authors = join(' ', $row->{first_author}, $row->{other_authors});
33 foreach my $authid ( split(/\s+/, $all_authors) ) {
34 push @{ $authors->{$authid}->{ $row->{category} } }, $row->{biblionumber};
41 my $all_authids = join(',', grep { length($_) > 0 } keys %$authors);
42 my $sth_auth = $dbh->prepare(q{
45 ExtractValue(marcxml,'//datafield[@tag="100"]/subfield[@code="a"]') as full_name
48 ExtractValue(marcxml,'//datafield[@tag="024"]/subfield[@code="a"]') <> '' and
49 authid in (} . $all_authids . q{)
53 while( my $row = $sth_auth->fetchrow_hashref ) {
55 $auth_header->{ $row->{authid} } = $row->{full_name};
63 <meta charset="UTF-8">
64 <title>|, join(" ", @_), qq|</title>
71 return qq|</body>\n</html\n|;
74 mkdir 'html' unless -d 'html';
76 open(my $index, '>:encoding(utf-8)', 'html/index.html');
77 print $index html_title('Bibliografija Filozogskog fakulteta');
81 foreach my $row ( sort { $a->{full_name} cmp $b->{full_name} } @authors ) {
83 my $first = substr( $row->{full_name}, 0, 1 );
84 if ( $first ne $first_letter ) {
85 print $index qq{</ul>\n} if $first_letter;
86 $first_letter = $first;
87 print $index qq{<h1>$first</h1>\n<ul>\n};
89 print $index qq{<li><a href="}, $row->{authid}, qq{.html">}, $row->{full_name}, "</a></li>\n";
91 open(my $fh, '>:encoding(utf-8)', "html/$row->{authid}.html");
92 print $fh html_title($row->{full_name}, "bibliografija");
93 foreach my $category ( sort keys %{ $authors->{ $row->{authid} } } ) {
94 print $fh qq|<h1>$category</h1>\n<ul>\n|;
95 foreach my $biblionumber ( @{ $authors->{ $row->{authid} }->{$category} } ) {
96 print $fh qq|<li><a href="https://koha.ffzg.hr/cgi-bin/koha/opac-detail.pl?biblionumber=$biblionumber">$biblionumber</a></li>\n|;
98 print $fh qq|</ul>\n|;
105 print $index html_end;
107 print dump( $authors );
109 print dump( $auth_header );