X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=html.pl;h=8f246ea351c45406caca9642917b41ca412175ae;hb=6f739ea5d041badf4c86ef58ea5ff65726d0cc83;hp=80d3cc15045c5e1938b007629e7787e5c86e5ab0;hpb=c512cb23ab9074fae1b74ff32872c9593353f467;p=koha-bibliografija diff --git a/html.pl b/html.pl index 80d3cc1..8f246ea 100755 --- a/html.pl +++ b/html.pl @@ -54,7 +54,6 @@ debug 'auth_department' => $auth_department; my $authors; -my $author_count; my $marcxml; my $sth_select_authors = $dbh->prepare(q{ @@ -100,7 +99,7 @@ sub biblioitem_html { my $source = eval { $parser->parse_string($xmlrecord) }; if ( $@ ) { - warn "SKIP $biblionumber corrupt XML"; +# warn "SKIP $biblionumber corrupt XML"; push @{ $skip->{XML_corrupt} }, $biblionumber; return; } @@ -173,7 +172,7 @@ while( my $row = $sth_select_authors->fetchrow_hashref ) { my $category = $data->{942}->[0]->{'t'}; if ( ! $category ) { - warn "# SKIP ", $row->{biblionumber}, " no category in ", dump($data); +# warn "# SKIP ", $row->{biblionumber}, " no category in ", dump($data); push @{ $skip->{no_category} }, $row->{biblionumber}; next; } @@ -182,8 +181,7 @@ while( my $row = $sth_select_authors->fetchrow_hashref ) { if ( exists $data->{100} ) { my @first_author = map { $_->{'9'} } @{ $data->{100} }; foreach my $authid ( @first_author ) { - push @{ $authors->{$authid}->{ $category } }, $row->{biblionumber}; - $author_count->{aut}->{$authid}++; + push @{ $authors->{$authid}->{aut}->{ $category } }, $row->{biblionumber}; } } @@ -194,13 +192,12 @@ while( my $row = $sth_select_authors->fetchrow_hashref ) { $type_stats->{$type}++; - push @{ $authors->{$authid}->{ $category } }, $row->{biblionumber}; if ( $type =~ m/aut/ ) { - $author_count->{aut}->{ $authid }++; - } elsif ( $type =~ m/(edt|tr)/ ) { - $author_count->{$1}->{ $authid }++; + push @{ $authors->{$authid}->{aut}->{ $category } }, $row->{biblionumber}; + } elsif ( $type =~ m/(edt|trl|com|ctb)/ ) { + push @{ $authors->{$authid}->{sec}->{ $category } }, $row->{biblionumber}; } else { - warn "# SKIP ", $row->{biblionumber}, ' no 700$4 in ', dump($data); +# warn "# SKIP ", $row->{biblionumber}, ' no 700$4 in ', dump($data); push @{ $skip->{ 'no_700$4' } }, $row->{biblionumber}; } } @@ -209,7 +206,6 @@ while( my $row = $sth_select_authors->fetchrow_hashref ) { } debug 'authors' => $authors; -debug 'author_count' => $author_count; debug 'type_stats' => $type_stats; my $category_label; @@ -247,6 +243,27 @@ my $first_letter = ''; debug 'authors' => \@authors; +sub author_html { + my ( $fh, $authid, $type, $label ) = @_; + + return unless exists $authors->{$authid}->{$type}; + + print $fh qq|

$label

\n|; + + foreach my $category ( sort keys %{ $authors->{$authid}->{$type} } ) { + my $label = $category_label->{$category} || 'Bez kategorije'; + print $fh qq|

$label

\n\n|; + } +} + foreach my $row ( sort { $a->{full_name} cmp $b->{full_name} } @authors ) { my $first = substr( $row->{full_name}, 0, 1 ); @@ -261,18 +278,10 @@ foreach my $row ( sort { $a->{full_name} cmp $b->{full_name} } @authors ) { open(my $fh, '>:encoding(utf-8)', "$path.new"); print $fh html_title($row->{full_name}, "bibliografija"); print $fh qq|

$row->{full_name} - bibliografija za razdoblje 2008-2013

|; - foreach my $category ( sort keys %{ $authors->{ $row->{authid} } } ) { - my $label = $category_label->{$category} || 'Bez kategorije'; - print $fh qq|

$label

\n\n|; - } + + author_html( $fh, $row->{authid}, 'aut' => 'Primarno autorstvo' ); + author_html( $fh, $row->{authid}, 'sec' => 'Sekundarno autorstvo' ); + print $fh html_end; close($fh); rename "$path.new", "$path.html";