Bug 14880: Keyboard shortcuts don't work after setting CircAutocompl to "Don't try"
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / xslt / NORMARCslimUtils.xsl
1 <?xml version='1.0'?>
2 <xsl:stylesheet version="1.0" xmlns:marc="http://www.loc.gov/MARC21/slim" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
3         <xsl:template name="datafield">
4                 <xsl:param name="tag"/>
5                 <xsl:param name="ind1"><xsl:text> </xsl:text></xsl:param>
6                 <xsl:param name="ind2"><xsl:text> </xsl:text></xsl:param>
7                 <xsl:param name="subfields"/>
8                 <xsl:element name="datafield">
9                         <xsl:attribute name="tag">
10                                 <xsl:value-of select="$tag"/>
11                         </xsl:attribute>
12                         <xsl:attribute name="ind1">
13                                 <xsl:value-of select="$ind1"/>
14                         </xsl:attribute>
15                         <xsl:attribute name="ind2">
16                                 <xsl:value-of select="$ind2"/>
17                         </xsl:attribute>
18                         <xsl:copy-of select="$subfields"/>
19                 </xsl:element>
20         </xsl:template>
21
22         <xsl:template name="subfieldSelect">
23                 <xsl:param name="codes"/>
24                 <xsl:param name="delimeter"><xsl:text> </xsl:text></xsl:param>
25                 <xsl:param name="subdivCodes"/>
26                 <xsl:param name="subdivDelimiter"/>
27         <xsl:param name="prefix"/>
28         <xsl:param name="suffix"/>
29                 <xsl:variable name="str">
30                         <xsl:for-each select="marc:subfield">
31                                 <xsl:if test="contains($codes, @code)">
32                     <xsl:if test="contains($subdivCodes, @code)">
33                         <xsl:value-of select="$subdivDelimiter"/>
34                     </xsl:if>
35                                         <xsl:value-of select="$prefix"/><xsl:value-of select="text()"/><xsl:value-of select="$suffix"/><xsl:value-of select="$delimeter"/>
36                                 </xsl:if>
37                         </xsl:for-each>
38                 </xsl:variable>
39                 <xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>
40         </xsl:template>
41
42         <xsl:template name="buildSpaces">
43                 <xsl:param name="spaces"/>
44                 <xsl:param name="char"><xsl:text> </xsl:text></xsl:param>
45                 <xsl:if test="$spaces>0">
46                         <xsl:value-of select="$char"/>
47                         <xsl:call-template name="buildSpaces">
48                                 <xsl:with-param name="spaces" select="$spaces - 1"/>
49                                 <xsl:with-param name="char" select="$char"/>
50                         </xsl:call-template>
51                 </xsl:if>
52         </xsl:template>
53
54     <xsl:template name="buildBiblioDefaultViewURL">
55         <xsl:param name="IntranetBiblioDefaultView"/>
56         <xsl:choose>
57             <xsl:when test="$IntranetBiblioDefaultView='normal'">
58                 <xsl:text>/cgi-bin/koha/catalogue/detail.pl?biblionumber=</xsl:text>
59             </xsl:when>
60             <xsl:when test="$IntranetBiblioDefaultView='isbd'">
61                 <xsl:text>/cgi-bin/koha/catalogue/ISBDdetail.pl?biblionumber=</xsl:text>
62             </xsl:when>
63             <xsl:when test="$IntranetBiblioDefaultView='labeled_marc'">
64                 <xsl:text>/cgi-bin/koha/catalogue/labeledMARCdetail.pl?biblionumber=</xsl:text>
65             </xsl:when>
66             <xsl:when test="$IntranetBiblioDefaultView='marc'">
67                 <xsl:text>/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=</xsl:text>
68             </xsl:when>
69             <xsl:otherwise>
70                 <xsl:text>/cgi-bin/koha/catalogue/detail.pl?biblionumber=</xsl:text>
71             </xsl:otherwise>
72         </xsl:choose>
73     </xsl:template>
74
75         <xsl:template name="chopPunctuation">
76                 <xsl:param name="chopString"/>
77                 <xsl:variable name="length" select="string-length($chopString)"/>
78                 <xsl:choose>
79                         <xsl:when test="$length=0"/>
80                         <xsl:when test="contains('.:,;/ ', substring($chopString,$length,1))">
81                                 <xsl:call-template name="chopPunctuation">
82                                         <xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
83                                 </xsl:call-template>
84                         </xsl:when>
85                         <xsl:when test="not($chopString)"/>
86                         <xsl:otherwise><xsl:value-of select="$chopString"/></xsl:otherwise>
87                 </xsl:choose>
88 <xsl:text> </xsl:text>
89         </xsl:template>
90
91         <!-- Function extractControlNumber is used to extract the control number (record number) from MARC tags 773/80/85 [etc.] subfield $w.
92              Parameter: control number string.
93              Assumes LOC convention: (OrgCode)recordNumber.
94              If OrgCode is not present, return full string.
95              Additionally, handle various brackets/parentheses. Chop leading and trailing spaces.
96         -->
97         <xsl:template name="extractControlNumber">
98             <xsl:param name="subfieldW"/>
99             <xsl:variable name="tranW" select="translate($subfieldW,']})&gt;','))))')"/>
100             <xsl:choose>
101               <xsl:when test="contains($tranW,')')">
102                 <xsl:value-of select="normalize-space(translate(substring-after($tranW,')'),'[]{}()&lt;&gt;',''))"/>
103               </xsl:when>
104               <xsl:otherwise>
105                 <xsl:value-of select="normalize-space($subfieldW)"/>
106               </xsl:otherwise>
107             </xsl:choose>
108         </xsl:template>
109
110 <xsl:template name="nameABCDQ">
111 <xsl:call-template name="chopPunctuation">
112 <xsl:with-param name="chopString">
113 <xsl:call-template name="subfieldSelect">
114 <xsl:with-param name="codes">aq</xsl:with-param>
115 </xsl:call-template>
116 </xsl:with-param>
117 <xsl:with-param name="punctuation">
118 <xsl:text>:,;/ </xsl:text>
119 </xsl:with-param>
120 </xsl:call-template>
121 <xsl:call-template name="termsOfAddress"/>
122 </xsl:template>
123
124 <xsl:template name="nameABCDN">
125 <xsl:for-each select="marc:subfield[@code='a']">
126 <xsl:call-template name="chopPunctuation">
127 <xsl:with-param name="chopString" select="."/>
128 </xsl:call-template>
129 </xsl:for-each>
130 <xsl:for-each select="marc:subfield[@code='b']">
131 <xsl:value-of select="."/>
132 </xsl:for-each>
133 <xsl:if test="marc:subfield[@code='c'] or marc:subfield[@code='d'] or marc:subfield[@code='n']">
134 <xsl:call-template name="subfieldSelect">
135 <xsl:with-param name="codes">cdn</xsl:with-param>
136 </xsl:call-template>
137 </xsl:if>
138 </xsl:template>
139
140 <xsl:template name="nameACDEQ">
141 <xsl:call-template name="subfieldSelect">
142 <xsl:with-param name="codes">acdeq</xsl:with-param>
143 </xsl:call-template>
144 </xsl:template>
145
146 <xsl:template name="termsOfAddress">
147 <xsl:if test="marc:subfield[@code='b' or @code='c']">
148 <xsl:call-template name="chopPunctuation">
149 <xsl:with-param name="chopString">
150 <xsl:call-template name="subfieldSelect">
151 <xsl:with-param name="codes">bc</xsl:with-param>
152 </xsl:call-template>
153 </xsl:with-param>
154 </xsl:call-template>
155 </xsl:if>
156 </xsl:template>
157
158     <!-- Function m880Select:  Display Alternate Graphic Representation (MARC 880) for selected latin "base"tags
159         - should be called immediately before the corresonding latin tags are processed 
160         - tags in right-to-left languages are displayed floating right
161         * Parameter:
162            + basetags: display these tags if found in linkage section ( subfield 6) of tag 880
163            + codes: display these subfields codes
164         * Options: 
165             - class: wrap output in <span class="$class">...</span>
166             - label: prefix each(!) tag with label $label
167             - bibno: link to biblionumber $bibno
168             - index: build a search link using index $index with subfield $a as key; if subfield $9 is present use index 'an' with key $9 instead.
169          * Limitations:
170             - displays every field on a separate line (to switch between rtl and ltr)
171          * Pitfalls:
172            (!) output might be empty
173     -->
174     <xsl:template name="m880Select">
175          <xsl:param name="basetags"/> <!-- e.g.  100,700,110,710 -->
176         <xsl:param name="codes"/> <!-- e.g. abc  -->
177         <xsl:param name="class"/> <!-- e.g. results_summary -->
178         <xsl:param name="label"/> <!-- e.g.  Edition -->
179         <xsl:param name="bibno"/>
180         <xsl:param name="index"/> <!-- e.g.  au -->
181
182         <xsl:for-each select="marc:datafield[@tag=880]">
183             <xsl:variable name="code6" select="marc:subfield[@code=6]"/>
184             <xsl:if test="contains(string($basetags), substring($code6,1,3))">
185                 <span>
186                     <xsl:if test="boolean($class)">
187                         <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
188                     </xsl:if>
189                     <xsl:choose>
190                         <!-- display right-to-left tags floating right of their left-to-right counterparts -->
191                         <xsl:when test="substring($code6,10,2) ='/r'">
192                             <xsl:attribute name="style">display:block; text-align:right; float:right; width:50%; padding-left:20px</xsl:attribute>
193                             <xsl:attribute name="dir">rtl</xsl:attribute>
194                         </xsl:when>
195                         <xsl:otherwise>
196                             <xsl:attribute name="style">display:block; </xsl:attribute>
197                         </xsl:otherwise>
198                     </xsl:choose>
199                     <xsl:if test="boolean($label)">
200                         <span class="label">
201                             <xsl:value-of select="$label"/>
202                         </span>
203                     </xsl:if>
204                     <xsl:variable name="str">
205                         <xsl:for-each select="marc:subfield">
206                             <xsl:if test="contains($codes, @code)">
207                                 <xsl:value-of select="text()"/>
208                                 <xsl:text> </xsl:text>
209                             </xsl:if>
210                         </xsl:for-each>
211                     </xsl:variable>
212                     <xsl:choose>
213                         <xsl:when test="boolean($bibno)">
214                             <a>
215                                 <xsl:attribute name="href">/cgi-bin/koha/opac-detail.pl?biblionumber=<xsl:value-of  select="$bibno"/></xsl:attribute>
216                                 <xsl:value-of select="$str"/>
217                             </a>
218                         </xsl:when>
219                        <xsl:when test="boolean($index) and boolean(marc:subfield[@code=9])">
220                             <a>
221                                 <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=an:<xsl:value-of  select="marc:subfield[@code=9]"/></xsl:attribute>
222                                   <xsl:value-of select="$str"/>
223                             </a>
224                         </xsl:when>
225                         <xsl:when test="boolean($index)">
226                             <a>
227                                 <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=<xsl:value-of  select="$index"/>:<xsl:value-of  select="marc:subfield[@code='a']"/></xsl:attribute>
228                                 <xsl:value-of select="$str"/>
229                             </a>
230                         </xsl:when>
231                         <xsl:otherwise>
232                             <xsl:value-of select="$str"/>
233                         </xsl:otherwise>
234                     </xsl:choose>
235                 </span>
236             </xsl:if>
237         </xsl:for-each>
238
239     </xsl:template>
240
241 </xsl:stylesheet>
242
243 <!-- Stylus Studio meta-information - (c)1998-2002 eXcelon Corp.
244 <metaInformation>
245 <scenarios/><MapperInfo srcSchemaPath="" srcSchemaRoot="" srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/>
246 </metaInformation>
247 -->