From 9137baa7c7f5e36827044853142c0ce1f26bb40d Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Thu, 14 Nov 2013 15:19:05 +0100 Subject: [PATCH] first naive implementation of authors list and biblios --- html.pl | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100755 html.pl diff --git a/html.pl b/html.pl new file mode 100755 index 0000000..7c6d3c8 --- /dev/null +++ b/html.pl @@ -0,0 +1,110 @@ +#!/usr/bin/perl + +# LC_COLLATE=hr_HR.utf8 KOHA_CONF=/etc/koha/sites/ffzg/koha-conf.xml ./html.pl + +use warnings; +use strict; + +use DBI; +use Data::Dump qw(dump); +use autodie; +use locale; + +use lib '/srv/koha_ffzg'; +use C4::Context; + +my $dbh = C4::Context->dbh; + +my $authors; + +my $sth_select_authors = $dbh->prepare(q{ +select + biblionumber, + ExtractValue(marcxml,'//datafield[@tag="100"]/subfield[@code="9"]') as first_author, + ExtractValue(marcxml,'//datafield[@tag="700"]/subfield[@code="9"]') as other_authors, + ExtractValue(marcxml,'//datafield[@tag="942"]/subfield[@code="t"]') as category +from biblioitems where agerestriction > 0 +}); + +$sth_select_authors->execute(); +while( my $row = $sth_select_authors->fetchrow_hashref ) { +# warn dump($row),$/; + my $all_authors = join(' ', $row->{first_author}, $row->{other_authors}); + foreach my $authid ( split(/\s+/, $all_authors) ) { + push @{ $authors->{$authid}->{ $row->{category} } }, $row->{biblionumber}; + } +} + +my $auth_header; +my @authors; + +my $all_authids = join(',', grep { length($_) > 0 } keys %$authors); +my $sth_auth = $dbh->prepare(q{ +select + authid, + ExtractValue(marcxml,'//datafield[@tag="100"]/subfield[@code="a"]') as full_name +from auth_header +where + ExtractValue(marcxml,'//datafield[@tag="024"]/subfield[@code="a"]') <> '' and + authid in (} . $all_authids . q{) +}); + +$sth_auth->execute(); +while( my $row = $sth_auth->fetchrow_hashref ) { + warn dump( $row ); + $auth_header->{ $row->{authid} } = $row->{full_name}; + push @authors, $row; + +} + +sub html_title { + return qq| + + +|, join(" ", @_), qq| + + +|; +} + +sub html_end { + return qq|\n:encoding(utf-8)', 'html/index.html'); +print $index html_title('Bibliografija Filozogskog fakulteta'); + +my $first_letter; + +foreach my $row ( sort { $a->{full_name} cmp $b->{full_name} } @authors ) { + + my $first = substr( $row->{full_name}, 0, 1 ); + if ( $first ne $first_letter ) { + print $index qq{\n} if $first_letter; + $first_letter = $first; + print $index qq{

$first

\n