Bug 8206: Specify index in OPAC authority search
authorJared Camins-Esakov <jcamins@cpbibliography.com>
Wed, 30 May 2012 15:02:51 +0000 (11:02 -0400)
committerPaul Poulain <paul.poulain@biblibre.com>
Fri, 7 Sep 2012 13:16:40 +0000 (15:16 +0200)
Adds a dropdown to allow the user to choose to search the 'mainentry,'
and 'match-heading'indexes, in addition to the 'any' index which is
the default.

To test (you will need authority records with see-from and
see-also headings):
1. Go to the browse subjects and authors section in the OPAC
2. Do a search for a fairly generic term that is used as a
   see-also term in a lot of records. Note that your search
   results include both the record that you wanted and all
   the other records that refer to it.
3. Apply the patch.
4. Repeat the search from step 2. Notice there is no change
   to the results.
5. Repeat the search from step 2, but choose "in main entry"
   and observe that you are now only seeing authority records
   with the search entered in their main entry.
6. Repeat the search from step 2, but choose "in any heading"
   and observe that the results are the same as in step 2. This
   is intentional, so that in the future notes in authorities
   can be made searchable.
7. Search for an obsolete form of heading with the "in keyword"
   option selected. Notice what results you get.

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Works nicely. Hiding the new options can be done with CSS:

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
C4/AuthoritiesMarc.pm
koha-tmpl/opac-tmpl/prog/en/modules/opac-authorities-home.tt
opac/opac-authorities-home.pl

index 1f440df..6593ee2 100644 (file)
@@ -199,7 +199,7 @@ sub SearchAuthorities {
         }
     } else {
         my $query;
-        my $attr;
+        my $attr = '';
             # the marclist may contain "mainentry". In this case, search the tag_to_report, that depends on
             # the authtypecode. Then, search on $a of this tag_to_report
             # also store main entry MARC tag, to extract it at end of search
@@ -230,9 +230,6 @@ sub SearchAuthorities {
                 elsif ( @$tags[$i] eq "mainentry" ) {
                     $attr = " \@attr 1=Heading ";
                 }
-                elsif ( @$tags[$i] eq "any" ) {
-                    $attr = " \@attr 1=Any ";
-                }
                 elsif ( @$tags[$i] eq "match" ) {
                     $attr = " \@attr 1=Match ";
                 }
@@ -245,6 +242,9 @@ sub SearchAuthorities {
                 elsif ( @$tags[$i] eq "thesaurus" ) {
                     $attr = " \@attr 1=Subject-heading-thesaurus ";
                 }
+                else { # Assume any if no index was specified
+                    $attr = " \@attr 1=Any ";
+                }
                 if ( @$operator[$i] eq 'is' ) {
                     $attr .= " \@attr 4=1  \@attr 5=100 "
                       ; ##Phrase, No truncation,all of subfield field must match
index 04d5a8c..f72d6a6 100644 (file)
                 [% END %]
                 [% END %]
                 </select>
-                <select name="operatorc" id="anywhere">
+                <select name="operator" id="anywhere">
                     <option value="contains">contains</option>
                     <option value="start">starts with</option>
                     <option value="is">is exactly</option>
                 </select>
-                <input type="text" name="valuec" id="anywhere_value" value="[% value %]" />
-                <input type="hidden" name="marclistc" value="" />
-                    <input type="hidden" name="and_ora" value="and" />
-                <input type="hidden" name="excludingc" value="" />
+                <input type="text" name="value" id="value" value="[% value %]" />
+                <select name="marclist" id="marclist">
+                    <option value="any" selected="selected">in keyword</option>
+                    <option value="mainentry">in main entry</option>
+                    <option value="match">in any heading</option>
+                </select>
+                <input type="hidden" name="and_ora" value="and" />
+                <input type="hidden" name="excluding" value="" />
             </li>
             <li><label for="orderby">Order by: </label><select name="orderby" id="orderby">
                 <option value="">None</option>
index 4e9f9ab..5656228 100755 (executable)
@@ -58,12 +58,12 @@ foreach my $thisauthtype (
 }
 
 if ( $op eq "do_search" ) {
-    my @marclist = ($query->param('marclista'),$query->param('marclistb'),$query->param('marclistc'));
-    my @and_or = ($query->param('and_ora'),$query->param('and_orb'),$query->param('and_orc'));
-    my @excluding = ($query->param('excludinga'),$query->param('excludingb'),$query->param('excludingc'),);
-    my @operator = ($query->param('operatora'),$query->param('operatorb'),$query->param('operatorc'));
+    my @marclist = ($query->param('marclist'));
+    my @and_or = ($query->param('and_or'));
+    my @excluding = ($query->param('excluding'),);
+    my @operator = ($query->param('operator'));
     my $orderby = $query->param('orderby');
-    my @value = ($query->param('valuea') || "",$query->param('valueb') || "",$query->param('valuec') || "",);
+    my @value = ($query->param('value') || "",);
 
     $resultsperpage = $query->param('resultsperpage');
     $resultsperpage = 20 if ( !defined $resultsperpage );
@@ -90,15 +90,7 @@ if ( $op eq "do_search" ) {
         $displaynext = 1;
     }
 
-    my @field_data = ();
-
-    foreach my $letter (qw/a b c/){
-        push @field_data, { term => "marclist$letter" , val => $query->param("marclist$letter") || ''};
-        push @field_data, { term => "and_or$letter" , val => $query->param("and_or$letter") || ''};
-        push @field_data, { term => "excluding$letter" , val => $query->param("excluding$letter") || ''};
-        push @field_data, { term => "operator$letter" , val => $query->param("operator$letter") || ''};
-        push @field_data, { term => "value$letter" , val => $query->param("value$letter") || ''};
-    }
+    my @field_data = ( { term => "marclist" , val => $query->param("marclist") || ''} );
 
     my @numbers = ();