]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/templates/kpac/parts/util.tt2
632c1800d7bf57ae6b5fb99ba79fac2f99bf13a3
[Evergreen.git] / Open-ILS / src / templates / kpac / parts / util.tt2
1 [% 
2
3     # -----------------------------------------------------------------
4     # Category trail/path utilities
5     # page trail looks like trail=id/id/id
6
7     # adds an ID, esults in the full trail as a string
8     MACRO trail_append(node_id) BLOCK;
9         trail = CGI.param('trail');
10         trail ? trail _ '/' _ node_id : node_id;
11     END;
12
13     # last trail component/id as a string
14     MACRO trail_endpoint BLOCK;
15         trail = CGI.param('trail');
16         list = trail ? trail.split('/') : [];
17         list().last;
18     END;
19
20     MACRO trail_splice(page_id) BLOCK;
21         trail = CGI.param('trail');
22         list = trail ? trail.split('/') : [];
23         path = '';
24         FOR id IN list;
25             path = path ? path _ '/' _ id : id;
26             IF id == page_id; LAST; END;
27         END;
28         path;
29     END;
30
31     # -----------------------------------------------------------------
32     # Determines the full path to image URLs
33     # Use absolute and fully-qualified image URLs as-is.
34     # For all others, use the kpac base path.
35     MACRO kpac_img_path(img) BLOCK;
36         IF img.match('^/') OR img.match('^https?://');
37             img;
38         ELSE;
39             ctx.media_prefix _ '/images/kpac/' _ img;
40         END;
41     END;
42 %]
43
44