From e737c7eb1d60e460d96b01da297f00ddc690d969 Mon Sep 17 00:00:00 2001 From: doxulting Date: Mon, 5 Jul 2004 13:37:22 +0000 Subject: [PATCH] First step for working authorities --- C4/AuthoritiesMarc.pm | 12 +++++++++--- authorities/auth_finder.pl | 19 ++++++++++++------- authorities/authorities-home.pl | 19 ++++++++++++++++++- authorities/authorities.pl | 3 ++- .../default/en/authorities/auth_finder.tmpl | 4 +++- .../default/en/authorities/authorities.tmpl | 12 +++++++++++- 6 files changed, 55 insertions(+), 14 deletions(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index 94ee47d00f..ca8b601f79 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -93,6 +93,7 @@ sub authoritysearch { my ($sql_tables, $sql_where1, $sql_where2) = create_request($dbh,\@normal_tags, \@normal_and_or, \@normal_operator, \@normal_value); my $sth; + if ($sql_where2) { $sth = $dbh->prepare("select distinct m1.authid from auth_header,$sql_tables where m1.authid=auth_header.authid and auth_header.authtypecode=? and $sql_where2 and ($sql_where1)"); warn "Q2 : select distinct m1.authid from auth_header,$sql_tables where m1.authid=auth_header.authid and auth_header.authtypecode=? and $sql_where2 and ($sql_where1)"; @@ -102,7 +103,6 @@ sub authoritysearch { } $sth->execute($authtypecode); my @result = (); - while (my ($authid) = $sth->fetchrow) { warn "AUTH: $authid"; push @result,$authid; @@ -172,6 +172,7 @@ sub create_request { my $nb_active=0; # will contain the number of "active" entries. and entry is active is a value is provided. my $nb_table=1; # will contain the number of table. ++ on each entry EXCEPT when an OR is provided. + for(my $i=0; $i<=@$value;$i++) { if (@$value[$i]) { $nb_active++; @@ -183,14 +184,15 @@ sub create_request { $sql_where1 .=" and m1.tag+m1.subfieldcode in (@$tags[$i])"; } $sql_where1.=")"; - } elsif (@$operator[$i] eq "contains") { - $sql_tables .= "auth_word as m$nb_table,"; + } elsif (@$operator[$i] eq "contains") { + $sql_tables .= "auth_word as m$nb_table,"; $sql_where1 .= "(m1.word like ".$dbh->quote("@$value[$i]%"); if (@$tags[$i]) { $sql_where1 .=" and m1.tagsubfield in (@$tags[$i])"; } $sql_where1.=")"; } else { + $sql_tables .= "auth_subfield_table as m$nb_table,"; $sql_where1 .= "(m1.subfieldvalue @$operator[$i] ".$dbh->quote("@$value[$i]"); if (@$tags[$i]) { @@ -250,6 +252,7 @@ sub create_request { $sql_where2 = ""; } chop $sql_tables; # deletes the trailing ',' + return ($sql_tables, $sql_where1, $sql_where2); } @@ -824,6 +827,9 @@ Paul POULAIN paul.poulain@free.fr # $Id$ # $Log$ +# Revision 1.5 2004/07/05 13:37:22 doxulting +# First step for working authorities +# # Revision 1.4 2004/06/22 11:35:37 tipaul # removing % at the beginning of a string to avoid loooonnnngggg searchs # diff --git a/authorities/auth_finder.pl b/authorities/auth_finder.pl index f27b8d3023..baa9ffbb50 100755 --- a/authorities/auth_finder.pl +++ b/authorities/auth_finder.pl @@ -36,6 +36,7 @@ use C4::Koha; # XXX subfield_is_koha_internal_p my $query=new CGI; my $op = $query->param('op'); my $authtypecode = $query->param('authtypecode'); +my $index = $query->param('index'); my $dbh = C4::Context->dbh; my $startfrom=$query->param('startfrom'); @@ -50,6 +51,7 @@ foreach my $thisauthtype (keys %$authtypes) { my %row =(value => $thisauthtype, selected => $selected, authtypetext => $authtypes->{$thisauthtype}{'authtypetext'}, + index => $index, ); push @authtypesloop, \%row; } @@ -63,17 +65,17 @@ if ($op eq "do_search") { $resultsperpage= $query->param('resultsperpage'); $resultsperpage = 19 if(!defined $resultsperpage); - my $orderby = $query->param('orderby'); +# my $orderby = $query->param('orderby'); # builds tag and subfield arrays my @tags; my ($results,$total) = authoritysearch($dbh, \@tags,\@and_or, \@excluding, \@operator, \@value, - $startfrom*$resultsperpage, $resultsperpage,$orderby); + $startfrom*$resultsperpage, $resultsperpage,$authtypecode);# $orderby); ($template, $loggedinuser, $cookie) - = get_template_and_user({template_name => "authorities/auth_finder.tmpl", + = get_template_and_user({template_name => "authorities/searchresultlist-auth.tmpl", query => $query, type => 'intranet', authnotrequired => 0, @@ -81,7 +83,6 @@ if ($op eq "do_search") { flagsrequired => {catalogue => 1}, debug => 1, }); - # multi page display gestion my $displaynext=0; my $displayprev=$startfrom; @@ -128,21 +129,24 @@ if ($op eq "do_search") { } else { $to = (($startfrom+1)*$resultsperpage); } - $template->param(result => $results, - startfrom=> $startfrom, + $template->param(result => $results) if $results; + $template->param(index => $query->param('index')); + warn "ici query $index $query->param('resultsperpage')" ; + $template->param(startfrom=> $startfrom, displaynext=> $displaynext, displayprev=> $displayprev, resultsperpage => $resultsperpage, startfromnext => $startfrom+1, startfromprev => $startfrom-1, + index => $index, searchdata=>\@field_data, total=>$total, from=>$from, to=>$to, numbers=>\@numbers, ); - } else { + warn "Je suis la de base $index\n"; ($template, $loggedinuser, $cookie) = get_template_and_user({template_name => "authorities/auth_finder.tmpl", query => $query, @@ -152,6 +156,7 @@ if ($op eq "do_search") { debug => 1, }); + $template->param(index => $index); } $template->param(authtypesloop => \@authtypesloop); diff --git a/authorities/authorities-home.pl b/authorities/authorities-home.pl index 3737e434c8..1094c217d3 100755 --- a/authorities/authorities-home.pl +++ b/authorities/authorities-home.pl @@ -36,6 +36,7 @@ use C4::Koha; # XXX subfield_is_koha_internal_p my $query=new CGI; my $op = $query->param('op'); my $authtypecode = $query->param('authtypecode'); +warn "La authtypecode = $authtypecode\n"; my $dbh = C4::Context->dbh; my $startfrom=$query->param('startfrom'); @@ -64,6 +65,7 @@ if ($op eq "do_search") { $resultsperpage= $query->param('resultsperpage'); $resultsperpage = 19 if(!defined $resultsperpage); my @tags; + warn "a ce pont labas dbh ($dbh), tags(\@tags), and_or (\@and_or), excluding (\@excluding), operator (\@operator), value (\@value), resultsperpage $resultsperpage, $startfrom, [$authtypecode]"; my ($results,$total) = authoritysearch($dbh, \@tags,\@and_or, \@excluding, \@operator, \@value, @@ -140,7 +142,22 @@ if ($op eq "do_search") { numbers=>\@numbers, ); -} elsif ($op eq "AddStatement") { +} elsif ($op eq "delete") { + + warn "Ici effacement\n"; + + ($template, $loggedinuser, $cookie) + = get_template_and_user({template_name => "authorities/authorities-home.tmpl", + query => $query, + type => 'intranet', + authnotrequired => 0, + flagsrequired => {catalogue => 1}, + debug => 1, + }); +# $template->param("statements" => \@statements, +# "nbstatements" => $nbstatements); +} +elsif ($op eq "AddStatement") { ($template, $loggedinuser, $cookie) = get_template_and_user({template_name => "authorities/authorities-home.tmpl", diff --git a/authorities/authorities.pl b/authorities/authorities.pl index d189d4970a..7937fe779d 100755 --- a/authorities/authorities.pl +++ b/authorities/authorities.pl @@ -340,6 +340,7 @@ if ($op eq "add") { } else { ($authid) = AUTHaddauthority($dbh,$record,$authid,$authtypecode); } + print $input->redirect("authorities-home.pl"); #------------------------------------------------------------------------------------------------------------------------------ } elsif ($op eq "addfield") { #------------------------------------------------------------------------------------------------------------------------------ @@ -423,4 +424,4 @@ foreach my $thisauthtype (keys %$authtypes) { } $template->param(authtypesloop => \@authtypesloop); -output_html_with_http_headers $input, $cookie, $template->output; \ No newline at end of file +output_html_with_http_headers $input, $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 6c04533999..d2b7fd940f 100644 --- a/koha-tmpl/intranet-tmpl/default/en/authorities/auth_finder.tmpl +++ b/koha-tmpl/intranet-tmpl/default/en/authorities/auth_finder.tmpl @@ -11,7 +11,7 @@

Search on

-

"> + "> + "

diff --git a/koha-tmpl/intranet-tmpl/default/en/authorities/authorities.tmpl b/koha-tmpl/intranet-tmpl/default/en/authorities/authorities.tmpl index 2b0cf444d0..f1206953a3 100644 --- a/koha-tmpl/intranet-tmpl/default/en/authorities/authorities.tmpl +++ b/koha-tmpl/intranet-tmpl/default/en/authorities/authorities.tmpl @@ -17,7 +17,17 @@

- +
+
+
+
+
+
+
+
+
+
+

-- 2.39.5