From 538a0b15a314aea0b5efcc830a37ec36c30b4029 Mon Sep 17 00:00:00 2001 From: tipaul Date: Wed, 18 Aug 2004 16:05:42 +0000 Subject: [PATCH] fixes in authorities. Now, it should work well... --- authorities/auth_finder.pl | 25 ++- authorities/authorities-home.pl | 2 +- authorities/authorities.pl | 2 +- authorities/blinddetail-biblio-search.pl | 135 ++++----------- .../default/en/authorities/auth_finder.tmpl | 7 +- .../blinddetail-biblio-search.tmpl | 46 +++-- .../en/authorities/searchresultlist-auth.tmpl | 158 ++++++++++-------- .../en/authorities/searchresultlist.tmpl | 24 ++- 8 files changed, 185 insertions(+), 214 deletions(-) diff --git a/authorities/auth_finder.pl b/authorities/auth_finder.pl index fb982fa6eb..106c6cdc2e 100755 --- a/authorities/auth_finder.pl +++ b/authorities/auth_finder.pl @@ -38,6 +38,7 @@ my $op = $query->param('op'); my $authtypecode = $query->param('authtypecode'); my $index = $query->param('index'); my $category = $query->param('category'); +my $resultstring = $query->param('result'); my $dbh = C4::Context->dbh; my $startfrom=$query->param('startfrom'); @@ -66,7 +67,6 @@ if ($op eq "do_search") { $resultsperpage= $query->param('resultsperpage'); $resultsperpage = 19 if(!defined $resultsperpage); -# my $orderby = $query->param('orderby'); # builds tag and subfield arrays my @tags; @@ -88,15 +88,14 @@ if ($op eq "do_search") { # multi page display gestion my $displaynext=0; my $displayprev=$startfrom; - if(($total - (($startfrom+1)*($resultsperpage))) > 0 ){ + if(($total - (($startfrom+1)*($resultsperpage))) > 0 ) { $displaynext = 1; } my @field_data = (); - for(my $i = 0 ; $i <= $#marclist ; $i++) - { + for(my $i = 0 ; $i <= $#marclist ; $i++) { push @field_data, { term => "marclist", val=>$marclist[$i] }; push @field_data, { term => "and_or", val=>$and_or[$i] }; push @field_data, { term => "excluding", val=>$excluding[$i] }; @@ -106,12 +105,9 @@ if ($op eq "do_search") { my @numbers = (); - if ($total>$resultsperpage) - { - for (my $i=1; $i<$total/$resultsperpage+1; $i++) - { - if ($i<16) - { + if ($total>$resultsperpage) { + for (my $i=1; $i<$total/$resultsperpage+1; $i++) { + if ($i<16) { my $highlight=0; ($startfrom==($i-1)) && ($highlight=1); push @numbers, { number => $i, @@ -125,8 +121,7 @@ if ($op eq "do_search") { my $from = $startfrom*$resultsperpage+1; my $to; - if($total < (($startfrom+1)*$resultsperpage)) - { + if($total < (($startfrom+1)*$resultsperpage)) { $to = $total; } else { $to = (($startfrom+1)*$resultsperpage); @@ -145,6 +140,8 @@ if ($op eq "do_search") { from=>$from, to=>$to, numbers=>\@numbers, + authtypecode =>$authtypecode, + resultstring =>$value[0], ); } else { ($template, $loggedinuser, $cookie) @@ -156,7 +153,9 @@ if ($op eq "do_search") { debug => 1, }); - $template->param(index => $index); + $template->param(index => $index, + resultstring => $resultstring + ); } $template->param(authtypesloop => \@authtypesloop); diff --git a/authorities/authorities-home.pl b/authorities/authorities-home.pl index ed0d400581..8262315374 100755 --- a/authorities/authorities-home.pl +++ b/authorities/authorities-home.pl @@ -68,7 +68,6 @@ if ($op eq "do_search") { my ($results,$total) = authoritysearch($dbh, \@tags,\@and_or, \@excluding, \@operator, \@value, $startfrom*$resultsperpage, $resultsperpage,$authtypecode); - warn "R test : $results"; ($template, $loggedinuser, $cookie) = get_template_and_user({template_name => "authorities/searchresultlist.tmpl", query => $query, @@ -138,6 +137,7 @@ if ($op eq "do_search") { from=>$from, to=>$to, numbers=>\@numbers, + authtypecode=>$authtypecode, ); } elsif ($op eq "delete") { diff --git a/authorities/authorities.pl b/authorities/authorities.pl index 7937fe779d..ad73cad811 100755 --- a/authorities/authorities.pl +++ b/authorities/authorities.pl @@ -160,7 +160,7 @@ sub create_input () { sub build_tabs ($$$$) { my($template, $record, $dbh,$encoding) = @_; - +warn "=>".$record->as_formatted; # fill arrays my @loop_data =(); my $tag; diff --git a/authorities/blinddetail-biblio-search.pl b/authorities/blinddetail-biblio-search.pl index a9c3bc7181..7c352341d9 100755 --- a/authorities/blinddetail-biblio-search.pl +++ b/authorities/blinddetail-biblio-search.pl @@ -49,8 +49,6 @@ use CGI; use C4::Search; use MARC::Record; use C4::Koha; -# use C4::Biblio; -# use C4::Catalogue; use HTML::Template; my $query=new CGI; @@ -62,6 +60,9 @@ my $index = $query->param('index'); my $authtypecode = &AUTHfind_authtypecode($dbh,$authid); my $tagslib = &AUTHgettagslib($dbh,1,$authtypecode); +my $auth_type = AUTHgetauth_type($authtypecode); +warn "XX = ".$auth_type->{auth_tag_to_report}; + my $record =AUTHgetauthority($dbh,$authid); # open template my ($template, $loggedinuser, $cookie) @@ -76,109 +77,41 @@ my ($template, $loggedinuser, $cookie) # fill arrays my @loop_data =(); my $tag; -# loop through each tab 0 through 9 -# for (my $tabloop = 0; $tabloop<=10;$tabloop++) { -# loop through each tag - my @fields = $record->fields(); - my @loop_data =(); - foreach my $field (@fields) { - my @subfields_data; - # if tag <10, there's no subfield, use the "@" trick - if ($field->tag()<10) { -# next if ($tagslib->{$field->tag()}->{'@'}->{tab} ne $tabloop); - next if ($tagslib->{$field->tag()}->{'@'}->{hidden}); - my %subfield_data; - $subfield_data{marc_lib}=$tagslib->{$field->tag()}->{'@'}->{lib}; - $subfield_data{marc_value}=$field->data(); - $subfield_data{marc_subfield}='@'; - $subfield_data{marc_tag}=$field->tag(); - push(@subfields_data, \%subfield_data); - } else { - my @subf=$field->subfields; +my @loop_data =(); +foreach my $field ($record->fields($auth_type->{auth_tag_to_report})) { + my @subfields_data; + my @subf=$field->subfields; # loop through each subfield - for my $i (0..$#subf) { - $subf[$i][0] = "@" unless $subf[$i][0]; -# next if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{tab} ne $tabloop); - next if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{hidden}); - my %subfield_data; - $subfield_data{marc_lib}=$tagslib->{$field->tag()}->{$subf[$i][0]}->{lib}; - if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{isurl}) { - $subfield_data{marc_value}="$subf[$i][1]"; - } else { - $subfield_data{marc_value}=$subf[$i][1]; - } - $subfield_data{marc_subfield}=$subf[$i][0]; - $subfield_data{marc_tag}=$field->tag(); - push(@subfields_data, \%subfield_data); - } - } - if ($#subfields_data>=0) { - my %tag_data; - $tag_data{tag}=$field->tag().' -'. $tagslib->{$field->tag()}->{lib}; - $tag_data{subfield} = \@subfields_data; - push (@loop_data, \%tag_data); - } + for my $i (0..$#subf) { + $subf[$i][0] = "@" unless $subf[$i][0]; + my %subfield_data; + $subfield_data{marc_value}=$subf[$i][1]; + $subfield_data{marc_subfield}=$subf[$i][0]; + $subfield_data{marc_tag}=$field->tag(); + push(@subfields_data, \%subfield_data); + } + if ($#subfields_data>=0) { + my %tag_data; + $tag_data{tag}=$field->tag().' -'. $tagslib->{$field->tag()}->{lib}; + $tag_data{subfield} = \@subfields_data; + push (@loop_data, \%tag_data); } - $template->param("0XX" =>\@loop_data); -# } -# now, build item tab ! -# the main difference is that datas are in lines and not in columns : thus, we build the first, then the values... -# loop through each tag -# warning : we may have differents number of columns in each row. Thus, we first build a hash, complete it if necessary -# then construct template. -# my @fields = $record->fields(); -# my %witness; #---- stores the list of subfields used at least once, with the "meaning" of the code -# my @big_array; -# foreach my $field (@fields) { -# next if ($field->tag()<10); -# my @subf=$field->subfields; -# my %this_row; -# # loop through each subfield -# for my $i (0..$#subf) { -# next if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{tab} ne 10); -# $witness{$subf[$i][0]} = $tagslib->{$field->tag()}->{$subf[$i][0]}->{lib}; -# $this_row{$subf[$i][0]} =$subf[$i][1]; -# } -# if (%this_row) { -# push(@big_array, \%this_row); -# } -# } -# #fill big_row with missing datas -# foreach my $subfield_code (keys(%witness)) { -# for (my $i=0;$i<=$#big_array;$i++) { -# $big_array[$i]{$subfield_code}=" " unless ($big_array[$i]{$subfield_code}); -# } -# } -# # now, construct template ! -# my @item_value_loop; -# my @header_value_loop; -# for (my $i=0;$i<=$#big_array; $i++) { -# my $items_data; -# foreach my $subfield_code (keys(%witness)) { -# $items_data .="".$big_array[$i]{$subfield_code}.""; -# } -# my %row_data; -# $row_data{item_value} = $items_data; -# push(@item_value_loop,\%row_data); -# } -# foreach my $subfield_code (keys(%witness)) { -# my %header_value; -# $header_value{header_value} = $witness{$subfield_code}; -# push(@header_value_loop, \%header_value); -# } - -my $authtypes = getauthtypes; -my @authtypesloop; -foreach my $thisauthtype (keys %$authtypes) { - my $selected = 1 if $thisauthtype eq $authtypecode; - my %row =(value => $thisauthtype, - selected => $selected, - authtypetext => $authtypes->{$thisauthtype}{'authtypetext'}, - ); - push @authtypesloop, \%row; } +$template->param("0XX" =>\@loop_data); + +# my $authtypes = getauthtypes; +# my @authtypesloop; +# foreach my $thisauthtype (keys %$authtypes) { +# my $selected = 1 if $thisauthtype eq $authtypecode; +# my %row =(value => $thisauthtype, +# selected => $selected, +# authtypetext => $authtypes->{$thisauthtype}{'authtypetext'}, +# ); +# push @authtypesloop, \%row; +# } $template->param(authid => $authid, - authtypesloop => \@authtypesloop, index => $index); +# authtypesloop => \@authtypesloop, + index => $index); output_html_with_http_headers $query, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/default/en/authorities/auth_finder.tmpl b/koha-tmpl/intranet-tmpl/default/en/authorities/auth_finder.tmpl index bbde305214..68951baafa 100644 --- a/koha-tmpl/intranet-tmpl/default/en/authorities/auth_finder.tmpl +++ b/koha-tmpl/intranet-tmpl/default/en/authorities/auth_finder.tmpl @@ -1,4 +1,4 @@ - +

Authority search

@@ -14,14 +14,13 @@

- - "> + "> "> - " + "

diff --git a/koha-tmpl/intranet-tmpl/default/en/authorities/blinddetail-biblio-search.tmpl b/koha-tmpl/intranet-tmpl/default/en/authorities/blinddetail-biblio-search.tmpl index d9ee3dd234..dd844b799a 100644 --- a/koha-tmpl/intranet-tmpl/default/en/authorities/blinddetail-biblio-search.tmpl +++ b/koha-tmpl/intranet-tmpl/default/en/authorities/blinddetail-biblio-search.tmpl @@ -6,29 +6,45 @@ function go() { var index_start = ; -opener.opener.document.f.field_value[index_start].value = ' + + if (opener.opener.document.f.tag[i].value == whichfield && opener.opener.document.f.subfield[i].value == '') + { + opener.opener.document.f.field_value[i].value = ''; + } + + + if (opener.opener.document.f.tag[i].value != whichfield) { + i=opener.opener.document.f.field_value.length; + } + i++; } - - -for (i=index_start ; i') +// go backward until the beginning of the field +i=index_start +while (i>=0) { + if (opener.opener.document.f.tag[i].value == whichfield && opener.opener.document.f.subfield[i].value == '9') { + opener.opener.document.f.field_value[i].value = ' + + if (opener.opener.document.f.tag[i].value == whichfield && opener.opener.document.f.subfield[i].value == '') { opener.opener.document.f.field_value[i].value = ''; } - + + + if (opener.opener.document.f.tag[i].value != whichfield) { + i=0; + } + i--; } - - - opener.close(); self.close(); return false; diff --git a/koha-tmpl/intranet-tmpl/default/en/authorities/searchresultlist-auth.tmpl b/koha-tmpl/intranet-tmpl/default/en/authorities/searchresultlist-auth.tmpl index aba7f2edfb..4edf108ab3 100644 --- a/koha-tmpl/intranet-tmpl/default/en/authorities/searchresultlist-auth.tmpl +++ b/koha-tmpl/intranet-tmpl/default/en/authorities/searchresultlist-auth.tmpl @@ -1,84 +1,98 @@

Authority search results

-
-

- - &=&resultsperpage=&type=intranet&op=do_search"> - - - - - - -highlight.gif"> - - &=&resultsperpage=&type=intranet&op=do_search">.gif" border="0"> +

+
+ + + "> +
+

Search on

+

+ + +

+

+ "> + "> + + + + + " +

+

+ +

+
+
+
+ +
- - + diff --git a/koha-tmpl/intranet-tmpl/default/en/authorities/searchresultlist.tmpl b/koha-tmpl/intranet-tmpl/default/en/authorities/searchresultlist.tmpl index cf32c7e7c0..09a8213213 100644 --- a/koha-tmpl/intranet-tmpl/default/en/authorities/searchresultlist.tmpl +++ b/koha-tmpl/intranet-tmpl/default/en/authorities/searchresultlist.tmpl @@ -4,7 +4,7 @@