smarter search term propagation, should avoid ARRAY(0xdeadbeef) type ...
authorsenator <lebbeous@esilibrary.com>
Tue, 15 Mar 2011 21:53:58 +0000 (17:53 -0400)
committersenator <lebbeous@esilibrary.com>
Tue, 15 Mar 2011 21:53:58 +0000 (17:53 -0400)
... stuff in search boxes

Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
Open-ILS/web/templates/default/opac/parts/header.tt2
Open-ILS/web/templates/default/opac/parts/searchbar.tt2
Open-ILS/web/templates/default/opac/results.tt2

index 84c68a7..7a4d491 100644 (file)
@@ -77,11 +77,11 @@ sub _prepare_biblio_search {
         }
     }
 
-    my $site = $cgi->param('loc') || $ctx->{aou_tree}->()->id;
-    if (defined($cgi->param('loc')) or not $query =~ /site\(\d+\)/) {
+    my $site = $cgi->param('loc');
+    if (defined($site) and ($site ne $ctx->{aou_tree}->()->id) and not $query =~ /site\(\d+\)/) {
         $query .= " site($site)";
     }
-    if (defined($cgi->param('depth')) or not $query =~ /depth\(\d+\)/) {
+    if (defined($cgi->param('depth')) and not $query =~ /depth\(\d+\)/) {
         my $depth = defined $cgi->param('depth') ?
             $cgi->param('depth') : $ctx->{find_aou}->($site)->ou_type->depth;
         $query .= " depth($depth)";
index fa775b2..aa34ab5 100644 (file)
@@ -19,6 +19,8 @@
 
     propagator = '?' _ query_string;
 
+    is_advanced = CGI.param("_adv").size;
+
     formats = [  # XXX KCLS-specific
         {'code' => 'a', 'name' => 'Book', 'image' => 'media_book.jpg'},
         {'code' => 'i', 'name' => 'Book on cassette', 'image' => 'media_bookoncasset.jpg'},
index 84ab264..158a93f 100644 (file)
@@ -20,8 +20,9 @@
             <td>
             [% INCLUDE "default/opac/parts/qtype_selector.tt2" %]
             </td>
-            <td>
             [% END %]
+            [% IF ctx.processed_search_query OR NOT is_advanced %]
+            <td>
                 <div id="search_box_wrapper">
                     <!-- Note: when common browsers support HTML5 placeholder text, we can remove the JS -->
                     <input type="text" id="search_box" name="query" value="[% is_advanced ? ctx.processed_search_query : CGI.param('query') || l("Search Keyword") | html %]"
@@ -40,6 +41,7 @@
                     </div>
                 </div>
             </td>
+            [% END %]
         </tr>
         [% UNLESS is_advanced %]
         <tr>
         [% END %]
     </table>
     [% UNLESS took_care_of_form %]</form>[% END %]
-    [% IF is_advanced %]
+    [% IF is_advanced AND CGI.param('qtype') %]
     <div class="opac-auto-102">
         [ <a href="[% ctx.opac_root %]/advanced?[% query_string %]">[%
-            l('Click to Refine Your Search')
+            l('Click to Refine Your Original Search')
         %]</a> ]
     </div>
     [% END %]
index 19735e2..3b06cae 100644 (file)
@@ -4,7 +4,6 @@
     WRAPPER "default/opac/parts/base.tt2";
     INCLUDE "default/opac/parts/topnav.tt2";
     ctx.page_title = l("Search Results");
-    is_advanced = CGI.param("_adv").size;
 
     page = CGI.param('page') || 0;
     page_count = POSIX.ceil(ctx.hit_count / ctx.page_size);
@@ -39,7 +38,7 @@
                 </div>
                 [% END %]
                 <div class="results_header_div"></div>
-                [% UNLESS CGI.param('_adv') %]
+                [% UNLESS is_advanced %]
                     <div class="results_header_lbl">Sort by</div>
                     [% INCLUDE "default/opac/parts/filtersort.tt2" value=CGI.param('sort') %]
                     <div class="results_header_div"></div>