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