]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/templates/opac/parts/record/authors.tt2
LP#1037171 Removed Expert Search paramters from subject links
[working/Evergreen.git] / Open-ILS / src / templates / opac / parts / record / authors.tt2
1 [%-  
2
3 PROCESS "opac/parts/relators.tt2";
4
5 author_cnt = 0;
6 authors = [
7     {
8         type => 'author', 
9         label => l('Author'),
10         xpath => '//*[@tag="100"]|//*[@tag="110"]|//*[@tag="111"]'
11     }, {
12         type => 'added', 
13         label => l('Added Author'),
14         xpath => '//*[@tag="700"]|//*[@tag="710"]|//*[@tag="711"]'
15     }, {
16         type => 'cast', 
17         label => l('Cast'),
18         xpath => '//*[@tag="508"]'
19     }, {
20         type => 'notes', 
21         label => l('Author Notes: '),
22         xpath => '' # Comes from added content...
23     }
24 ];
25
26 BLOCK build_author_links;
27     FOR node IN ctx.marc_xml.findnodes(xpath);
28         author_cnt = author_cnt + 1;
29         contrib_ref = '#schemacontrib' _ author_cnt;
30         iprop = '';
31         term = '';
32         qterm = '';
33         tlabel = '';
34         birthdate = '';
35         deathdate = '';
36         graphics = [];
37         tag = node.getAttribute('tag');
38         FOR subfield IN node.childNodes;
39             NEXT UNLESS subfield.nodeName == "subfield";
40             code = subfield.getAttribute('code');
41             IF code == '4';
42                 relcode = subfield.textContent.substr(0,3);
43                 tlabel = relators.$relcode || label;
44             END;
45             IF code == '6';
46                target_field = tag;
47                linked_fields = [subfield.textContent()];
48                get_linked_880s;
49             END;
50             NEXT UNLESS code.match('[a-z]');
51             sf = subfield.textContent | html;
52             IF code.match('[acdq]');
53                 sf_raw = subfield.textContent.replace('[#"^$\+\-,\.:;&|\[\]()]', ' ');
54                 qterm = qterm _ ' ' _ sf_raw;
55             END;
56             # Only Persons have birth/death dates in schema.org
57             IF code.match('d') && tag.substr(1,2) == '00';
58                 IF subfield.textContent.match('^\s*\d{4}');
59                     birthdate = subfield.textContent.replace('^\s*(\d{4}).*$', '$1');
60                 END;
61                 IF subfield.textContent.match('-\d{4}.*$');
62                     deathdate = subfield.textContent.replace('^\s*.{4}\-(\d{4}).*$', '$1');
63                 END;
64             ELSE;
65                 term = term _ ' ' _ sf;
66             END;
67         END;
68         url = mkurl(ctx.opac_root _ '/results', {query => qterm, qtype => 'author'}, stop_parms.merge(expert_search_parms, general_search_parms));
69         author_type = (tlabel || label) | html;
70         
71         # schema.org changes
72         IF type == 'author';
73             IF tag.substr(1,2) == '10' && args.schema.itemtype && args.schema.itemtype.match('MusicAlbum');
74                 iprop = ' typeof="MusicGroup" property="byArtist"';
75             ELSIF tag.substr(1,2) == '00';
76                 iprop = ' typeof="Person" property="author"';
77             ELSE;
78                 iprop = ' typeof="Organization" property="author"';
79             END;
80         ELSIF type == 'added';
81             IF tag.substr(1,2) == '00';
82                 iprop = ' typeOf="Person" property="contributor"';
83             ELSE;
84                 iprop = ' typeOf="Organization" property="contributor"';
85             END;
86         END;
87         '<span' _ iprop _ ' resource="' _ contrib_ref _ '"><a href="' _ url _ '">';
88         IF iprop; '<span property="name" about="' _ contrib_ref _ '">'; END;
89         term.replace('^\s+', '');
90         IF iprop; '</span>'; END;
91         IF birthdate;
92             ' <span property="birthDate" about="' _ contrib_ref _ '">' _ birthdate _ '</span>-';
93         END;
94         IF deathdate;
95             '<span property="deathDate" about="' _ contrib_ref _ '">' _ deathdate _ '</span>';
96         END;
97         '</a>'; # End search link
98         FOREACH link880 IN graphics;
99             diratt = '';
100             IF link880.dir;
101                 diratt = ' dir="' _ link880.dir _ '"';
102             END;
103             ' <span class="graphic880"' _ diratt _ '>';
104             link880.value | html;
105             '</span>';
106         END;
107         ' (<span property="description" about="' _ contrib_ref _ '">' _ author_type _ '</span>). ';
108         '</span>'; # End author span
109     END;
110 END;
111 %]
112
113 <div class='rdetail_authors_div'>
114 [%- FOREACH author IN authors;
115     NEXT UNLESS author.xpath; 
116     links = PROCESS build_author_links(
117         xpath=author.xpath, label=author.label, type=author.type
118     );
119     IF links.match('\S') %]
120     <span class='rdetail-author-div'>[% links %]</span>
121     [%- END %]
122 [%- END %]
123 </div>
124
125