]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/templates/opac/parts/record/subjects.tt2
a89a1be27f1e3515b53e0c00835f1bf4b4080e01
[working/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         xpath = xpath || '//*[starts-with(@tag,"6")]';
32         FOR node IN ctx.marc_xml.findnodes(xpath);
33             '<span property="about">';
34             all_terms = [];
35             graphics = [];
36             FOR subfield IN node.childNodes;
37                 NEXT UNLESS subfield.nodeName == "subfield";
38                 code = subfield.getAttribute('code');
39                 IF code == '6';
40                    linked_fields = [subfield.textContent()];
41                    target_field = node.getAttribute('tag');
42                    get_linked_880s;
43                 END;
44                 NEXT UNLESS code.match('[a-z]');
45                 IF code.match('[vxyz]'); " &gt; "; END;
46                 # at this point, we actually have a partial term to use.
47                 single_term = subfield.textContent | html;
48                 all_terms.push(subfield.textContent.replace('\-', ' ').replace('[#"^$\+,\.:;&|\[\]()]', ''));
49                 total_term = all_terms.join(" ").replace('\s+$', '');
50             %]
51 <a href="[% mkurl(ctx.opac_root _ '/results', {qtype=>'subject', query=>total_term}, stop_parms.merge(expert_search_parms, general_search_parms, browse_search_parms, facet_search_parms)) %]">[% single_term %]</a>
52             [%- END;
53             IF all_terms.size; "<br/>"; END;
54             FOREACH link880 IN graphics;
55                 '<div class="graphic880"' _ link880.dir _ '>';
56                 link880.value | html;
57                 '</div>';
58             END;
59             '</span>';
60         END;
61     END 
62 %]
63
64 [%  BLOCK render_all_subjects;
65     FOREACH subj IN subjects;
66         content = PROCESS render_subject(xpath=subj.xpath);
67         IF content.match('\S');
68 %]
69         <table class='rdetail_subject'>
70             <tbody>
71                 <tr>
72                     <td class='rdetail_subject_type'>[% subj.label %]</td>
73                     <td class='rdetail_subject_value'>[% content %]</td>
74                 </tr>
75             </tbody>
76         </table>
77         [%- END; %]
78     [%- END; %]
79 [%- END %]
80
81 [%-  subject_html = PROCESS render_all_subjects;
82     IF subject_html.length > 0;
83 %]
84 <h2 class='rdetail_related_subjects'>[% l('Search for related items by subject') %]</h2>
85 [%- subject_html %]
86 [%- END %]