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';
18 my $dbh = C4::Context->dbh;
20 my $xslfilename = 'compact.xsl';
24 my $sth_select_authors = $dbh->prepare(q{
27 ExtractValue(marcxml,'//datafield[@tag="100"]/subfield[@code="9"]') as first_author,
28 ExtractValue(marcxml,'//datafield[@tag="700"]/subfield[@code="9"]') as other_authors,
29 ExtractValue(marcxml,'//datafield[@tag="942"]/subfield[@code="t"]') as category
30 from biblioitems where agerestriction > 0
33 $sth_select_authors->execute();
34 while( my $row = $sth_select_authors->fetchrow_hashref ) {
36 my $all_authors = join(' ', $row->{first_author}, $row->{other_authors});
37 foreach my $authid ( split(/\s+/, $all_authors) ) {
38 push @{ $authors->{$authid}->{ $row->{category} } }, $row->{biblionumber};
45 my $all_authids = join(',', grep { length($_) > 0 } keys %$authors);
46 my $sth_auth = $dbh->prepare(q{
49 ExtractValue(marcxml,'//datafield[@tag="100"]/subfield[@code="a"]') as full_name
52 ExtractValue(marcxml,'//datafield[@tag="024"]/subfield[@code="a"]') <> '' and
53 authid in (} . $all_authids . q{)
57 while( my $row = $sth_auth->fetchrow_hashref ) {
59 $auth_header->{ $row->{authid} } = $row->{full_name};
67 <meta charset="UTF-8">
68 <title>|, join(" ", @_), qq|</title>
69 <link href="style.css" type="text/css" rel="stylesheet" />
76 return qq|</body>\n</html\n|;
80 my $sth_marcxml = $dbh->prepare(q{
81 select marcxml from biblioitems where biblionumber = ?
85 my $biblionumber = shift;
87 $sth_marcxml->execute( $biblionumber );
88 my $xmlrecord = $sth_marcxml->fetchrow_arrayref->[0];
90 my $parser = XML::LibXML->new();
91 $parser->recover_silently(0); # don't die when you find &, >, etc
92 my $source = $parser->parse_string($xmlrecord);
93 my $style_doc = $parser->parse_file($xslfilename);
95 my $xslt = XML::LibXSLT->new();
96 my $parsed = $xslt->parse_stylesheet($style_doc);
97 my $transformed = $parsed->transform($source);
98 return $parsed->output_string( $transformed );
102 mkdir 'html' unless -d 'html';
104 open(my $index, '>:encoding(utf-8)', 'html/index.html');
105 print $index html_title('Bibliografija Filozogskog fakulteta');
109 foreach my $row ( sort { $a->{full_name} cmp $b->{full_name} } @authors ) {
111 my $first = substr( $row->{full_name}, 0, 1 );
112 if ( $first ne $first_letter ) {
113 print $index qq{</ul>\n} if $first_letter;
114 $first_letter = $first;
115 print $index qq{<h1>$first</h1>\n<ul>\n};
117 print $index qq{<li><a href="}, $row->{authid}, qq{.html">}, $row->{full_name}, "</a></li>\n";
119 open(my $fh, '>:encoding(utf-8)', "html/$row->{authid}.html");
120 print $fh html_title($row->{full_name}, "bibliografija");
121 foreach my $category ( sort keys %{ $authors->{ $row->{authid} } } ) {
122 print $fh qq|<h1>$category</h1>\n<ul>\n|;
123 foreach my $biblionumber ( @{ $authors->{ $row->{authid} }->{$category} } ) {
124 print $fh qq|<li><a href="https://koha.ffzg.hr/cgi-bin/koha/opac-detail.pl?biblionumber=$biblionumber">$biblionumber</a>|, biblioitem_html($biblionumber), qq|</li>\n|;
126 print $fh qq|</ul>\n|;
133 print $index html_end;
135 print dump( $authors );
137 print dump( $auth_header );