1 [%- USE money = format(l('$%.2f'));
6 SET DATE_FORMAT = l('%m/%d/%Y');
7 PROCESS "opac/parts/config.tt2";
9 # Don't wrap in l() here; do that where this format string is actually used.
10 SET HUMAN_NAME_FORMAT = '[_1] [_2] [_3] [_4] [_5]';
12 is_advanced = CGI.param("_adv").size;
13 is_special = CGI.param("_special").size;
15 # Check if we want to show the detail record view. Doing this
16 # here because we don't want to repeat logic in multiple other
17 # files, nor do we want to add a new tt2 file just for this. The
18 # below is currently needed for parts/result/table.tt2,
19 # parts/searchbar.tt2, and results.tt2.
21 IF CGI.param("detail_record_view").defined;
22 show_detail_view = CGI.param("detail_record_view");
23 ELSIF show_more_details.default == "true" OR
24 show_more_details.default == "hide";
28 #variables to use to remove parameters via mkurk
29 expert_search_parms = ['tag','subfield','term','_special'];
30 general_search_parms = ['page','sort','query','bool','contains','pubdate'];
31 browse_search_parms = ['fi:has_browse_entry','bterm','blimit','bpivot'];
32 facet_search_parms = ['facet'];
35 # -----------------------------------------------------------------------------
36 # mkurl( destination_page, params_to_set, params_to_clear )
38 # Current page, updated params:
39 # mkurl('', {foo => 'bar', boo => 'baz'});
41 # New page, one param is a list:
42 # mkurl('http://flarg.baz/squz', {foo => 'bar', boo => ['baz', 'faz']});
44 # New page, clear all existing params before applying new ones:
45 # mkurl('/fuz/buster', {foo => 'bar', boo => 'baz'}, 1);
47 # Current page, clear 'some_param' from the existing params:
48 # mkurl('', {foo => 'bar', boo => 'baz'}, ['some_param']);
50 # Current page to a named anchor 'copies'
51 # mkurl('', {}, [], 'copies');
52 MACRO mkurl(page, params, clear_params, named_anchor) BLOCK;
54 # clone the query string to avoid clobberation
55 cgi = CGI.new(CGI.query_string);
57 # remove requested params
58 IF clear_params.0; # array
59 FOR p IN clear_params; cgi.delete(p); END;
64 # x and y are artifacts of using <input type="image" /> tags
65 # instead of true submit buttons, and their values are never used.
73 # The following commented-out line can be fooled. Its replacement
74 # below is what you really mean.
75 # list = (params.$k.0 OR max == -1) ? params.$k : [params.$k];
76 list = params.$k.list;
78 IF list.size == 0; NEXT; END;
79 # CGI croaks on already-decoded strings. force-encode to be safe.
80 FOR p IN list; encoded.push(ctx.encode_utf8(p)); END;
81 foo = cgi.param("-name", k, "-values", encoded);
84 # for url brevity, remove any params that have no value
87 IF val == ''; cgi.delete(p); END;
89 # Delete POST vars unless we asked for them
90 UNLESS CGI.url_param(p).defined OR params.defined(p);
95 final = named_anchor ? '#' _ named_anchor : '';
99 page _ '?' _ cgi.query_string _ final;
104 # staying on the current page
105 cgi.url("-absolute" => 1, "-path" => 1, "-query" => 1) _ final;
109 # Dojo is required for the copy locations advanced search filter
110 IF ctx.page == 'advanced';
114 use_autosuggest = ctx.get_cgf("opac.use_autosuggest");
116 IF use_autosuggest.enabled == "t";
120 IF ENV.OILS_NOVELIST_URL;
124 IF ebook_api.enabled == 'true';
128 # Especially useful for image 'alt' tags and link title tags,
129 # where the content may need to be unique (making it longer)
130 # but should not exceed 75 chars for ideal screen reader support.
131 # usage: html_text_attr('title', 'Link to item I Have A Super Long Title')
132 # the full HTML attribute key="value" is produced
133 MACRO html_text_attr(name, value) BLOCK;
134 IF value.length >= 75;
135 value = value.substr(71, value.length, '...');
137 value = value.replace('\s*$', ''); # remove trailing whitespace
138 HTML.attributes($name => value);
141 MACRO img_alt(text) BLOCK;
142 html_text_attr('alt', text);