Bug 10564 - use OPACURLOpenInNewWindow in UNIMARCslim2OPACResults.xsl
[koha.git] / koha-tmpl / opac-tmpl / prog / en / xslt / UNIMARCslim2OPACResults.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2
3 <!DOCTYPE stylesheet [<!ENTITY nbsp "&#160;" >]>
4
5 <xsl:stylesheet version="1.0"
6   xmlns:marc="http://www.loc.gov/MARC21/slim"
7   xmlns:items="http://www.koha-community.org/items"
8   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
9   exclude-result-prefixes="marc items">
10
11 <xsl:import href="UNIMARCslimUtils.xsl"/>
12 <xsl:output method = "html" indent="yes" omit-xml-declaration = "yes" encoding="UTF-8"/>
13 <xsl:key name="item-by-status" match="items:item" use="items:status"/>
14 <xsl:key name="item-by-status-and-branch" match="items:item" use="concat(items:status, ' ', items:homebranch)"/>
15
16 <xsl:template match="/">
17   <xsl:apply-templates/>
18 </xsl:template>
19
20 <xsl:template match="marc:record">
21   <xsl:variable name="leader" select="marc:leader"/>
22   <xsl:variable name="leader6" select="substring($leader,7,1)"/>
23   <xsl:variable name="leader7" select="substring($leader,8,1)"/>
24   <xsl:variable name="biblionumber"
25    select="marc:datafield[@tag=090]/marc:subfield[@code='a']"/>
26   <xsl:variable name="isbn"
27    select="marc:datafield[@tag=010]/marc:subfield[@code='a']"/>
28
29   <xsl:variable name="hidelostitems" select="marc:sysprefs/marc:syspref[@name='hidelostitems']"/>
30   <xsl:variable name="singleBranchMode" select="marc:sysprefs/marc:syspref[@name='singleBranchMode']"/>
31   <xsl:variable name="OPACURLOpenInNewWindow" select="marc:sysprefs/marc:syspref[@name='OPACURLOpenInNewWindow']"/>
32
33   <xsl:if test="marc:datafield[@tag=200]">
34     <xsl:for-each select="marc:datafield[@tag=200]">
35         <xsl:call-template name="addClassRtl" />
36         <xsl:for-each select="marc:subfield">
37           <xsl:choose>
38             <xsl:when test="@code='a'">
39               <xsl:variable name="title" select="."/>
40               <xsl:variable name="ntitle"
41                 select="translate($title, '&#x0088;&#x0089;&#x0098;&#x009C;','')"/>
42               <a>
43                 <xsl:attribute name="href">
44                   <xsl:text>/cgi-bin/koha/opac-detail.pl?biblionumber=</xsl:text>
45                   <xsl:value-of select="$biblionumber"/>
46                 </xsl:attribute>
47                 <xsl:value-of select="$ntitle" />
48               </a>
49             </xsl:when>
50             <xsl:when test="@code='b'">
51               <xsl:text> [</xsl:text>
52               <xsl:value-of select="."/>
53               <xsl:text>]</xsl:text>
54             </xsl:when>
55             <xsl:when test="@code='d'">
56               <xsl:text> = </xsl:text>
57               <xsl:value-of select="."/>
58             </xsl:when>
59             <xsl:when test="@code='e'">
60               <xsl:text> : </xsl:text>
61               <xsl:value-of select="."/>
62             </xsl:when>
63             <xsl:when test="@code='f'">
64               <xsl:text> / </xsl:text>
65               <xsl:value-of select="."/>
66             </xsl:when>
67             <xsl:when test="@code='g'">
68               <xsl:text> ; </xsl:text>
69               <xsl:value-of select="."/>
70             </xsl:when>
71             <xsl:otherwise>
72               <xsl:text>, </xsl:text>
73               <xsl:value-of select="."/>
74             </xsl:otherwise>
75           </xsl:choose>
76         </xsl:for-each>
77     </xsl:for-each>
78   </xsl:if>
79
80   <xsl:call-template name="tag_title">
81     <xsl:with-param name="tag">454</xsl:with-param>
82     <xsl:with-param name="label">Translation of</xsl:with-param>
83     <xsl:with-param name="spanclass">original_title</xsl:with-param>
84   </xsl:call-template>
85
86   <xsl:call-template name="tag_title">
87     <xsl:with-param name="tag">461</xsl:with-param>
88     <xsl:with-param name="label">Set Level</xsl:with-param>
89     <xsl:with-param name="spanclass">set_level</xsl:with-param>
90   </xsl:call-template>
91
92   <xsl:call-template name="tag_title">
93     <xsl:with-param name="tag">464</xsl:with-param>
94     <xsl:with-param name="label">Piece-Analytic Level</xsl:with-param>
95     <xsl:with-param name="spanclass">piece_analytic_level</xsl:with-param>
96   </xsl:call-template>
97
98   <xsl:call-template name="tag_210" />
99
100   <xsl:call-template name="tag_215" />
101
102   <span class="results_summary availability">
103     <span class="label">Availability: </span>
104     <xsl:choose>
105       <xsl:when test="marc:datafield[@tag=856]">
106         <xsl:for-each select="marc:datafield[@tag=856]">
107           <xsl:choose>
108             <xsl:when test="@ind2=0">
109               <a>
110                 <xsl:attribute name="href">
111                   <xsl:value-of select="marc:subfield[@code='u']"/>
112                 </xsl:attribute>
113                 <xsl:if test="$OPACURLOpenInNewWindow='1'">
114                     <xsl:attribute name="target">_blank</xsl:attribute>
115                 </xsl:if>
116                 <xsl:choose>
117                   <xsl:when test="marc:subfield[@code='y' or @code='3' or @code='z']">
118                     <xsl:call-template name="subfieldSelect">                        
119                       <xsl:with-param name="codes">y3z</xsl:with-param>                    
120                     </xsl:call-template>
121                   </xsl:when>
122                   <xsl:when test="not(marc:subfield[@code='y']) and not(marc:subfield[@code='3']) and not(marc:subfield[@code='z'])">
123                     Click here to access online
124                   </xsl:when>
125                 </xsl:choose>
126               </a>
127               <xsl:choose>
128                 <xsl:when test="position()=last()"></xsl:when>
129                 <xsl:otherwise> | </xsl:otherwise>
130               </xsl:choose>
131             </xsl:when> 
132           </xsl:choose>
133         </xsl:for-each>
134       </xsl:when>
135       <xsl:when test="count(key('item-by-status', 'available'))=0 and count(key('item-by-status', 'reference'))=0">
136         No copies available
137       </xsl:when>
138       <xsl:when test="count(key('item-by-status', 'available'))>0">
139         <span class="available">
140           <b><xsl:text>Copies available for loan: </xsl:text></b>
141           <xsl:variable name="available_items" select="key('item-by-status', 'available')"/>
142       <xsl:choose>
143       <xsl:when test="$singleBranchMode=1">
144       <xsl:for-each select="$available_items[generate-id() = generate-id(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch))[1])]">
145         <xsl:if test="items:itemcallnumber != '' and items:itemcallnumber"> [<xsl:value-of select="items:itemcallnumber"/>]</xsl:if>
146           <xsl:text> (</xsl:text>
147           <xsl:value-of select="count(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch)))"/>
148           <xsl:text>)</xsl:text>
149           <xsl:choose><xsl:when test="position()=last()"><xsl:text>. </xsl:text></xsl:when><xsl:otherwise><xsl:text>, </xsl:text></xsl:otherwise></xsl:choose>
150       </xsl:for-each>
151       </xsl:when>
152       <xsl:otherwise>
153           <xsl:for-each select="$available_items[generate-id() = generate-id(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch))[1])]">
154             <xsl:value-of select="items:homebranch"/>
155                             <xsl:if test="items:itemcallnumber != '' and items:itemcallnumber">[<xsl:value-of select="items:itemcallnumber"/>]
156                             </xsl:if>
157             <xsl:text> (</xsl:text>
158             <xsl:value-of select="count(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch)))"/>
159             <xsl:text>)</xsl:text>
160             <xsl:choose>
161               <xsl:when test="position()=last()">
162                 <xsl:text>. </xsl:text>
163               </xsl:when>
164               <xsl:otherwise>
165                 <xsl:text>, </xsl:text>
166               </xsl:otherwise>
167             </xsl:choose>
168           </xsl:for-each>
169       </xsl:otherwise>
170       </xsl:choose>
171         </span>
172       </xsl:when>
173     </xsl:choose>
174     <xsl:choose>
175       <xsl:when test="count(key('item-by-status', 'reference'))>0">
176         <span class="available">
177           <b><xsl:text>Copies available for reference: </xsl:text></b>
178           <xsl:variable name="reference_items"
179                         select="key('item-by-status', 'reference')"/>
180           <xsl:for-each select="$reference_items[generate-id() = generate-id(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch))[1])]">
181             <xsl:value-of select="items:homebranch"/>
182             <xsl:if test="items:itemcallnumber != '' and items:itemcallnumber">[<xsl:value-of select="items:itemcallnumber"/>]</xsl:if>
183             <xsl:text> (</xsl:text>
184             <xsl:value-of select="count(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch)))"/>
185             <xsl:text>)</xsl:text>
186             <xsl:choose>
187               <xsl:when test="position()=last()">
188                 <xsl:text>. </xsl:text>
189               </xsl:when>
190               <xsl:otherwise>
191                 <xsl:text>, </xsl:text>
192               </xsl:otherwise>
193             </xsl:choose>
194           </xsl:for-each>
195         </span>
196       </xsl:when>
197     </xsl:choose>
198     <xsl:if test="count(key('item-by-status', 'Checked out'))>0">
199       <span class="unavailable">
200         <xsl:text>Checked out (</xsl:text>
201         <xsl:value-of select="count(key('item-by-status', 'Checked out'))"/>
202         <xsl:text>). </xsl:text>
203       </span>
204     </xsl:if>
205     <xsl:if test="count(key('item-by-status', 'Withdrawn'))>0">
206       <span class="unavailable">
207         <xsl:text>Withdrawn (</xsl:text>
208         <xsl:value-of select="count(key('item-by-status', 'Withdrawn'))"/>
209         <xsl:text>). </xsl:text>
210       </span>
211     </xsl:if>
212     <xsl:if test="$hidelostitems='0' and count(key('item-by-status', 'Lost'))>0">
213       <span class="unavailable">
214         <xsl:text>Lost (</xsl:text>
215         <xsl:value-of select="count(key('item-by-status', 'Lost'))"/>
216         <xsl:text>). </xsl:text>
217       </span>
218     </xsl:if>
219     <xsl:if test="count(key('item-by-status', 'Damaged'))>0">
220       <span class="unavailable">
221         <xsl:text>Damaged (</xsl:text>
222         <xsl:value-of select="count(key('item-by-status', 'Damaged'))"/>
223         <xsl:text>). </xsl:text>
224       </span>
225     </xsl:if>
226     <xsl:if test="count(key('item-by-status', 'On order'))>0">
227       <span class="unavailable">
228         <xsl:text>On order (</xsl:text>
229         <xsl:value-of select="count(key('item-by-status', 'On order'))"/>
230         <xsl:text>). </xsl:text>
231       </span>
232     </xsl:if>
233     <xsl:if test="count(key('item-by-status', 'In transit'))>0">
234       <span class="unavailable">
235         <xsl:text>In transit (</xsl:text>
236         <xsl:value-of select="count(key('item-by-status', 'In transit'))"/>
237         <xsl:text>). </xsl:text>
238       </span>
239     </xsl:if>
240     <xsl:if test="count(key('item-by-status', 'Waiting'))>0">
241       <span class="unavailable">
242         <xsl:text>On hold (</xsl:text>
243         <xsl:value-of select="count(key('item-by-status', 'Waiting'))"/>
244         <xsl:text>). </xsl:text>
245       </span>
246     </xsl:if>
247   </span>
248
249 </xsl:template>
250
251 </xsl:stylesheet>