LP1918470 WIP Fix for Place Hold Internal Server Error collab/jboyer/lp1918470_mkurl_fix
authorJason Boyer <JBoyer@EquinoxInitiative.org>
Thu, 11 Mar 2021 21:29:02 +0000 (16:29 -0500)
committerJason Boyer <JBoyer@EquinoxInitiative.org>
Thu, 11 Mar 2021 21:29:02 +0000 (16:29 -0500)
Trying to add an opts hash to mkurl to allow more control over filtered / non-filtered output.

Signed-off-by: Jason Boyer <JBoyer@EquinoxInitiative.org>
Open-ILS/src/templates/opac/parts/header.tt2
Open-ILS/src/templates/opac/parts/result/table.tt2

index 0b404e0..a7b8741 100644 (file)
@@ -33,7 +33,8 @@
 
 
     # -----------------------------------------------------------------------------
-    # mkurl( destination_page, params_to_set, params_to_clear )
+    # mkurl( destination_page, params_to_set, params_to_clear, opts )
+    # Currently the opts hash only accepts a filter key (values 'html', 'uri', or 'none')
     #
     # Current page, updated params:
     # mkurl('', {foo => 'bar', boo => 'baz'});
     #
     # Current page to a named anchor 'copies'
     # mkurl('', {}, [], 'copies');
-    MACRO mkurl(page, params, clear_params, named_anchor) BLOCK;
+    #
+    # Current page, don't filter output at all
+    # mkurl('', {}, [], '', { filter => 'none' });
+    #
+    # Current page, use html filter on output (the default, but made explicit)
+    # mkurl('', {}, [], '', { filter => 'html' });
+    MACRO mkurl(page, params, clear_params, named_anchor, opts) BLOCK;
 
         # clone the query string to avoid clobberation
         cgi = CGI.new(CGI.query_string);
             END;
         END;
 
+        # Hold resulting URL
+        result = '';
+
         final = named_anchor ? '#' _ named_anchor : '';
 
         IF page;
             IF cgi.query_string;
-                page _ '?' _ cgi.query_string _ final | html;
+                result = page _ '?' _ cgi.query_string _ final;
             ELSE;
-                page _ final | html;
+                result = page _ final;
             END;
         ELSE;
             # staying on the current page
-            cgi.url("-absolute" => 1, "-path" => 1, "-query" => 1) _ final | html;
+            result = cgi.url("-absolute" => 1, "-path" => 1, "-query" => 1) _ final;
+        END;
+
+        UNLESS opts.filter;
+            result | html;
+return;
         END;
+
+        IF opts.filter == 'none';
+            result;
+return;
+        ELSIF opts.filter == 'uri';
+            result | uri;
+return;
+        ELSIF opts.filter == 'html';
+            result | html;
+return;
+        ELSE;
+            result | html;
+        END;
+
     END;
 
     # Dojo is required for the copy locations advanced search filter
index c9436f9..35ce5d6 100644 (file)
@@ -445,7 +445,7 @@ END;
                                                                    'sort','page'];
                                                         add_parms = {hold_target => rec.id, 
                                                                      hold_type => hold_type, 
-                                                                     hold_source_page => mkurl()};
+                                                                     hold_source_page => mkurl('', {}, [], '', { filter => 'none' })};
 
                                                         IF is_advanced;
                                                             # Do not pass "advanced params" to hold code