]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/templates/opac/parts/record/subjects.tt2
Read STDIN up to record separator then stop
[Evergreen.git] / Open-ILS / src / templates / opac / parts / record / subjects.tt2
1 [% 
2     subjects = [
3         {
4             label => l('Subject: '),
5             xpath => '//*[@tag="600" or @tag="610" or @tag="611" or @tag="630" or @tag="650" or @tag="651"]'
6         }, {
7             label => l('Genre: '),
8             xpath => '//*[@tag="655"]|//*[@tag="659"]'
9         }, {
10             label => l('Topic Heading: '),
11             xpath => '//*[@tag="690"]'
12         }, {
13             label => l('Geographic Setting: '),
14             xpath => '//*[@tag="691"]'
15         }, {
16             label => l('Biographical Subject: '),
17             xpath => '//*[@tag="692"]'
18         }, {
19             label => l('Character Attributes: '),
20             xpath => '//*[@tag="693"]'
21         }, {
22             label => l('Setting: '),
23             xpath => '//*[@tag="698"]'
24         }, {
25             label => l('Time Period: '),
26             xpath => '//*[@tag="699"]'
27         }
28     ];
29
30     BLOCK render_subject;
31         loc = CGI.param('loc') | uri;
32         xpath = xpath || '//*[starts-with(@tag,"6")]';
33         FOR node IN ctx.marc_xml.findnodes(xpath);
34             all_terms = [];
35             FOR subfield IN node.childNodes;
36                 NEXT UNLESS subfield.nodeName == "subfield";
37                 code = subfield.getAttribute('code');
38                 NEXT UNLESS code.match('[a-z]');
39                 IF code.match('[vxyz]'); " — "; END;
40                 # at this point, we actually have a partial term to use.
41                 single_term = subfield.textContent | html;
42                 all_terms.push(subfield.textContent);
43                 total_term = all_terms.join(" ").replace('\s+$', '') | uri;
44                 '<a href="' _ ctx.opac_root _ '/results?qtype=subject&amp;query=' _ total_term _ '&amp;loc=' _ loc _ '">' _ single_term _ '</a>';
45             END;
46             IF all_terms.size; "<br/>"; END;
47         END;
48     END 
49 %]
50
51 <div>
52     <table cellpadding="0" cellspacing="0" border="0">
53     [%  any_subjects = 0;
54         FOREACH subj IN subjects;
55             content = PROCESS render_subject(xpath=subj.xpath);
56             IF content.match('\S');
57                 any_subjects = 1; %]
58             <tr>
59                 <td width="1" style="padding:5px 7px 0px 0px;" valign="top">
60                     <strong>[% subj.label %]</strong>
61                 </td>
62                 <td style="padding-top:5px;"><div>[% content %] </div></td>
63             </tr>
64             [% END; %]
65         [% END; %]
66     [% IF any_subjects == 0 %]
67         <tr><td><i>[% l('No Subjects') %]</i></td></tr>
68     [% END; %]
69     </table>
70 </div>