1 [%- USE money = format(l('$%.2f'));
5 SET DATE_FORMAT = l('%m/%d/%Y');
7 # Don't wrap in l() here; do that where this format string is actually used.
8 SET HUMAN_NAME_FORMAT = '[_1] [_2] [_3] [_4] [_5]';
10 is_advanced = CGI.param("_adv").size;
11 is_special = CGI.param("_special").size;
13 # -----------------------------------------------------------------------------
14 # mkurl( destination_page, params_to_set, params_to_clear )
16 # Current page, updated params:
17 # mkurl('', {foo => 'bar', boo => 'baz'});
19 # New page, one param is a list:
20 # mkurl('http://flarg.baz/squz', {foo => 'bar', boo => ['baz', 'faz']});
22 # New page, clear all existing params before applying new ones:
23 # mkurl('/fuz/buster', {foo => 'bar', boo => 'baz'}, 1);
25 # Current page, clear 'some_param' from the existing params:
26 # mkurl('', {foo => 'bar', boo => 'baz'}, ['some_param']);
27 MACRO mkurl(page, params, clear_params) BLOCK;
29 # clone the query string to avoid clobberation
30 cgi = CGI.new(CGI.query_string);
32 # remove requested params
33 IF clear_params.0; # array
34 FOR p IN clear_params; cgi.delete(p); END;
39 # x and y are artifacts of using <input type="image" /> tags
40 # instead of true submit buttons, and their values are never used.
46 list = params.$k.0 ? params.$k : [params.$k];
47 # CGI croaks on already-decoded strings. force-encode to be safe.
48 FOR p IN list; encoded.push(ctx.encode_utf8(p)); END;
49 foo = cgi.param("-name", k, "-values", encoded);
52 # for url brevity, remove any params that have no value
55 IF val == ''; cgi.delete(p); END;
60 page _ '?' _ cgi.query_string;
65 # staying on the current page
66 cgi.url("-path" => 1, "-query" => 1);