]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/web/templates/default/opac/parts/misc_util.tt2
TTpac: show full 245 for title on record details page
[working/Evergreen.git] / Open-ILS / web / templates / default / opac / parts / misc_util.tt2
1 [% 
2     # Extract MARC fields from XML
3     #   get_marc_attrs( { marc_xml => doc } )
4     BLOCK get_marc_attrs;
5         xml = args.marc_xml;
6
7         args.isbns = [];
8         FOR isbn IN xml.findnodes('//*[@tag="020"]/*[@code="a"]');
9             args.isbns.push(isbn.textContent);
10         END;
11
12         args.upc = xml.findnodes('//*[@tag="024"]/*[@code="a"]').textContent;
13         args.issn = xml.findnodes('//*[@tag="022"]/*[@code="a"]').textContent;
14         args.title = xml.findnodes('//*[@tag="245"]/*[@code="a"]').textContent;
15         args.title_extended = xml.findnodes('//*[@tag="245"]').textContent;
16         args.author = xml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent;
17         args.publisher = xml.findnodes('//*[@tag="260"]/*[@code="b"]').textContent;
18         args.pubdate = xml.findnodes('//*[@tag="260"]/*[@code="c"]').textContent;
19         args.edition = xml.findnodes('//*[@tag="250"]/*[@code="a"]').textContent ||
20             xml.findnodes('//*[@tag="534"]/*[@code="b"]').textContent ||
21             xml.findnodes('//*[@tag="775"]/*[@code="b"]').textContent;
22         phys = xml.findnodes(
23             '//*[@tag="300"]/*[@code="a" or @code="b" or @code="c" or @code="e"]'
24         );
25         phys_content = [];
26         FOR p IN phys; phys_content.push(p.textContent); END;
27         args.phys_desc = phys_content.join("");
28
29         # capture all of the 520a's
30         args.summary = [];
31         FOR s IN xml.findnodes('//*[@tag="520"]/*[@code="a"]');
32             args.summary.push(s.textContent); 
33         END;
34
35         # MARC Callnumber
36         args.marc_cn = xml.findnodes('//*[@tag="092" or @tag="099"]/*').textContent;
37
38         # clean up the ISBN
39         args.isbn_clean = args.isbns.0.replace('\ .*', '');
40
41         args.holdings = [];
42         FOR holding IN xml.findnodes('//*[local-name()="volumes"]/*[local-name()="volume"]');
43             args.holdings.push(
44                 holding.getAttribute('label')
45             );
46         END;
47
48         # Extract the copy count summary
49         count_type = (ctx.is_staff) ? 'staff' : 'public';
50         xpath = '//*[local-name()="counts"]/*[local-name()="count"][@type="' _ count_type _ '"]';
51         FOR node IN xml.findnodes(xpath);
52             args.copy_counts = {};
53             FOR attr IN ['count', 'available', 'unshadow', 'transcendant']; 
54                 args.copy_counts.$attr = node.getAttribute(attr);
55             END;
56         END;
57
58         # "mattype" == "custom marc format specifier"
59         FOR icon_style IN ['mattype', 'item_type']; 
60             node = xml.findnodes(
61                 '//*[local-name()="attributes"]/*[local-name()="field"][@name="' _ icon_style _ '"]');
62             IF node AND node.textContent;
63                 args.format_label = node.getAttribute('coded-value')
64                 args.format_icon = ctx.media_prefix _ '/images/format_icons/' _ icon_style _ '/' _ node.textContent _ '.png';
65                 LAST;
66             END;
67         END;
68     END;
69
70     BLOCK get_hold_status;
71         IF hold.hold.status == 4;
72             l("Available");
73             IF ahr.shelf_expire_time;
74                 l('<br/>Expires [_1]', 
75                     date.format(ctx.parse_datetime(ahr.shelf_expire_time), DATE_FORMAT));
76             END;
77         ELSIF hold.hold.estimated_wait AND hold.hold.estimated_wait > 0;
78             # estimated wait is delivered as seconds.
79             SET hwait = POSIX.ceil(hold.hold.estimated_wait / 86400);
80             l("Estimated wait: [quant,_1,day,days]", hwait);
81         ELSIF hold.hold.status == 3;
82             l("In Transit");
83         ELSIF hold.hold.status < 3;
84             l("Waiting for copy");
85         END;
86     END;
87 %]