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';
25 my $sth_select_authors = $dbh->prepare(q{
28 ExtractValue(marcxml,'//datafield[@tag="100"]/subfield[@code="9"]') as first_author,
29 ExtractValue(marcxml,'//datafield[@tag="700"]/subfield[@code="9"]') as other_authors,
30 ExtractValue(marcxml,'//datafield[@tag="942"]/subfield[@code="t"]') as category,
35 and SUBSTR(ExtractValue(marcxml,'//controlfield[@tag="008"]'),8,4) between 2008 and 2013
36 order by SUBSTR(ExtractValue(marcxml,'//controlfield[@tag="008"]'),8,4) desc
39 $sth_select_authors->execute();
40 while( my $row = $sth_select_authors->fetchrow_hashref ) {
42 my $all_authors = join(' ', $row->{first_author}, $row->{other_authors});
43 foreach my $authid ( split(/\s+/, $all_authors) ) {
44 push @{ $authors->{$authid}->{ $row->{category} } }, $row->{biblionumber};
45 $marcxml->{ $row->{biblionumber} } = $row->{marcxml};
52 my $all_authids = join(',', grep { length($_) > 0 } keys %$authors);
53 my $sth_auth = $dbh->prepare(q{
56 ExtractValue(marcxml,'//datafield[@tag="100"]/subfield[@code="a"]') as full_name
59 ExtractValue(marcxml,'//datafield[@tag="024"]/subfield[@code="a"]') <> '' and
60 authid in (} . $all_authids . q{)
64 while( my $row = $sth_auth->fetchrow_hashref ) {
66 $auth_header->{ $row->{authid} } = $row->{full_name};
72 my $sth_categories = $dbh->prepare(q{
73 select authorised_value, lib from authorised_values where category = 'BIBCAT'
75 $sth_categories->execute();
76 while( my $row = $sth_categories->fetchrow_hashref ) {
77 $category_label->{ $row->{authorised_value} } = $row->{lib};
80 warn dump( $category_label );
85 <meta charset="UTF-8">
86 <title>|, join(" ", @_), qq|</title>
87 <link href="style.css" type="text/css" rel="stylesheet" />
94 return qq|</body>\n</html\n|;
99 my $biblionumber = shift;
101 my $xmlrecord = $marcxml->{$biblionumber} || die "missing $biblionumber marcxml";
103 my $parser = XML::LibXML->new();
104 $parser->recover_silently(0); # don't die when you find &, >, etc
105 my $source = $parser->parse_string($xmlrecord);
106 my $style_doc = $parser->parse_file($xslfilename);
108 my $xslt = XML::LibXSLT->new();
109 my $parsed = $xslt->parse_stylesheet($style_doc);
110 my $transformed = $parsed->transform($source);
111 return $parsed->output_string( $transformed );
115 mkdir 'html' unless -d 'html';
117 open(my $index, '>:encoding(utf-8)', 'html/index.html');
118 print $index html_title('Bibliografija Filozogskog fakulteta');
122 foreach my $row ( sort { $a->{full_name} cmp $b->{full_name} } @authors ) {
124 my $first = substr( $row->{full_name}, 0, 1 );
125 if ( $first ne $first_letter ) {
126 print $index qq{</ul>\n} if $first_letter;
127 $first_letter = $first;
128 print $index qq{<h1>$first</h1>\n<ul>\n};
130 print $index qq{<li><a href="}, $row->{authid}, qq{.html">}, $row->{full_name}, "</a></li>\n";
132 open(my $fh, '>:encoding(utf-8)', "html/$row->{authid}.html");
133 print $fh html_title($row->{full_name}, "bibliografija");
134 foreach my $category ( sort keys %{ $authors->{ $row->{authid} } } ) {
135 my $label = $category_label->{$category} || 'Bez kategorije';
136 print $fh qq|<h1>$label</h1>\n<ul>\n|;
137 foreach my $biblionumber ( @{ $authors->{ $row->{authid} }->{$category} } ) {
138 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|;
140 print $fh qq|</ul>\n|;
147 print $index html_end;
149 print dump( $authors );
151 print dump( $auth_header );