TTpac: removed last bits of propagator; minor cleanup
authorBill Erickson <berick@esilibrary.com>
Thu, 11 Aug 2011 21:17:40 +0000 (17:17 -0400)
committerBill Erickson <berick@esilibrary.com>
Thu, 11 Aug 2011 21:17:40 +0000 (17:17 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/web/templates/default/opac/parts/header.tt2
Open-ILS/web/templates/default/opac/parts/result/table.tt2

index 1298754..66e47ac 100644 (file)
@@ -7,22 +7,11 @@
     # Don't wrap in l() here; do that where this format string is actually used.
     SET HUMAN_NAME_FORMAT = '[_1] [_2] [_3] [_4] [_5]';
 
-    # x and y are artifacts of using <input type="image" /> tags instead of
-    # true submit buttons, and their values are never used. page is used, but
-    # currently none of the use cases for rendering the query_string back
-    # into page output call for propagating the value of the page variable.
-
-    query_string = CGI.query_string |
-        replace(';x=\d+','') | replace(';y=\d+','') | replace(';page=\d*', '') |
-        replace(';', '&') | replace('&', '&amp;');
-
-    propagator = '?' _ query_string;
-
     is_advanced = CGI.param("_adv").size;
     is_special = CGI.param("_special").size;
 
     # -----------------------------------------------------------------------------
-    # mkurl()
+    # mkurl( destination_page, params_to_set, params_to_clear )
     #
     # Current page, updated params:
     # mkurl('', {foo => 'bar', boo => 'baz'});
@@ -33,7 +22,7 @@
     # New page, clear all existing params before applying new ones:
     # mkurl('/fuz/buster', {foo => 'bar', boo => 'baz'}, 1); 
     #
-    # Current page, clear the 'some_param' from the existing params:
+    # Current page, clear 'some_param' from the existing params:
     # mkurl('', {foo => 'bar', boo => 'baz'}, ['some_param']);
     MACRO mkurl(page, params, clear_params) BLOCK;
 
             cgi.delete_all();
         END;
 
-        # always remove these pesky artifacts
+        # x and y are artifacts of using <input type="image" /> tags 
+        # instead of true submit buttons, and their values are never used.
         cgi.delete('x', 'y'); 
 
         # apply user params
         FOR k IN params.keys;
             encoded = [];
             list = params.$k.0 ? params.$k : [params.$k];
-            # CGI croaks on already-decoded strings.  force-encode to be safe
+            # CGI croaks on already-decoded strings.  force-encode to be safe.
             FOR p IN list; encoded.push(ctx.encode_utf8(p)); END;
             foo = cgi.param("-name", k, "-values", encoded);
         END;
@@ -72,6 +62,7 @@
                 page;
             END;
         ELSE;
+            # staying on the current page
             cgi.url("-path" => 1, "-query" => 1);
         END;
     END;
index b79a536..5686971 100644 (file)
@@ -25,7 +25,7 @@
                     [%  class = 'search_page_nav_link';
                         href = '#';
                         IF page > 0;
-                            href = propagator _ '&amp;page=' _ (page - 1);
+                            href = mkurl('', {page => page - 1});
                         ELSE; class = class _ ' invisible'; END;
                     %]
                     <a class='[% class %]' href='[% href %]' 
@@ -37,7 +37,7 @@
                     [%  class = 'search_page_nav_link';
                         href = '#';
                         IF (page + 1) < page_count;
-                            href = propagator _ '&amp;page=' _ (page + 1);
+                            href = mkurl('', {page => page + 1});
                         ELSE; class = class _ ' invisible'; END;
                     %]
                     <a class='[% class %]' href='[% href %]' 
@@ -78,7 +78,7 @@
                                             <td class='result_table_pic_header' align='center'
                                                 width="78" nowrap="nowrap" valign="top">
                                                 [% ident = attrs.isbn_clean || attrs.upc; IF ident; %]
-                                                <a href="[% ctx.opac_root %]/record/[% rec.id _ propagator %]"><img alt="[% l('Image of item') %]"
+                                                <a href="[% mkurl(ctx.opac_root _ '/record/' _ rec.id) %]"><img alt="[% l('Image of item') %]"
                                                         name='item_jacket' class='result_table_pic' width="55"
                                                         src='[% ctx.media_prefix %]/opac/extras/ac/jacket/small/[% ident %]' /></a><br />
                                                 [% END %]
                                                 valign="top">
                                                 <div class="bold">
                                                     <a title="[% attrs.title %]" name='item_title'
-                                                        href="[% ctx.opac_root %]/record/[% rec.id _ propagator %]"
+                                                        href="[% mkurl(ctx.opac_root _ '/record/' _ rec.id) %]"
                                                         class='search_link'>[% attrs.title %]</a>
                                                 </div>
                                                 <div style="font-size:11px;">
                                                     <div>
                                                         <em><a title="[% l("Perform an Author Search") %]"
                                                                 name='item_author'
-                                                                href="[% ctx.opac_root %]/results?qtype=author&amp;query=[% 
-                                                                    attrs.author | replace('[,\.:;]', '') | uri %]&amp;loc=[% CGI.param('loc') | uri %]"
-                                                                class='search_link'>[% attrs.author %]</a></em>
+                                                                href="[%- 
+                                                                    authorquery = attrs.author | replace('[,\.:;]', '');
+                                                                    mkurl(ctx.opac_root _ '/results', {qtype => 'author', query => authorquery})
+                                                                    -%]">[% attrs.author | html_entity %]</a></em>
                                                         &nbsp;&nbsp;
                                                         [% attrs.pubdate %]
                                                     </div>
                                                 <div style="width:250px;text-align:left;">
                                                     <div style="float:right;">
                                                         <div class="results_aux_utils opac-auto-010"><a
-                                                                href="[% ctx.opac_root %]/place_hold[% propagator; propagator.length > 1 ? "&amp;" : ""; %]hold_target=[% rec.id %]&amp;hold_type=T
+                                                                href="[% mkurl(ctx.opac_root _ '/place_hold', {hold_target => rec.id, hold_type => 'T'}) %]
                                                                     name="place_hold_link" class="no-dec"><img
                                                                 src="[% ctx.media_prefix %]/images/green_check.png"
                                                                 alt="[% l('Place hold') %]"/><span style="position:relative;top:-3px;left:3px;">[% l('Place Hold') %]</span></a>
                                                                 <input type="hidden" name="record" value="[% rec.id %]" />
                                                             <div style="position:absolute;">
                                                                 <div style="position:relative;top:5px; left: 25px;">
-                                                                    <input type="submit" title="[% l(label _ ' my list') %]" value="[% l(label _ ' my list') %]" class="subtle-button" />
+                                                                    <input type="submit" title="[% l(label _ ' my list') %]" 
+                                                                        value="[% l(label _ ' my list') %]" class="subtle-button" />
                                                                 </div>
                                                             </div>
                                                                 <input type="image"
                                                                 alt="[% l(label _ ' my list') %]"
                                                                 src="[% ctx.media_prefix %]/images/clipboard.png" />
-                                                        </form>
+                                                            </form>
                                                         </div>
-                                                        <!-- <div style="padding-top:7px;" class="results_aux_utils">
-                                                            <a title="Reviews and More" target="_blank" class="no-dec"
-                                                                name="reviews_and_more" href="javascript:;"><img
-                                                                alt="[% l('Reviews and more') %]"
-                                                                src="[% ctx.media_prefix %]/images/starz.png" /> <span
-                                                                    style="position:relative;top:-5px;">[% l('Reviews and More') %]</span></a>
-                                                        </div> -->
                                                     </div>
                                                 </div>
                                             </td>