X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=html.pl;h=cc7089cde1726d2d4ce1056b4567b95c785d54b2;hb=ecddab314838f4d90e959753acf934d9f27cd8c6;hp=cb76f145f60630cf72dad4fb612e3ebbd41d2e75;hpb=4d179b347d0fd811891bb675bd56f7772e3c88e7;p=koha-bibliografija
diff --git a/html.pl b/html.pl
index cb76f14..cc7089c 100755
--- a/html.pl
+++ b/html.pl
@@ -311,23 +311,33 @@ while( my $row = $sth_select_authors->fetchrow_hashref ) {
$type_stats->{$type}++;
- if ( $type =~ m/(edt|trl|com|ctb)/ ) {
- push @{ $authors->{$authid}->{sec}->{ $category } }, $row->{biblionumber};
- push @{ $authors->{$authid}->{$1}->{ $category } }, $row->{biblionumber};
- } elsif ( $type =~ m/aut/ ) {
- if ( ! $have_100 ) {
- $have_edt = grep { exists $_->{4} && $_->{4} =~ m/edt/ } @{ $data->{700} } if ! defined $have_edt;
- if ( $have_edt ) {
- $skip->{ have_700_edt }->{ $row->{biblionumber} }++;
+ my @types = split(/[\s\/]+/, $type);
+
+ foreach my $type ( @types ) {
+ my $type = substr($type,0,3);
+ $type_stats->{_count_each_type}->{$type}++;
+
+ if ( $type =~ m/(edt|trl|com|ctb)/ ) {
+ push @{ $authors->{$authid}->{__sec}->{ $category } }, $row->{biblionumber};
+ push @{ $authors->{$authid}->{$type}->{ $category } }, $row->{biblionumber};
+ $type =~ s/(com|ctb)/_ostalo/;
+ push @{ $authors->{$authid}->{$type}->{ $category } }, $row->{biblionumber};
+
+ } elsif ( $type =~ m/aut/ ) {
+ if ( ! $have_100 ) {
+ $have_edt = grep { exists $_->{4} && $_->{4} =~ m/edt/ } @{ $data->{700} } if ! defined $have_edt;
+ if ( $have_edt ) {
+ $skip->{ have_700_edt }->{ $row->{biblionumber} }++;
+ } else {
+ push @{ $authors->{$authid}->{aut}->{ $category } }, $row->{biblionumber};
+ }
} else {
push @{ $authors->{$authid}->{aut}->{ $category } }, $row->{biblionumber};
}
} else {
- push @{ $authors->{$authid}->{aut}->{ $category } }, $row->{biblionumber};
+# warn "# SKIP ", $row->{biblionumber}, ' no 700$4 in ', dump($data);
+ $skip->{ 'no_700$4' }->{ $row->{biblionumber} }++;
}
- } else {
-# warn "# SKIP ", $row->{biblionumber}, ' no 700$4 in ', dump($data);
- $skip->{ 'no_700$4' }->{ $row->{biblionumber} }++;
}
}
delete $data->{700};
@@ -364,6 +374,7 @@ sub html_title {
|, join(" ", @_), qq|
+
|;
@@ -410,7 +421,7 @@ sub author_html {
return unless exists $authors->{$authid}->{$type};
- print $fh qq|$label
\n|;
+ print $fh qq|$label
\n|;
foreach my $category ( sort keys %{ $authors->{$authid}->{$type} } ) {
my $label = $category_label->{$category} || 'Bez kategorije';
@@ -422,13 +433,21 @@ sub author_html {
}
}
+my @toc_type_label = (
+'aut' => 'Primarno autorstvo',
+'edt' => 'Uredništva',
+'trl' => 'Prijevodi',
+'_ostalo' => 'Ostalo',
+);
+
sub count_author_years {
my $years = shift;
my ($authid) = @_;
foreach my $type ( keys %{ $authors->{$authid} } ) {
+ next if $type =~ m/^_/;
foreach my $category ( keys %{ $authors->{$authid}->{$type} } ) {
- foreach my $biblionumber ( @{ $authors->{$authid}->{$type}->{$category} } ) {
+ foreach my $biblionumber ( unique_biblionumber @{ $authors->{$authid}->{$type}->{$category} } ) {
$years->{ $biblio_year->{ $biblionumber } }->{ $type . '-' . $category }++;
}
}
@@ -440,6 +459,8 @@ sub html_year_selection {
my $fh = shift;
my @authids = @_;
+ debug 'html_year_selection authids=', [ @authids ];
+
print $fh qq|Godine:\n|;
my $type_cat_count = {};
my $years;
@@ -448,10 +469,15 @@ sub html_year_selection {
$years = count_author_years( $years, $authid );
}
+ debug 'years' => $years;
+
foreach my $year ( sort { $b <=> $a } keys %$years ) {
print $fh qq| \n|;
foreach my $type_cat ( keys %{ $years->{$year} } ) {
$type_cat_count->{ $type_cat } += $years->{$year}->{$type_cat};
+ my ($type,$cat) = split(/-/, $type_cat);
+ $type_cat_count->{_toc}->{$type}->{$cat}++;
+ $type_cat_count->{_toc_count}->{$type} += $years->{$year}->{$type_cat};
}
}
@@ -469,65 +495,33 @@ var years = |, encode_json($years), q|;
var type_cat_count = |, encode_json($type_cat_count), q|;
-function year_show(year) {
- $('.y'+year).show();
- console.debug('show', year);
- for(var type_cat in years[year]) {
- if ( ( type_cat_count[ type_cat ] += years[year][type_cat] ) == years[year][type_cat]) {
- $('a[name="'+type_cat+'"]').show();
- console.debug(type_cat, 'show');
- }
- }
-}
+
-function year_hide(year) {
- $('.y'+year).hide();
- console.debug('hide', year);
- for(var type_cat in years[year]) {
- if ( ( type_cat_count[ type_cat ] -= years[year][type_cat] ) == 0 ) {
- $('a[name="'+type_cat+'"]').hide();
- console.debug(type_cat, 'hide');
- }
- }
-}
+ |;
-function toggle_year(year, el) {
- if ( el.checked ) {
- year_show(year);
- } else {
- year_hide(year);
+ debug 'type_cat_count' => $type_cat_count;
+
+ # TOC
+ print $fh qq|\n|;
+ my $i = 0;
+ while ( $i < $#toc_type_label ) {
+ my $type = $toc_type_label[$i++] || die "type";
+ my $label = $toc_type_label[$i++] || die "label";
+ next unless exists $type_cat_count->{_toc}->{$type};
+ print $fh qq| - $label $type_cat_count->{_toc_count}->{$type}
\n \n|;
+ foreach my $category ( sort keys %{ $type_cat_count->{_toc}->{$type} } ) {
+ my $label = $category_label->{$category} || 'Bez kategorije';
+ my $count = $type_cat_count->{ $type . '-' . $category };
+ my $cat_html = $category;
+ $cat_html =~ s/\./-/g;
+ print $fh qq| - $label $count
\n|;
+ }
+ print $fh qq|
\n|;
}
-}
+ print $fh qq|
\n|;
-function all_years( turn_on ) {
- $('input[name=year_selection]').each( function(i,el) {
- if ( turn_on ) {
- if ( ! el.checked ) {
- el.checked = true;
- year_show( el.value );
- }
- } else {
- if ( el.checked ) {
- el.checked = false;
- year_hide( el.value );
- }
- }
- } );
}
-$(document).ready( function() {
- console.info('ready');
-
- $('input[name=year_selection]').each( function(i, el) {
- var year = el.value;
- console.debug( 'on load', year, el.checked );
- if (! el.checked) year_hide(year);
- });
-
-});
-
- |;
-}
foreach my $row ( sort { $a->{full_name} cmp $b->{full_name} } @authors ) {
@@ -546,8 +540,12 @@ foreach my $row ( sort { $a->{full_name} cmp $b->{full_name} } @authors ) {
html_year_selection $fh => $row->{authid};
- author_html( $fh, $row->{authid}, 'aut' => 'Primarno autorstvo' );
- author_html( $fh, $row->{authid}, 'sec' => 'UredniÅ¡tva, prijevodi, kritiÄka izdanja' );
+ my $i = 0;
+ while ( $i < $#toc_type_label ) {
+ my $type = $toc_type_label[$i++] || die "type";
+ my $label = $toc_type_label[$i++] || die "label";
+ author_html( $fh, $row->{authid}, $type => $label );
+ }
print $fh html_end;
close($fh);
@@ -566,7 +564,7 @@ my $department_category_author;
foreach my $department ( sort keys %$auth_department ) {
foreach my $authid ( sort @{ $auth_department->{$department} } ) {
my @categories = keys %{ $authors->{$authid}->{aut} };
- push @categories, keys %{ $authors->{$authid}->{sec} };
+ push @categories, keys %{ $authors->{$authid}->{__sec} };
foreach my $category ( sort @categories ) {
push @{ $department_category_author->{$department}->{$category} }, $authid;
push @{ $department_category_author->{'AAA_ukupno'}->{$category} }, $authid if $department_in_sum->{$department};
@@ -585,7 +583,7 @@ debug 'department_category_author' => $department_category_author;
sub department_html {
my ( $fh, $department, $type, $label ) = @_;
- print $fh qq|$label
\n|;
+ print $fh qq|$label
\n|;
foreach my $category ( sort keys %{ $department_category_author->{$department} } ) {
@@ -626,9 +624,12 @@ foreach my $department ( sort keys %$department_category_author ) {
}
html_year_selection $fh => @authids;
- department_html( $fh, $department, 'aut', 'Primarno autorstvo' );
-
- department_html( $fh, $department, 'sec', 'Sekundarno autorstvo' );
+ my $i = 0;
+ while ( $i < $#toc_type_label ) {
+ my $type = $toc_type_label[$i++] || die "type";
+ my $label = $toc_type_label[$i++] || die "label";
+ department_html( $fh, $department, $type, $label );
+ }
print $fh html_end;
close($fh);