koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] CVS: koha/C4 Biblio.pm,1.80,1.81 SearchMarc.pm,1.9,1.10


From: Paul POULAIN
Subject: [Koha-cvs] CVS: koha/C4 Biblio.pm,1.80,1.81 SearchMarc.pm,1.9,1.10
Date: Sat, 06 Mar 2004 12:26:15 -0800

Update of /cvsroot/koha/koha/C4
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5077/C4

Modified Files:
        Biblio.pm SearchMarc.pm 
Log Message:
adding seealso feature in MARC searches

Index: Biblio.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Biblio.pm,v
retrieving revision 1.80
retrieving revision 1.81
diff -C2 -r1.80 -r1.81
*** Biblio.pm   12 Feb 2004 13:40:56 -0000      1.80
--- Biblio.pm   6 Mar 2004 20:26:13 -0000       1.81
***************
*** 232,236 ****
        }
  
!       $sth=$dbh->prepare("select tagfield,tagsubfield,$libfield as lib,tab, 
mandatory, 
repeatable,authorised_value,thesaurus_category,value_builder,kohafield from 
marc_subfield_structure order by tagfield,tagsubfield");
        $sth->execute;
  
--- 232,236 ----
        }
  
!       $sth=$dbh->prepare("select tagfield,tagsubfield,$libfield as lib,tab, 
mandatory, 
repeatable,authorised_value,thesaurus_category,value_builder,kohafield,seealso 
from marc_subfield_structure order by tagfield,tagsubfield");
        $sth->execute;
  
***************
*** 240,244 ****
        my $value_builder;
        my $kohafield;
!       while ( ($tag, $subfield, $lib, $tab, $mandatory, 
$repeatable,$authorised_value,$thesaurus_category,$value_builder,$kohafield) = 
$sth->fetchrow) {
                $res->{$tag}->{$subfield}->{lib}=$lib;
                $res->{$tag}->{$subfield}->{tab}=$tab;
--- 240,245 ----
        my $value_builder;
        my $kohafield;
!       my $seealso;
!       while ( ($tag, $subfield, $lib, $tab, $mandatory, 
$repeatable,$authorised_value,$thesaurus_category,$value_builder,$kohafield,$seealso)
 = $sth->fetchrow) {
                $res->{$tag}->{$subfield}->{lib}=$lib;
                $res->{$tag}->{$subfield}->{tab}=$tab;
***************
*** 249,252 ****
--- 250,254 ----
                $res->{$tag}->{$subfield}->{value_builder}=$value_builder;
                $res->{$tag}->{$subfield}->{kohafield}=$kohafield;
+               $res->{$tag}->{$subfield}->{seealso}=$seealso;
        }
        return $res;
***************
*** 2192,2195 ****
--- 2194,2200 ----
  # $Id$
  # $Log$
+ # Revision 1.81  2004/03/06 20:26:13  tipaul
+ # adding seealso feature in MARC searches
+ #
  # Revision 1.80  2004/02/12 13:40:56  tipaul
  # deleting subs duplicated by error

Index: SearchMarc.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/SearchMarc.pm,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** SearchMarc.pm       24 Nov 2003 16:53:10 -0000      1.9
--- SearchMarc.pm       6 Mar 2004 20:26:13 -0000       1.10
***************
*** 22,25 ****
--- 22,26 ----
  use DBI;
  use C4::Context;
+ use C4::Biblio;
  
  use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
***************
*** 52,63 ****
  
  @ISA = qw(Exporter);
! @EXPORT = qw(&catalogsearch);
  # make all your functions, whether exported or not;
  
  # marcsearch : search in the MARC biblio table.
  # everything is choosen by the user : what to search, the conditions...
  
  sub catalogsearch {
!       my ($dbh, $tags, $subfields, $and_or, $excluding, $operator, $value, 
$offset,$length) = @_;
        # build the sql request. She will look like :
        # select m1.bibid
--- 53,75 ----
  
  @ISA = qw(Exporter);
! @EXPORT = qw(&catalogsearch &findseealso);
! 
  # make all your functions, whether exported or not;
  
+ sub findseealso {
+       my ($dbh, $fields) = @_;
+       my $tagslib = MARCgettagslib ($dbh,1);
+       for (my $i=0;$i<=$#{$fields};$i++) {
+               my ($tag) =substr(@$fields[$i],1,4);
+               my ($subfield) =substr(@$fields[$i],4,1);
+               warn "$tag / $subfield 
=>".$tagslib->{$tag}->{$subfield}->{seealso};
+       }
+ }
  # marcsearch : search in the MARC biblio table.
  # everything is choosen by the user : what to search, the conditions...
  
  sub catalogsearch {
!       my ($dbh, $tags, $and_or, $excluding, $operator, $value, 
$offset,$length) = @_;
!       warn "=>@$tags / @$and_or, $excluding = $operator / $value";
        # build the sql request. She will look like :
        # select m1.bibid
***************
*** 68,79 ****
        # "Normal" statements
        my @normal_tags = ();
!       my @normal_subfields = ();
        my @normal_and_or = ();
        my @normal_operator = ();
        my @normal_value = ();
- 
        # Extracts the NOT statements from the list of statements
        my @not_tags = ();
!       my @not_subfields = ();
        my @not_and_or = ();
        my @not_operator = ();
--- 80,90 ----
        # "Normal" statements
        my @normal_tags = ();
! #     my @normal_subfields = ();
        my @normal_and_or = ();
        my @normal_operator = ();
        my @normal_value = ();
        # Extracts the NOT statements from the list of statements
        my @not_tags = ();
! #     my @not_subfields = ();
        my @not_and_or = ();
        my @not_operator = ();
***************
*** 92,96 ****
                                        unless 
(C4::Context->stopwords->{uc($word)}) {  #it's NOT a stopword => use it. 
Otherwise, ignore
                                                push @not_tags, @$tags[$i];
!                                               push @not_subfields, 
@$subfields[$i];
                                                push @not_and_or, "or"; # as 
request is negated, finds "foo" or "bar" if final request is NOT "foo" and "bar"
                                                push @not_operator, 
@$operator[$i];
--- 103,107 ----
                                        unless 
(C4::Context->stopwords->{uc($word)}) {  #it's NOT a stopword => use it. 
Otherwise, ignore
                                                push @not_tags, @$tags[$i];
! #                                             push @not_subfields, 
@$subfields[$i];
                                                push @not_and_or, "or"; # as 
request is negated, finds "foo" or "bar" if final request is NOT "foo" and "bar"
                                                push @not_operator, 
@$operator[$i];
***************
*** 102,106 ****
                        {
                                push @not_tags, @$tags[$i];
!                               push @not_subfields, @$subfields[$i];
                                push @not_and_or, "or"; # as request is 
negated, finds "foo" or "bar" if final request is NOT "foo" and "bar"
                                push @not_operator, @$operator[$i];
--- 113,117 ----
                        {
                                push @not_tags, @$tags[$i];
! #                             push @not_subfields, @$subfields[$i];
                                push @not_and_or, "or"; # as request is 
negated, finds "foo" or "bar" if final request is NOT "foo" and "bar"
                                push @not_operator, @$operator[$i];
***************
*** 116,120 ****
                                        unless 
(C4::Context->stopwords->{uc($word)}) {  #it's NOT a stopword => use it. 
Otherwise, ignore
                                                push @normal_tags, @$tags[$i];
!                                               push @normal_subfields, 
@$subfields[$i];
                                                push @normal_and_or, "and";     
# assumes "foo" and "bar" if "foo bar" is entered
                                                push @normal_operator, 
@$operator[$i];
--- 127,131 ----
                                        unless 
(C4::Context->stopwords->{uc($word)}) {  #it's NOT a stopword => use it. 
Otherwise, ignore
                                                push @normal_tags, @$tags[$i];
! #                                             push @normal_subfields, 
@$subfields[$i];
                                                push @normal_and_or, "and";     
# assumes "foo" and "bar" if "foo bar" is entered
                                                push @normal_operator, 
@$operator[$i];
***************
*** 126,130 ****
                        {
                                push @normal_tags, @$tags[$i];
!                               push @normal_subfields, @$subfields[$i];
                                push @normal_and_or, @$and_or[$i];
                                push @normal_operator, @$operator[$i];
--- 137,141 ----
                        {
                                push @normal_tags, @$tags[$i];
! #                             push @normal_subfields, @$subfields[$i];
                                push @normal_and_or, @$and_or[$i];
                                push @normal_operator, @$operator[$i];
***************
*** 135,150 ****
  
        # Finds the basic results without the NOT requests
!       my ($sql_tables, $sql_where1, $sql_where2) = 
create_request(address@hidden, address@hidden, address@hidden, address@hidden, 
address@hidden);
  
        my $sth;
- #     warn "HERE (NORMAL)";
        if ($sql_where2) {
                $sth = $dbh->prepare("select distinct m1.bibid from $sql_tables 
where $sql_where2 and ($sql_where1)");
- #             warn("-->select m1.bibid from $sql_tables where $sql_where2 and 
($sql_where1)");
        } else {
                $sth = $dbh->prepare("select distinct m1.bibid from $sql_tables 
where $sql_where1");
- #             warn("==>select m1.bibid from $sql_tables where $sql_where1");
        }
! 
        $sth->execute();
        my @result = ();
--- 146,158 ----
  
        # Finds the basic results without the NOT requests
!       my ($sql_tables, $sql_where1, $sql_where2) = 
create_request(address@hidden, address@hidden, address@hidden, address@hidden);
  
        my $sth;
        if ($sql_where2) {
                $sth = $dbh->prepare("select distinct m1.bibid from $sql_tables 
where $sql_where2 and ($sql_where1)");
        } else {
                $sth = $dbh->prepare("select distinct m1.bibid from $sql_tables 
where $sql_where1");
        }
!       warn "===> select distinct m1.bibid from $sql_tables where $sql_where2 
and ($sql_where1)";
        $sth->execute();
        my @result = ();
***************
*** 155,159 ****
        if( ($sth->rows) && $any_not )  # some results to tune up and some NOT 
statements
        {
!               ($not_sql_tables, $not_sql_where1, $not_sql_where2) = 
create_request(address@hidden, address@hidden, address@hidden, address@hidden, 
address@hidden);
  
                my @tmpresult;
--- 163,167 ----
        if( ($sth->rows) && $any_not )  # some results to tune up and some NOT 
statements
        {
!               ($not_sql_tables, $not_sql_where1, $not_sql_where2) = 
create_request(address@hidden, address@hidden, address@hidden, address@hidden);
  
                my @tmpresult;
***************
*** 163,173 ****
                }
                my $sth_not;
- #             warn "HERE (NOT)";
                if ($not_sql_where2) {
                        $sth_not = $dbh->prepare("select distinct m1.bibid from 
$not_sql_tables where $not_sql_where2 and ($not_sql_where1)");
- #                     warn("-->select m1.bibid from $not_sql_tables where 
$not_sql_where2 and ($not_sql_where1)");
                } else {
                        $sth_not = $dbh->prepare("select distinct m1.bibid from 
$not_sql_tables where $not_sql_where1");
- #                     warn("==>select m1.bibid from $not_sql_tables where 
$not_sql_where1");
                }
  
--- 171,178 ----
***************
*** 220,224 ****
  
  sub create_request {
!       my ($tags, $subfields, $and_or, $operator, $value) = @_;
  
        my $sql_tables; # will contain marc_subfield_table as m1,...
--- 225,229 ----
  
  sub create_request {
!       my ($tags, $and_or, $operator, $value) = @_;
  
        my $sql_tables; # will contain marc_subfield_table as m1,...
***************
*** 236,240 ****
                                        $sql_where1 .= "(m1.subfieldvalue like 
'@$value[$i]%'";
                                        if (@$tags[$i]) {
!                                               $sql_where1 .=" and 
address@hidden and m1.subfieldcode='@$subfields[$i]'";
                                        }
                                        $sql_where1.=")";
--- 241,245 ----
                                        $sql_where1 .= "(m1.subfieldvalue like 
'@$value[$i]%'";
                                        if (@$tags[$i]) {
!                                               $sql_where1 .=" and 
m1.tag+m1.subfieldcode in (@$tags[$i])";
                                        }
                                        $sql_where1.=")";
***************
*** 243,247 ****
                                        $sql_where1 .= "(m1.word  like 
'@$value[$i]%'";
                                        if (@$tags[$i]) {
!                                                $sql_where1 .=" and 
address@hidden and m1.subfieldid='@$subfields[$i]'";
                                        }
                                        $sql_where1.=")";
--- 248,252 ----
                                        $sql_where1 .= "(m1.word  like 
'@$value[$i]%'";
                                        if (@$tags[$i]) {
!                                                $sql_where1 .=" and 
m1.tag+m1.subfieldid in (@$tags[$i])";
                                        }
                                        $sql_where1.=")";
***************
*** 250,254 ****
                                        $sql_where1 .= "(m1.subfieldvalue 
@$operator[$i] '@$value[$i]' ";
                                        if (@$tags[$i]) {
!                                                $sql_where1 .=" and 
address@hidden and m1.subfieldcode='@$subfields[$i]'";
                                        }
                                        $sql_where1.=")";
--- 255,259 ----
                                        $sql_where1 .= "(m1.subfieldvalue 
@$operator[$i] '@$value[$i]' ";
                                        if (@$tags[$i]) {
!                                                $sql_where1 .=" and 
m1.tag+m1.subfieldcode in (@$tags[$i])";
                                        }
                                        $sql_where1.=")";
***************
*** 260,264 ****
                                        $sql_where1 .= "@$and_or[$i] 
(m$nb_table.subfieldvalue like '@$value[$i]%'";
                                        if (@$tags[$i]) {
!                                               $sql_where1 .=" and 
address@hidden and m$nb_table.subfieldcode='@$subfields[$i]'";
                                        }
                                        $sql_where1.=")";
--- 265,269 ----
                                        $sql_where1 .= "@$and_or[$i] 
(m$nb_table.subfieldvalue like '@$value[$i]%'";
                                        if (@$tags[$i]) {
!                                               $sql_where1 .=" and 
m$nb_table.tag+m$nb_table.subfieldcode in (@$tags[$i])";
                                        }
                                        $sql_where1.=")";
***************
*** 270,274 ****
                                                $sql_where1 .= "@$and_or[$i] 
(m$nb_table.word like '@$value[$i]%'";
                                                if (@$tags[$i]) {
!                                                       $sql_where1 .=" and 
address@hidden and m$nb_table.subfieldid='@$subfields[$i]'";
                                                }
                                                $sql_where1.=")";
--- 275,279 ----
                                                $sql_where1 .= "@$and_or[$i] 
(m$nb_table.word like '@$value[$i]%'";
                                                if (@$tags[$i]) {
!                                                       $sql_where1 .=" and 
m$nb_table.tag+m$nb_table.subfieldid in(@$tags[$i])";
                                                }
                                                $sql_where1.=")";
***************
*** 277,281 ****
                                                $sql_where1 .= "@$and_or[$i] 
(m$nb_table.word like '@$value[$i]%'";
                                                if (@$tags[$i]) {
!                                                       $sql_where1 .="  and 
address@hidden and m$nb_table.subfieldid='@$subfields[$i]'";
                                                }
                                                $sql_where1.=")";
--- 282,286 ----
                                                $sql_where1 .= "@$and_or[$i] 
(m$nb_table.word like '@$value[$i]%'";
                                                if (@$tags[$i]) {
!                                                       $sql_where1 .="  and 
m$nb_table.tag+m$nb_table.subfieldid in (@$tags[$i])";
                                                }
                                                $sql_where1.=")";
***************
*** 287,291 ****
                                        $sql_where1 .= "@$and_or[$i] 
(m$nb_table.subfieldvalue @$operator[$i] '@$value[$i]'";
                                        if (@$tags[$i]) {
!                                               $sql_where1 .="  and 
address@hidden and m$nb_table.subfieldcode='@$subfields[$i]'";
                                        }
                                        $sql_where2 .= 
"m1.bibid=m$nb_table.bibid and ";
--- 292,296 ----
                                        $sql_where1 .= "@$and_or[$i] 
(m$nb_table.subfieldvalue @$operator[$i] '@$value[$i]'";
                                        if (@$tags[$i]) {
!                                               $sql_where1 .="  and 
m$nb_table.tag+m$nb_table.subfieldcode in (@$tags[$i])";
                                        }
                                        $sql_where2 .= 
"m1.bibid=m$nb_table.bibid and ";




reply via email to

[Prev in Thread] Current Thread [Next in Thread]