From f3bed157bc524e5c88e07407fc56b1bfb8998406 Mon Sep 17 00:00:00 2001
From: Bill Erickson <berick@esilibrary.com>
Date: Fri, 30 Sep 2011 12:19:35 -0400
Subject: [PATCH] TPac: propagate searches to advanced search page

The link that takes users to the advanced searc page now propagates
any existing (well, all) search URL params.  The change required some
minor augmentation to the code that builds the advanced search form.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
---
 Open-ILS/src/templates/opac/parts/advanced/global_row.tt2 | 13 +++++++++++++
 Open-ILS/src/templates/opac/parts/searchbar.tt2           |  2 +-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/Open-ILS/src/templates/opac/parts/advanced/global_row.tt2 b/Open-ILS/src/templates/opac/parts/advanced/global_row.tt2
index 1598b69346..66ecea427e 100644
--- a/Open-ILS/src/templates/opac/parts/advanced/global_row.tt2
+++ b/Open-ILS/src/templates/opac/parts/advanced/global_row.tt2
@@ -9,6 +9,19 @@
     queries = CGI.param('query');
     bools = CGI.param('bool') || ['and' x 3];
     qtypes = CGI.param('qtype') || ['keyword' x 3];
+
+    IF !qtypes.0; # not an array
+        qtypes = [qtypes];
+        bools = [bools];
+        queries = [queries];
+    END;
+
+    WHILE qtypes.size < 3;
+        qtypes.push('keyword');
+        bools.push('and');
+        queries.push('');
+    END;
+
     FOR qtype IN qtypes;
         c = contains.shift;
         b = bools.shift;
diff --git a/Open-ILS/src/templates/opac/parts/searchbar.tt2 b/Open-ILS/src/templates/opac/parts/searchbar.tt2
index 1f1f0a8303..79213d2a53 100644
--- a/Open-ILS/src/templates/opac/parts/searchbar.tt2
+++ b/Open-ILS/src/templates/opac/parts/searchbar.tt2
@@ -7,7 +7,7 @@
         <tr>
             <td colspan="3">
                 <span class="search_catalog_lbl">[% l('Search the Catalog') %]</span>
-                <a href="[% ctx.opac_root %]/advanced"
+                <a href="[% mkurl(ctx.opac_root _ '/advanced') %]"
                     id="home_adv_search_link"><span
                     class="adv_search_font">[% l('Advanced Search') %]</span></a>
             </td>
-- 
2.11.0